diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/DeviceProvisioningServicesCertificateResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/DeviceProvisioningServicesCertificateResource.cs index 6faea1f306c5..013af6cbdd62 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/DeviceProvisioningServicesCertificateResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/DeviceProvisioningServicesCertificateResource.cs @@ -1,17 +1,27 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +// + +#nullable disable + using System; -using System.Collections.Generic; -using System.Text; -using Azure.ResourceManager.DeviceProvisioningServices.Models; -using System.Threading.Tasks; +using System.Globalization; using System.Threading; +using System.Threading.Tasks; using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - public partial class DeviceProvisioningServicesCertificateResource + /// + /// A Class representing a DeviceProvisioningServicesCertificate 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 GetDeviceProvisioningServicesCertificateResource method. + /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServicesCertificate method. + /// + public partial class DeviceProvisioningServicesCertificateResource : ArmResource { /// /// Deletes the specified certificate associated with the Provisioning Service @@ -22,36 +32,38 @@ public partial class DeviceProvisioningServicesCertificateResource /// /// /// Operation Id - /// DpsCertificate_Delete + /// CertificateResponse_Delete + /// + /// + /// Default Api Version + /// 2025-02-01-preview + /// + /// + /// Resource + /// /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// ETag of the certificate. - /// This is optional, and it is the Common Name of the certificate. - /// Raw data within the certificate. - /// Indicates if certificate has been verified by owner of the private key. - /// A description that mentions the purpose of the certificate. - /// Time the certificate is created. - /// Time the certificate is last updated. - /// Indicates if the certificate contains a private key. - /// Random number generated to indicate Proof of Possession. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. - /// is null. - public virtual async Task DeleteAsync(WaitUntil waitUntil, string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task DeleteAsync(WaitUntil waitUntil, DeviceProvisioningServicesCertificateResourceDeleteOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - - DeviceProvisioningServicesCertificateResourceDeleteOptions options = new DeviceProvisioningServicesCertificateResourceDeleteOptions(ifMatch); - options.CertificateCommonName = certificateCommonName; - options.CertificateIsVerified = certificateIsVerified; - options.CertificatePurpose = certificatePurpose; - options.CertificateCreatedOn = certificateCreatedOn; - options.CertificateLastUpdatedOn = certificateLastUpdatedOn; - options.CertificateHasPrivateKey = certificateHasPrivateKey; - options.CertificateNonce = certificateNonce; + Argument.AssertNotNull(options, nameof(options)); - return await DeleteAsync(waitUntil, options, cancellationToken).ConfigureAwait(false); + return await this.DeleteAsync( + waitUntil, + options.IfMatch, + options.CertificateCommonName, + BinaryData.FromBytes(options.CertificateRawBytes), + options.CertificateIsVerified, + options.CertificatePurpose, + options.CertificateCreatedOn, + options.CertificateLastUpdatedOn, + options.CertificateHasPrivateKey, + options.CertificateNonce, + cancellationToken).ConfigureAwait(false); } /// @@ -63,36 +75,38 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, string /// /// /// Operation Id - /// DpsCertificate_Delete + /// CertificateResponse_Delete + /// + /// + /// Default Api Version + /// 2025-02-01-preview + /// + /// + /// Resource + /// /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// ETag of the certificate. - /// This is optional, and it is the Common Name of the certificate. - /// Raw data within the certificate. - /// Indicates if certificate has been verified by owner of the private key. - /// A description that mentions the purpose of the certificate. - /// Time the certificate is created. - /// Time the certificate is last updated. - /// Indicates if the certificate contains a private key. - /// Random number generated to indicate Proof of Possession. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Delete(WaitUntil waitUntil, string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Delete(WaitUntil waitUntil, DeviceProvisioningServicesCertificateResourceDeleteOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - - DeviceProvisioningServicesCertificateResourceDeleteOptions options = new DeviceProvisioningServicesCertificateResourceDeleteOptions(ifMatch); - options.CertificateCommonName = certificateCommonName; - options.CertificateIsVerified = certificateIsVerified; - options.CertificatePurpose = certificatePurpose; - options.CertificateCreatedOn = certificateCreatedOn; - options.CertificateLastUpdatedOn = certificateLastUpdatedOn; - options.CertificateHasPrivateKey = certificateHasPrivateKey; - options.CertificateNonce = certificateNonce; + Argument.AssertNotNull(options, nameof(options)); - return Delete(waitUntil, options, cancellationToken); + return this.Delete( + waitUntil, + options.IfMatch, + options.CertificateCommonName, + BinaryData.FromBytes(options.CertificateRawBytes), + options.CertificateIsVerified, + options.CertificatePurpose, + options.CertificateCreatedOn, + options.CertificateLastUpdatedOn, + options.CertificateHasPrivateKey, + options.CertificateNonce, + cancellationToken); } /// @@ -104,36 +118,36 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, string ifMatch, string c /// /// /// Operation Id - /// DpsCertificate_GenerateVerificationCode + /// CertificateResponses_GenerateVerificationCode + /// + /// + /// Default Api Version + /// 2025-02-01-preview + /// + /// + /// Resource + /// /// /// /// - /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Description mentioning the purpose of the certificate. - /// Certificate creation time. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. - /// is null. - public virtual async Task> GenerateVerificationCodeAsync(string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> GenerateVerificationCodeAsync(DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - - DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options = new DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions(ifMatch); - options.CertificateCommonName = certificateCommonName; - options.CertificateRawBytes = certificateRawBytes; - options.CertificateIsVerified = certificateIsVerified; - options.CertificatePurpose = certificatePurpose; - options.CertificateCreatedOn = certificateCreatedOn; - options.CertificateLastUpdatedOn = certificateLastUpdatedOn; - options.CertificateHasPrivateKey = certificateHasPrivateKey; - options.CertificateNonce = certificateNonce; + Argument.AssertNotNull(options, nameof(options)); - return await GenerateVerificationCodeAsync(options, cancellationToken).ConfigureAwait(false); + return await GenerateVerificationCodeAsync( + options.IfMatch, + options.CertificateCommonName, + BinaryData.FromBytes(options.CertificateRawBytes), + options.CertificateIsVerified, + options.CertificatePurpose, + options.CertificateCreatedOn, + options.CertificateLastUpdatedOn, + options.CertificateHasPrivateKey, + options.CertificateNonce, + cancellationToken).ConfigureAwait(false); } /// @@ -145,40 +159,40 @@ public virtual async Task> GenerateV /// /// /// Operation Id - /// DpsCertificate_GenerateVerificationCode + /// CertificateResponses_GenerateVerificationCode + /// + /// + /// Default Api Version + /// 2025-02-01-preview + /// + /// + /// Resource + /// /// /// /// - /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Description mentioning the purpose of the certificate. - /// Certificate creation time. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. - /// is null. - public virtual Response GenerateVerificationCode(string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) + /// is null. + public virtual Response GenerateVerificationCode(DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); + Argument.AssertNotNull(options, nameof(options)); - DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options = new DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions(ifMatch); - options.CertificateCommonName = certificateCommonName; - options.CertificateRawBytes = certificateRawBytes; - options.CertificateIsVerified = certificateIsVerified; - options.CertificatePurpose = certificatePurpose; - options.CertificateCreatedOn = certificateCreatedOn; - options.CertificateLastUpdatedOn = certificateLastUpdatedOn; - options.CertificateHasPrivateKey = certificateHasPrivateKey; - options.CertificateNonce = certificateNonce; - - return GenerateVerificationCode(options, cancellationToken); + return GenerateVerificationCode( + options.IfMatch, + options.CertificateCommonName, + BinaryData.FromBytes(options.CertificateRawBytes), + options.CertificateIsVerified, + options.CertificatePurpose, + options.CertificateCreatedOn, + options.CertificateLastUpdatedOn, + options.CertificateHasPrivateKey, + options.CertificateNonce, + cancellationToken); } /// - /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. /// /// /// Request Path @@ -186,42 +200,41 @@ public virtual Response GenerateVerificationC /// /// /// Operation Id - /// DpsCertificate_VerifyCertificate + /// CertificateResponses_VerifyCertificate + /// + /// + /// Default Api Version + /// 2025-02-01-preview + /// + /// + /// Resource + /// /// /// /// - /// ETag of the certificate. - /// The name of the certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Describe the purpose of the certificate. - /// Certificate creation time. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. - /// or is null. - public virtual async Task> VerifyCertificateAsync(string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> VerifyCertificateAsync(DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(options, nameof(options)); - DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options = new DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions(ifMatch, content); - options.CertificateCommonName = certificateCommonName; - options.CertificateRawBytes = certificateRawBytes; - options.CertificateIsVerified = certificateIsVerified; - options.CertificatePurpose = certificatePurpose; - options.CertificateCreatedOn = certificateCreatedOn; - options.CertificateLastUpdatedOn = certificateLastUpdatedOn; - options.CertificateHasPrivateKey = certificateHasPrivateKey; - options.CertificateNonce = certificateNonce; - - return await VerifyCertificateAsync(options, cancellationToken).ConfigureAwait(false); + return await VerifyCertificateAsync( + options.IfMatch, + options.Content, + options.CertificateCommonName, + BinaryData.FromBytes(options.CertificateRawBytes), + options.CertificateIsVerified, + options.CertificatePurpose, + options.CertificateCreatedOn, + options.CertificateLastUpdatedOn, + options.CertificateHasPrivateKey, + options.CertificateNonce, + cancellationToken).ConfigureAwait(false); } /// - /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. /// /// /// Request Path @@ -229,38 +242,37 @@ public virtual async Task /// /// Operation Id - /// DpsCertificate_VerifyCertificate + /// CertificateResponses_VerifyCertificate + /// + /// + /// Default Api Version + /// 2025-02-01-preview + /// + /// + /// Resource + /// /// /// /// - /// ETag of the certificate. - /// The name of the certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Describe the purpose of the certificate. - /// Certificate creation time. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. - /// or is null. - public virtual Response VerifyCertificate(string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) + /// is null. + public virtual Response VerifyCertificate(DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - Argument.AssertNotNull(content, nameof(content)); - - DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options = new DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions(ifMatch, content); - options.CertificateCommonName = certificateCommonName; - options.CertificateRawBytes = certificateRawBytes; - options.CertificateIsVerified = certificateIsVerified; - options.CertificatePurpose = certificatePurpose; - options.CertificateCreatedOn = certificateCreatedOn; - options.CertificateLastUpdatedOn = certificateLastUpdatedOn; - options.CertificateHasPrivateKey = certificateHasPrivateKey; - options.CertificateNonce = certificateNonce; + Argument.AssertNotNull(options, nameof(options)); - return VerifyCertificate(options, cancellationToken); + return VerifyCertificate( + options.IfMatch, + options.Content, + options.CertificateCommonName, + BinaryData.FromBytes(options.CertificateRawBytes), + options.CertificateIsVerified, + options.CertificatePurpose, + options.CertificateCreatedOn, + options.CertificateLastUpdatedOn, + options.CertificateHasPrivateKey, + options.CertificateNonce, + cancellationToken); } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateResourceDeleteOptions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/Models/DeviceProvisioningServicesCertificateResourceDeleteOptions.cs similarity index 100% rename from sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateResourceDeleteOptions.cs rename to sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/Models/DeviceProvisioningServicesCertificateResourceDeleteOptions.cs diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/Models/DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions.cs similarity index 100% rename from sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions.cs rename to sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/Models/DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions.cs diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/Models/DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions.cs similarity index 100% rename from sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions.cs rename to sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Custom/Models/DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions.cs diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ArmDeviceProvisioningServicesModelFactory.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ArmDeviceProvisioningServicesModelFactory.cs index 71dc8b125a44..996ec9446f70 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ArmDeviceProvisioningServicesModelFactory.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ArmDeviceProvisioningServicesModelFactory.cs @@ -7,37 +7,37 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; +using Azure; using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmDeviceProvisioningServicesModelFactory { - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. /// properties of a certificate. /// The entity tag. /// A new instance for mocking. - public static DeviceProvisioningServicesCertificateData DeviceProvisioningServicesCertificateData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DeviceProvisioningServicesCertificateProperties properties = null, ETag? etag = null) + public static DeviceProvisioningServicesCertificateData DeviceProvisioningServicesCertificateData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DeviceProvisioningServicesCertificateProperties properties = default, ETag? etag = default) { return new DeviceProvisioningServicesCertificateData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, properties, - etag, - serializedAdditionalRawData: null); + etag); } - /// Initializes a new instance of . + /// The description of an X509 CA Certificate. /// The certificate's subject name. /// The certificate's expiration date and time. /// The certificate's thumbprint. @@ -46,7 +46,7 @@ public static DeviceProvisioningServicesCertificateData DeviceProvisioningServic /// The certificate's creation date and time. /// The certificate's last update date and time. /// A new instance for mocking. - public static DeviceProvisioningServicesCertificateProperties DeviceProvisioningServicesCertificateProperties(string subject = null, DateTimeOffset? expireOn = null, BinaryData thumbprint = null, bool? isVerified = null, BinaryData certificate = null, DateTimeOffset? createdOn = null, DateTimeOffset? updatedOn = null) + public static DeviceProvisioningServicesCertificateProperties DeviceProvisioningServicesCertificateProperties(string subject = default, DateTimeOffset? expireOn = default, BinaryData thumbprint = default, bool? isVerified = default, BinaryData certificate = default, DateTimeOffset? createdOn = default, DateTimeOffset? updatedOn = default) { return new DeviceProvisioningServicesCertificateProperties( subject, @@ -56,30 +56,37 @@ public static DeviceProvisioningServicesCertificateProperties DeviceProvisioning certificate, createdOn, updatedOn, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); + } + + /// The JSON-serialized array of Certificate objects. + /// The array of Certificate objects. + /// A new instance for mocking. + public static CertificateListDescription CertificateListDescription(IEnumerable value = default) + { + value ??= new ChangeTrackingList(); + + return new CertificateListDescription(value.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Name of certificate. /// Request etag. + /// The resource identifier. + /// The resource type. /// /// A new instance for mocking. - public static CertificateVerificationCodeResult CertificateVerificationCodeResult(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, CertificateVerificationCodeProperties properties = null) + public static CertificateVerificationCodeResult CertificateVerificationCodeResult(string name = default, ETag? etag = default, string id = default, string @type = default, CertificateVerificationCodeProperties properties = default) { return new CertificateVerificationCodeResult( - id, name, - resourceType, - systemData, etag, + id, + @type, properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The CertificateVerificationCodeProperties. /// Verification code. /// Certificate subject. /// Code expiry. @@ -89,7 +96,7 @@ public static CertificateVerificationCodeResult CertificateVerificationCodeResul /// Certificate created time. /// Certificate updated time. /// A new instance for mocking. - public static CertificateVerificationCodeProperties CertificateVerificationCodeProperties(string verificationCode = null, string subject = null, DateTimeOffset? expireOn = null, BinaryData thumbprint = null, bool? isVerified = null, BinaryData certificate = null, DateTimeOffset? createdOn = null, DateTimeOffset? updatedOn = null) + public static CertificateVerificationCodeProperties CertificateVerificationCodeProperties(string verificationCode = default, string subject = default, DateTimeOffset? expireOn = default, BinaryData thumbprint = default, bool? isVerified = default, BinaryData certificate = default, DateTimeOffset? createdOn = default, DateTimeOffset? updatedOn = default) { return new CertificateVerificationCodeProperties( verificationCode, @@ -100,16 +107,15 @@ public static CertificateVerificationCodeProperties CertificateVerificationCodeP certificate, createdOn, updatedOn, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. /// The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. /// The resource group of the resource. /// The subscription id of the resource. @@ -117,15 +123,16 @@ public static CertificateVerificationCodeProperties CertificateVerificationCodeP /// Sku info for a provisioning Service. /// The managed service identities assigned to this resource. /// A new instance for mocking. - public static DeviceProvisioningServiceData DeviceProvisioningServiceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ETag? etag = null, string resourceGroup = null, string subscriptionId = null, DeviceProvisioningServiceProperties properties = null, DeviceProvisioningServicesSkuInfo sku = null, ManagedServiceIdentity identity = null) + public static DeviceProvisioningServiceData DeviceProvisioningServiceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ETag? etag = default, string resourceGroup = default, string subscriptionId = default, DeviceProvisioningServiceProperties properties = default, DeviceProvisioningServicesSkuInfo sku = default, ManagedServiceIdentity identity = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new DeviceProvisioningServiceData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, etag, @@ -133,11 +140,10 @@ public static DeviceProvisioningServiceData DeviceProvisioningServiceData(Resour subscriptionId, properties, sku, - identity, - serializedAdditionalRawData: null); + identity); } - /// Initializes a new instance of . + /// the service specific properties of a provisioning service, including keys, linked iot hubs, current state, and system generated properties such as hostname and idScope. /// Current state of the provisioning service. /// Whether requests from Public Network are allowed. /// The IP filter rules. @@ -156,57 +162,57 @@ public static DeviceProvisioningServiceData DeviceProvisioningServiceData(Resour /// /// Portal endpoint to enable CORS for this provisioning service. /// A new instance for mocking. - public static DeviceProvisioningServiceProperties DeviceProvisioningServiceProperties(DeviceProvisioningServicesState? state = null, DeviceProvisioningServicesPublicNetworkAccess? publicNetworkAccess = null, IEnumerable ipFilterRules = null, IEnumerable privateEndpointConnections = null, string provisioningState = null, IEnumerable iotHubs = null, DeviceRegistryNamespaceDescription deviceRegistryNamespace = null, DeviceProvisioningServicesAllocationPolicy? allocationPolicy = null, string serviceOperationsHostName = null, string deviceProvisioningHostName = null, string idScope = null, IEnumerable authorizationPolicies = null, bool? isDataResidencyEnabled = null, string portalOperationsHostName = null) + public static DeviceProvisioningServiceProperties DeviceProvisioningServiceProperties(DeviceProvisioningServicesState? state = default, DeviceProvisioningServicesPublicNetworkAccess? publicNetworkAccess = default, IEnumerable ipFilterRules = default, IEnumerable privateEndpointConnections = default, string provisioningState = default, IEnumerable iotHubs = default, DeviceRegistryNamespaceDescription deviceRegistryNamespace = default, DeviceProvisioningServicesAllocationPolicy? allocationPolicy = default, string serviceOperationsHostName = default, string deviceProvisioningHostName = default, string idScope = default, IEnumerable authorizationPolicies = default, bool? isDataResidencyEnabled = default, string portalOperationsHostName = default) { - ipFilterRules ??= new List(); - privateEndpointConnections ??= new List(); - iotHubs ??= new List(); - authorizationPolicies ??= new List(); + ipFilterRules ??= new ChangeTrackingList(); + privateEndpointConnections ??= new ChangeTrackingList(); + iotHubs ??= new ChangeTrackingList(); + authorizationPolicies ??= new ChangeTrackingList(); return new DeviceProvisioningServiceProperties( state, publicNetworkAccess, - ipFilterRules?.ToList(), - privateEndpointConnections?.ToList(), + ipFilterRules.ToList(), + privateEndpointConnections.ToList(), provisioningState, - iotHubs?.ToList(), + iotHubs.ToList(), deviceRegistryNamespace, allocationPolicy, serviceOperationsHostName, deviceProvisioningHostName, idScope, - authorizationPolicies?.ToList(), + authorizationPolicies.ToList(), isDataResidencyEnabled, portalOperationsHostName, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// The private endpoint connection of a provisioning service. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. /// The properties of a private endpoint connection. /// A new instance for mocking. - public static DeviceProvisioningServicesPrivateEndpointConnectionData DeviceProvisioningServicesPrivateEndpointConnectionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DeviceProvisioningServicesPrivateEndpointConnectionProperties properties = null) + public static DeviceProvisioningServicesPrivateEndpointConnectionData DeviceProvisioningServicesPrivateEndpointConnectionData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DeviceProvisioningServicesPrivateEndpointConnectionProperties properties = default) { return new DeviceProvisioningServicesPrivateEndpointConnectionData( id, name, resourceType, systemData, - properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + properties); } - /// Initializes a new instance of . + /// Description of the IoT hub. /// flag for applying allocationPolicy or not for a given iot hub. /// weight to apply for a given iot h. /// Host name of the IoT hub. /// Connection string of the IoT hub. /// ARM region of the IoT hub. /// A new instance for mocking. - public static IotHubDefinitionDescription IotHubDefinitionDescription(bool? applyAllocationPolicy = null, int? allocationWeight = null, string name = null, string connectionString = null, AzureLocation location = default) + public static IotHubDefinitionDescription IotHubDefinitionDescription(bool? applyAllocationPolicy = default, int? allocationWeight = default, string name = default, string connectionString = default, AzureLocation location = default) { return new IotHubDefinitionDescription( applyAllocationPolicy, @@ -214,106 +220,94 @@ public static IotHubDefinitionDescription IotHubDefinitionDescription(bool? appl name, connectionString, location, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// List of possible provisioning service SKUs. /// Sku name. /// Pricing tier name of the provisioning service. /// The number of units to provision. /// A new instance for mocking. - public static DeviceProvisioningServicesSkuInfo DeviceProvisioningServicesSkuInfo(DeviceProvisioningServicesSku? name = null, string tier = null, long? capacity = null) + public static DeviceProvisioningServicesSkuInfo DeviceProvisioningServicesSkuInfo(DeviceProvisioningServicesSku? name = default, string tier = default, long? capacity = default) { - return new DeviceProvisioningServicesSkuInfo(name, tier, capacity, serializedAdditionalRawData: null); + return new DeviceProvisioningServicesSkuInfo(name, tier, capacity, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// A container holding only the Tags for a resource, allowing the user to update the tags on a Provisioning Service instance. + /// Resource tags. + /// A new instance for mocking. + public static DeviceProvisioningServicePatch DeviceProvisioningServicePatch(IDictionary tags = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new DeviceProvisioningServicePatch(tags, additionalBinaryDataProperties: null); + } + + /// Available SKUs of tier and units. /// Sku name. /// A new instance for mocking. - public static DeviceProvisioningServicesSkuDefinition DeviceProvisioningServicesSkuDefinition(DeviceProvisioningServicesSku? name = null) + public static DeviceProvisioningServicesSkuDefinition DeviceProvisioningServicesSkuDefinition(DeviceProvisioningServicesSku? name = default) { - return new DeviceProvisioningServicesSkuDefinition(name, serializedAdditionalRawData: null); + return new DeviceProvisioningServicesSkuDefinition(name, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// The group information for creating a private endpoint on a provisioning service. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. /// The properties for a group information object. /// A new instance for mocking. - public static DeviceProvisioningServicesPrivateLinkResourceData DeviceProvisioningServicesPrivateLinkResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DeviceProvisioningServicesPrivateLinkResourceProperties properties = null) + public static DeviceProvisioningServicesPrivateLinkResourceData DeviceProvisioningServicesPrivateLinkResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DeviceProvisioningServicesPrivateLinkResourceProperties properties = default) { return new DeviceProvisioningServicesPrivateLinkResourceData( id, name, resourceType, systemData, - properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + properties); } - /// Initializes a new instance of . + /// The properties for a group information object. /// The group id. /// The required members for a specific group id. /// The required DNS zones for a specific group id. /// A new instance for mocking. - public static DeviceProvisioningServicesPrivateLinkResourceProperties DeviceProvisioningServicesPrivateLinkResourceProperties(string groupId = null, IEnumerable requiredMembers = null, IEnumerable requiredZoneNames = null) + public static DeviceProvisioningServicesPrivateLinkResourceProperties DeviceProvisioningServicesPrivateLinkResourceProperties(string groupId = default, IEnumerable requiredMembers = default, IEnumerable requiredZoneNames = default) { - requiredMembers ??= new List(); - requiredZoneNames ??= new List(); + requiredMembers ??= new ChangeTrackingList(); + requiredZoneNames ??= new ChangeTrackingList(); - return new DeviceProvisioningServicesPrivateLinkResourceProperties(groupId, requiredMembers?.ToList(), requiredZoneNames?.ToList(), serializedAdditionalRawData: null); + return new DeviceProvisioningServicesPrivateLinkResourceProperties(groupId, requiredMembers.ToList(), requiredZoneNames.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// specifies if a name is available or not. - /// specifies the reason a name is unavailable. - /// message containing a detailed reason name is unavailable. - /// A new instance for mocking. - public static DeviceProvisioningServicesNameAvailabilityResult DeviceProvisioningServicesNameAvailabilityResult(bool? isNameAvailable = null, DeviceProvisioningServicesNameUnavailableReason? reason = null, string message = null) + /// The available private link resources for a provisioning service. + /// The list of available private link resources for a provisioning service. + /// A new instance for mocking. + public static PrivateLinkResources PrivateLinkResources(IEnumerable value = default) { - return new DeviceProvisioningServicesNameAvailabilityResult(isNameAvailable, reason, message, serializedAdditionalRawData: null); + value ??= new ChangeTrackingList(); + + return new PrivateLinkResources(value.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. - /// Service specific properties for a provisioning service. - /// Sku info for a provisioning Service. - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static DeviceProvisioningServiceData DeviceProvisioningServiceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ETag? etag, DeviceProvisioningServiceProperties properties, DeviceProvisioningServicesSkuInfo sku) + /// Input values for operation results call. + /// The name of the Provisioning Service to check. + /// A new instance for mocking. + public static DeviceProvisioningServicesNameAvailabilityContent DeviceProvisioningServicesNameAvailabilityContent(string name = default) { - return DeviceProvisioningServiceData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, etag: etag, resourceGroup: default, subscriptionId: default, properties: properties, sku: sku, identity: default); + return new DeviceProvisioningServicesNameAvailabilityContent(name, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// Current state of the provisioning service. - /// Whether requests from Public Network are allowed. - /// The IP filter rules. - /// Private endpoint connections created on this IotHub. - /// The ARM provisioning state of the provisioning service. - /// List of IoT hubs associated with this provisioning service. - /// Allocation policy to be used by this provisioning service. - /// Service endpoint for provisioning service. - /// Device endpoint for this provisioning service. - /// Unique identifier of this provisioning service. - /// List of authorization keys for a provisioning service. - /// - /// Optional. - /// Indicates if the DPS instance has Data Residency enabled, removing the cross geo-pair disaster recovery. - /// - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static DeviceProvisioningServiceProperties DeviceProvisioningServiceProperties(DeviceProvisioningServicesState? state, DeviceProvisioningServicesPublicNetworkAccess? publicNetworkAccess, IEnumerable ipFilterRules, IEnumerable privateEndpointConnections, string provisioningState, IEnumerable iotHubs, DeviceProvisioningServicesAllocationPolicy? allocationPolicy, string serviceOperationsHostName, string deviceProvisioningHostName, string idScope, IEnumerable authorizationPolicies, bool? isDataResidencyEnabled) + /// Description of name availability. + /// specifies if a name is available or not. + /// specifies the reason a name is unavailable. + /// message containing a detailed reason name is unavailable. + /// A new instance for mocking. + public static DeviceProvisioningServicesNameAvailabilityResult DeviceProvisioningServicesNameAvailabilityResult(bool? isNameAvailable = default, DeviceProvisioningServicesNameUnavailableReason? reason = default, string message = default) { - return DeviceProvisioningServiceProperties(state: state, publicNetworkAccess: publicNetworkAccess, ipFilterRules: ipFilterRules, privateEndpointConnections: privateEndpointConnections, provisioningState: provisioningState, iotHubs: iotHubs, deviceRegistryNamespace: default, allocationPolicy: allocationPolicy, serviceOperationsHostName: serviceOperationsHostName, deviceProvisioningHostName: deviceProvisioningHostName, idScope: idScope, authorizationPolicies: authorizationPolicies, isDataResidencyEnabled: isDataResidencyEnabled, portalOperationsHostName: default); + return new DeviceProvisioningServicesNameAvailabilityResult(isNameAvailable, reason, message, additionalBinaryDataProperties: null); } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..3216ce9278e8 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT.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; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + ProvisioningServiceDescriptionListResult result = ProvisioningServiceDescriptionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..8b19bf33ba77 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + ProvisioningServiceDescriptionListResult result = ProvisioningServiceDescriptionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..45442b2cffa8 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + ProvisioningServiceDescriptionListResult result = ProvisioningServiceDescriptionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesSubscriptionResource.GetDeviceProvisioningServices"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..9e904cf65934 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT.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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + ProvisioningServiceDescriptionListResult result = ProvisioningServiceDescriptionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesSubscriptionResource.GetDeviceProvisioningServices"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..3c8838552557 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT : AsyncPageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _provisioningServiceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the provisioning service to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _provisioningServiceName = provisioningServiceName; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + SharedAccessSignatureAuthorizationRuleListResult result = SharedAccessSignatureAuthorizationRuleListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetKeysRequest(nextLink, _subscriptionId, _resourceGroupName, _provisioningServiceName, _context) : _client.CreateGetKeysRequest(_subscriptionId, _resourceGroupName, _provisioningServiceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetKeys"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetKeysCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetKeysCollectionResultOfT.cs new file mode 100644 index 000000000000..2e382c67c97c --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetKeysCollectionResultOfT.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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetKeysCollectionResultOfT : Pageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _provisioningServiceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetKeysCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the provisioning service to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetKeysCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _provisioningServiceName = provisioningServiceName; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetKeysCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetKeysCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + SharedAccessSignatureAuthorizationRuleListResult result = SharedAccessSignatureAuthorizationRuleListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetKeysRequest(nextLink, _subscriptionId, _resourceGroupName, _provisioningServiceName, _context) : _client.CreateGetKeysRequest(_subscriptionId, _resourceGroupName, _provisioningServiceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetKeys"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..26dd0f2e17fe --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT : AsyncPageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _provisioningServiceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the provisioning service to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _provisioningServiceName = provisioningServiceName; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + IotDpsSkuDefinitionListResult result = IotDpsSkuDefinitionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetValidSkusRequest(nextLink, _subscriptionId, _resourceGroupName, _provisioningServiceName, _context) : _client.CreateGetValidSkusRequest(_subscriptionId, _resourceGroupName, _provisioningServiceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetValidSkus"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT.cs new file mode 100644 index 000000000000..ba0c64024cfd --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/CollectionResults/ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT.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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DeviceProvisioningServices.Models; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT : Pageable + { + private readonly ProvisioningServiceDescriptions _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _provisioningServiceName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ProvisioningServiceDescriptions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of the provisioning service to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT(ProvisioningServiceDescriptions client, string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _provisioningServiceName = provisioningServiceName; + _context = context; + } + + /// Gets the pages of ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + IotDpsSkuDefinitionListResult result = IotDpsSkuDefinitionListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetValidSkusRequest(nextLink, _subscriptionId, _resourceGroupName, _provisioningServiceName, _context) : _client.CreateGetValidSkusRequest(_subscriptionId, _resourceGroupName, _provisioningServiceName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetValidSkus"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceCollection.cs index 52bf6361c553..3f49d5463b16 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DeviceProvisioningServices @@ -25,51 +26,49 @@ namespace Azure.ResourceManager.DeviceProvisioningServices /// public partial class DeviceProvisioningServiceCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics; - private readonly ProvisioningServiceDescriptionsRestOperations _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient; + private readonly ClientDiagnostics _provisioningServiceDescriptionsClientDiagnostics; + private readonly ProvisioningServiceDescriptions _provisioningServiceDescriptionsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServiceCollection for mocking. protected DeviceProvisioningServiceCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServiceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServiceResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DeviceProvisioningServiceResource.ResourceType, out string deviceProvisioningServiceProvisioningServiceDescriptionsApiVersion); - _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient = new ProvisioningServiceDescriptionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServiceProvisioningServiceDescriptionsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DeviceProvisioningServiceResource.ResourceType, out string deviceProvisioningServiceApiVersion); + _provisioningServiceDescriptionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServiceResource.ResourceType.Namespace, Diagnostics); + _provisioningServiceDescriptionsRestClient = new ProvisioningServiceDescriptions(_provisioningServiceDescriptionsClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServiceApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] 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)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } } /// /// Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values in a new body to update the provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// ProvisioningServiceDescriptions_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -77,21 +76,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// Name of the provisioning service to retrieve. /// Description of the provisioning service to create or update. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string provisioningServiceName, DeviceProvisioningServiceData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.CreateOrUpdate"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, data, cancellationToken).ConfigureAwait(false); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServiceOperationSource(Client), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, DeviceProvisioningServiceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServiceOperationSource(Client), + _provisioningServiceDescriptionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -105,20 +117,16 @@ public virtual async Task> Creat /// Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values in a new body to update the provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_CreateOrUpdate + /// Operation Id. + /// ProvisioningServiceDescriptions_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -126,21 +134,34 @@ public virtual async Task> Creat /// Name of the provisioning service to retrieve. /// Description of the provisioning service to create or update. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string provisioningServiceName, DeviceProvisioningServiceData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.CreateOrUpdate"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.CreateOrUpdate"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, data, cancellationToken); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServiceOperationSource(Client), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, DeviceProvisioningServiceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServiceOperationSource(Client), + _provisioningServiceDescriptionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -154,38 +175,42 @@ public virtual ArmOperation CreateOrUpdate(Wa /// Get the metadata of the provisioning service without SAS keys. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetAsync(string provisioningServiceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Get"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Get"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -199,38 +224,42 @@ public virtual async Task> GetAsync( /// Get the metadata of the provisioning service without SAS keys. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Get(string provisioningServiceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Get"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Get"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -244,50 +273,44 @@ public virtual Response Get(string provisioni /// Get a list of all provisioning services in the given resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices. /// /// - /// Operation Id - /// ProvisioningServiceDescription_ListByResourceGroup + /// Operation Id. + /// ProvisioningServiceDescriptions_ListByResourceGroup. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeviceProvisioningServiceResource(Client, DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(e)), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "DeviceProvisioningServiceCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ProvisioningServiceDescriptionsGetByResourceGroupAsyncCollectionResultOfT(_provisioningServiceDescriptionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new DeviceProvisioningServiceResource(Client, data)); } /// /// Get a list of all provisioning services in the given resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_ListByResourceGroup + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// ProvisioningServiceDescriptions_ListByResourceGroup. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -295,45 +318,61 @@ public virtual AsyncPageable GetAllAsync(Canc /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeviceProvisioningServiceResource(Client, DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(e)), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "DeviceProvisioningServiceCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ProvisioningServiceDescriptionsGetByResourceGroupCollectionResultOfT(_provisioningServiceDescriptionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new DeviceProvisioningServiceResource(Client, data)); } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> ExistsAsync(string provisioningServiceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Exists"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Exists"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServiceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -347,36 +386,50 @@ public virtual async Task> ExistsAsync(string provisioningService /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Exists(string provisioningServiceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Exists"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.Exists"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServiceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -390,38 +443,54 @@ public virtual Response Exists(string provisioningServiceName, Cancellatio /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetIfExistsAsync(string provisioningServiceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.GetIfExists"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.GetIfExists"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServiceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -435,38 +504,54 @@ public virtual async Task> G /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual NullableResponse GetIfExists(string provisioningServiceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.GetIfExists"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceCollection.GetIfExists"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, provisioningServiceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServiceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -486,6 +571,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.Serialization.cs index 4e98d7e4d1ba..485a76f90a6a 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - public partial class DeviceProvisioningServiceData : IUtf8JsonSerializable, IJsonModel + /// The description of the provisioning service. + public partial class DeviceProvisioningServiceData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServiceData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,12 +38,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServiceData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(ETag)) { @@ -60,153 +66,174 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireV3Options); + ((IJsonModel)Identity).Write(writer, options); } } - DeviceProvisioningServiceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServiceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DeviceProvisioningServiceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServiceData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServiceData(document.RootElement, options); } - internal static DeviceProvisioningServiceData DeserializeDeviceProvisioningServiceData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServiceData DeserializeDeviceProvisioningServiceData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ETag? etag = default; - string resourcegroup = default; - string subscriptionid = default; - DeviceProvisioningServiceProperties properties = default; - DeviceProvisioningServicesSkuInfo sku = default; - ManagedServiceIdentity identity = default; - IDictionary tags = default; - AzureLocation location = default; ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + ETag? eTag = default; + string resourceGroup = default; + string subscriptionId = default; + DeviceProvisioningServiceProperties properties = default; + DeviceProvisioningServicesSkuInfo sku = default; + ManagedServiceIdentity identity = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("etag"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - etag = new ETag(property.Value.GetString()); - continue; - } - if (property.NameEquals("resourcegroup"u8)) - { - resourcegroup = property.Value.GetString(); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("subscriptionid"u8)) + if (prop.NameEquals("name"u8)) { - subscriptionid = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("type"u8)) { - properties = DeviceProvisioningServiceProperties.DeserializeDeviceProvisioningServiceProperties(property.Value, options); - continue; - } - if (property.NameEquals("sku"u8)) - { - sku = DeviceProvisioningServicesSkuInfo.DeserializeDeviceProvisioningServicesSkuInfo(property.Value, options); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("identity"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireV3Options, AzureResourceManagerDeviceProvisioningServicesContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); continue; } - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } tags = dictionary; continue; } - if (property.NameEquals("location"u8)) + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("etag"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + eTag = new ETag(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("resourcegroup"u8)) { - location = new AzureLocation(property.Value.GetString()); + resourceGroup = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("subscriptionid"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + subscriptionId = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("properties"u8)) { - name = property.Value.GetString(); + properties = DeviceProvisioningServiceProperties.DeserializeDeviceProvisioningServiceProperties(prop.Value, options); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("sku"u8)) { - type = new ResourceType(property.Value.GetString()); + sku = DeviceProvisioningServicesSkuInfo.DeserializeDeviceProvisioningServicesSkuInfo(prop.Value, options); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("identity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new DeviceProvisioningServiceData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - etag, - resourcegroup, - subscriptionid, + eTag, + resourceGroup, + subscriptionId, properties, sku, - identity, - serializedAdditionalRawData); + identity); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -216,15 +243,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - DeviceProvisioningServiceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServiceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DeviceProvisioningServiceData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServiceData(document.RootElement, options); } default: @@ -232,6 +264,26 @@ DeviceProvisioningServiceData IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DeviceProvisioningServiceData deviceProvisioningServiceData) + { + if (deviceProvisioningServiceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(deviceProvisioningServiceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DeviceProvisioningServiceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeviceProvisioningServiceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.cs index f2cf4abbf4c5..737dbd67f6f6 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceData.cs @@ -7,52 +7,21 @@ using System; using System.Collections.Generic; +using Azure; using Azure.Core; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - /// - /// A class representing the DeviceProvisioningService data model. - /// The description of the provisioning service. - /// + /// The description of the provisioning service. public partial class DeviceProvisioningServiceData : 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - /// The location. + /// The geo-location where the resource lives. /// Service specific properties for a provisioning service. /// Sku info for a provisioning Service. /// or is null. @@ -66,45 +35,45 @@ public DeviceProvisioningServiceData(AzureLocation location, DeviceProvisioningS } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. /// The resource group of the resource. /// The subscription id of the resource. /// Service specific properties for a provisioning service. /// Sku info for a provisioning Service. /// The managed service identities assigned to this resource. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServiceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ETag? etag, string resourceGroup, string subscriptionId, DeviceProvisioningServiceProperties properties, DeviceProvisioningServicesSkuInfo sku, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal DeviceProvisioningServiceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, ETag? eTag, string resourceGroup, string subscriptionId, DeviceProvisioningServiceProperties properties, DeviceProvisioningServicesSkuInfo sku, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData, tags, location) { - ETag = etag; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + ETag = eTag; ResourceGroup = resourceGroup; SubscriptionId = subscriptionId; Properties = properties; Sku = sku; Identity = identity; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServiceData() - { } /// The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. public ETag? ETag { get; set; } + /// The resource group of the resource. public string ResourceGroup { get; set; } + /// The subscription id of the resource. public string SubscriptionId { get; set; } + /// Service specific properties for a provisioning service. public DeviceProvisioningServiceProperties Properties { get; set; } + /// Sku info for a provisioning Service. public DeviceProvisioningServicesSkuInfo Sku { get; set; } + /// The managed service identities assigned to this resource. public ManagedServiceIdentity Identity { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.Serialization.cs index de15ccda9d80..d9c7b462c1f8 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { + /// public partial class DeviceProvisioningServiceResource : IJsonModel { - private static DeviceProvisioningServiceData s_dataDeserializationInstance; - private static DeviceProvisioningServiceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DeviceProvisioningServiceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - DeviceProvisioningServiceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + DeviceProvisioningServiceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DeviceProvisioningServiceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.cs index 6be99625982a..0917413b55e1 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServiceResource.cs @@ -7,48 +7,37 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DeviceProvisioningServices { /// - /// A Class representing a DeviceProvisioningService 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 GetDeviceProvisioningServiceResource method. - /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningService method. + /// A class representing a DeviceProvisioningService 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 GetResource method. + /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServices method. /// public partial class DeviceProvisioningServiceResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The provisioningServiceName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics; - private readonly ProvisioningServiceDescriptionsRestOperations _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient; + private readonly ClientDiagnostics _provisioningServiceDescriptionsClientDiagnostics; + private readonly ProvisioningServiceDescriptions _provisioningServiceDescriptionsRestClient; private readonly DeviceProvisioningServiceData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Devices/provisioningServices"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServiceResource for mocking. protected DeviceProvisioningServiceResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal DeviceProvisioningServiceResource(ArmClient client, DeviceProvisioningServiceData data) : this(client, data.Id) @@ -57,280 +46,92 @@ internal DeviceProvisioningServiceResource(ArmClient client, DeviceProvisioningS _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServiceResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string deviceProvisioningServiceProvisioningServiceDescriptionsApiVersion); - _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient = new ProvisioningServiceDescriptionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServiceProvisioningServiceDescriptionsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string deviceProvisioningServiceApiVersion); + _provisioningServiceDescriptionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); + _provisioningServiceDescriptionsRestClient = new ProvisioningServiceDescriptions(_provisioningServiceDescriptionsClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServiceApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } /// 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 DeviceProvisioningServiceData 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 DeviceProvisioningServicesCertificateResources in the DeviceProvisioningService. - /// An object representing collection of DeviceProvisioningServicesCertificateResources and their operations over a DeviceProvisioningServicesCertificateResource. - public virtual DeviceProvisioningServicesCertificateCollection GetDeviceProvisioningServicesCertificates() - { - return GetCachedClient(client => new DeviceProvisioningServicesCertificateCollection(client, Id)); - } - - /// - /// Get the certificate from the provisioning service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetDeviceProvisioningServicesCertificateAsync(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) - { - return await GetDeviceProvisioningServicesCertificates().GetAsync(certificateName, ifMatch, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get the certificate from the provisioning service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetDeviceProvisioningServicesCertificate(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) - { - return GetDeviceProvisioningServicesCertificates().Get(certificateName, ifMatch, cancellationToken); - } - - /// Gets a collection of DeviceProvisioningServicesPrivateLinkResources in the DeviceProvisioningService. - /// An object representing collection of DeviceProvisioningServicesPrivateLinkResources and their operations over a DeviceProvisioningServicesPrivateLinkResource. - public virtual DeviceProvisioningServicesPrivateLinkResourceCollection GetDeviceProvisioningServicesPrivateLinkResources() - { - return GetCachedClient(client => new DeviceProvisioningServicesPrivateLinkResourceCollection(client, Id)); - } - - /// - /// Get the specified private link resource for the given provisioning service - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} - /// - /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the private link resource. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetDeviceProvisioningServicesPrivateLinkResourceAsync(string groupId, CancellationToken cancellationToken = default) - { - return await GetDeviceProvisioningServicesPrivateLinkResources().GetAsync(groupId, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get the specified private link resource for the given provisioning service - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} - /// - /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the private link resource. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetDeviceProvisioningServicesPrivateLinkResource(string groupId, CancellationToken cancellationToken = default) - { - return GetDeviceProvisioningServicesPrivateLinkResources().Get(groupId, cancellationToken); - } - - /// Gets a collection of DeviceProvisioningServicesPrivateEndpointConnectionResources in the DeviceProvisioningService. - /// An object representing collection of DeviceProvisioningServicesPrivateEndpointConnectionResources and their operations over a DeviceProvisioningServicesPrivateEndpointConnectionResource. - public virtual DeviceProvisioningServicesPrivateEndpointConnectionCollection GetDeviceProvisioningServicesPrivateEndpointConnections() - { - return GetCachedClient(client => new DeviceProvisioningServicesPrivateEndpointConnectionCollection(client, Id)); - } - - /// - /// Get private endpoint connection properties - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the private endpoint connection. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetDeviceProvisioningServicesPrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The provisioningServiceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string provisioningServiceName) { - return await GetDeviceProvisioningServicesPrivateEndpointConnections().GetAsync(privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"; + return new ResourceIdentifier(resourceId); } - /// - /// Get private endpoint connection properties - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the private endpoint connection. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetDeviceProvisioningServicesPrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) { - return GetDeviceProvisioningServicesPrivateEndpointConnections().Get(privateEndpointConnectionName, cancellationToken); + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get the metadata of the provisioning service without SAS keys. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Get"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Get"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -344,33 +145,41 @@ public virtual async Task> GetAsync( /// Get the metadata of the provisioning service without SAS keys. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Get"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Get"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -381,38 +190,55 @@ public virtual Response Get(CancellationToken } /// - /// Deletes the Provisioning Service. + /// Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Delete + /// Operation Id. + /// ProvisioningServiceDescriptions_Update. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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. + /// Updated tag information to set into the provisioning service instance. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DeviceProvisioningServicePatch patch, CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Update"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DeviceProvisioningServicesArmOperation(_deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, DeviceProvisioningServicePatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServiceOperationSource(Client), + _provisioningServiceDescriptionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -423,38 +249,55 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Deletes the Provisioning Service. + /// Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Delete + /// Operation Id. + /// ProvisioningServiceDescriptions_Update. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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. + /// Updated tag information to set into the provisioning service instance. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DeviceProvisioningServicePatch patch, CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Update"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new DeviceProvisioningServicesArmOperation(_deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, DeviceProvisioningServicePatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServiceOperationSource(Client), + _provisioningServiceDescriptionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); + { + operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -465,42 +308,45 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method + /// Deletes the Provisioning Service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Update + /// Operation Id. + /// ProvisioningServiceDescriptions_Delete. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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. - /// Updated tag information to set into the provisioning service instance. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, DeviceProvisioningServicePatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Update"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Delete"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServiceOperationSource(Client), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(_provisioningServiceDescriptionsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -511,42 +357,45 @@ public virtual async Task> Updat } /// - /// Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method + /// Deletes the Provisioning Service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Update + /// Operation Id. + /// ProvisioningServiceDescriptions_Delete. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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. - /// Updated tag information to set into the provisioning service instance. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, DeviceProvisioningServicePatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Update"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.Delete"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServiceOperationSource(Client), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(_provisioningServiceDescriptionsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); + { + operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -560,50 +409,52 @@ public virtual ArmOperation Update(WaitUntil /// Gets the list of valid SKUs and tiers for a provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus. /// /// - /// Operation Id - /// ProvisioningServiceDescriptions_ListValidSkus + /// Operation Id. + /// ProvisioningServiceDescriptions_ListValidSkus. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetValidSkusAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListValidSkusRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListValidSkusNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DeviceProvisioningServicesSkuDefinition.DeserializeDeviceProvisioningServicesSkuDefinition(e), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "DeviceProvisioningServiceResource.GetValidSkus", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new ProvisioningServiceDescriptionsGetValidSkusAsyncCollectionResultOfT(_provisioningServiceDescriptionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); } /// /// Gets the list of valid SKUs and tiers for a provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus. /// /// - /// Operation Id - /// ProvisioningServiceDescriptions_ListValidSkus + /// Operation Id. + /// ProvisioningServiceDescriptions_ListValidSkus. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -611,59 +462,63 @@ public virtual AsyncPageable GetValidSk /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetValidSkus(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListValidSkusRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListValidSkusNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DeviceProvisioningServicesSkuDefinition.DeserializeDeviceProvisioningServicesSkuDefinition(e), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "DeviceProvisioningServiceResource.GetValidSkus", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new ProvisioningServiceDescriptionsGetValidSkusCollectionResultOfT(_provisioningServiceDescriptionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); } /// /// List the primary and secondary keys for a provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys. /// /// - /// Operation Id - /// ProvisioningServiceDescriptions_ListKeys + /// Operation Id. + /// ProvisioningServiceDescriptions_ListKeys. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetKeysAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListKeysRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListKeysNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DeviceProvisioningServicesSharedAccessKey.DeserializeDeviceProvisioningServicesSharedAccessKey(e), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "DeviceProvisioningServiceResource.GetKeys", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new ProvisioningServiceDescriptionsGetKeysAsyncCollectionResultOfT(_provisioningServiceDescriptionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); } /// /// List the primary and secondary keys for a provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys. /// /// - /// Operation Id - /// ProvisioningServiceDescriptions_ListKeys + /// Operation Id. + /// ProvisioningServiceDescriptions_ListKeys. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -671,45 +526,57 @@ public virtual AsyncPageable GetKeysA /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetKeys(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListKeysRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListKeysNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DeviceProvisioningServicesSharedAccessKey.DeserializeDeviceProvisioningServicesSharedAccessKey(e), _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "DeviceProvisioningServiceResource.GetKeys", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new ProvisioningServiceDescriptionsGetKeysCollectionResultOfT(_provisioningServiceDescriptionsRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); } /// /// List primary and secondary keys for a specific key name /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys. /// /// - /// Operation Id - /// ProvisioningServiceDescriptions_GetKey + /// Operation Id. + /// ProvisioningServiceDescriptions_ListKeysForKeyName. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// Logical key name to get key-values for. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetKeyAsync(string keyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetKey"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetKey"); scope.Start(); try { - var response = await _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetKeyAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetKeyRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesSharedAccessKey.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -723,36 +590,46 @@ public virtual async Task> G /// List primary and secondary keys for a specific key name /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys. /// /// - /// Operation Id - /// ProvisioningServiceDescriptions_GetKey + /// Operation Id. + /// ProvisioningServiceDescriptions_ListKeysForKeyName. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// Logical key name to get key-values for. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response GetKey(string keyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetKey"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.GetKey"); scope.Start(); try { - var response = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetKey(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetKeyRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesSharedAccessKey.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -762,27 +639,7 @@ public virtual Response GetKey(string } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -792,28 +649,34 @@ public virtual async Task> AddTagAsy Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.AddTag"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.AddTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response 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 _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DeviceProvisioningServiceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DeviceProvisioningServicePatch(); - foreach (var tag in current.Tags) + DeviceProvisioningServiceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -824,27 +687,7 @@ public virtual async Task> AddTagAsy } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -854,28 +697,34 @@ public virtual Response AddTag(string key, st Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.AddTag"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.AddTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new DeviceProvisioningServiceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DeviceProvisioningServicePatch(); - foreach (var tag in current.Tags) + DeviceProvisioningServiceData current = Get(cancellationToken: cancellationToken).Value.Data; + DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -886,53 +735,39 @@ public virtual Response AddTag(string key, st } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// 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 = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.SetTags"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.SetTags"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response 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 _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DeviceProvisioningServiceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DeviceProvisioningServicePatch(); + DeviceProvisioningServiceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -943,53 +778,39 @@ public virtual async Task> SetTagsAs } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.SetTags"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.SetTags"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new DeviceProvisioningServiceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DeviceProvisioningServicePatch(); + DeviceProvisioningServiceData current = Get(cancellationToken: cancellationToken).Value.Data; + DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch(); patch.Tags.ReplaceWith(tags); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1000,27 +821,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1028,28 +829,34 @@ public virtual async Task> RemoveTag { Argument.AssertNotNull(key, nameof(key)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.RemoveTag"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.RemoveTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response 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 _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DeviceProvisioningServiceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DeviceProvisioningServicePatch(); - foreach (var tag in current.Tags) + DeviceProvisioningServiceData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1060,27 +867,7 @@ public virtual async Task> RemoveTag } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1088,28 +875,34 @@ public virtual Response RemoveTag(string key, { Argument.AssertNotNull(key, nameof(key)); - using var scope = _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.RemoveTag"); + using DiagnosticScope scope = _provisioningServiceDescriptionsClientDiagnostics.CreateScope("DeviceProvisioningServiceResource.RemoveTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new DeviceProvisioningServiceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _provisioningServiceDescriptionsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServiceData.FromResponse(result), result); + return Response.FromValue(new DeviceProvisioningServiceResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DeviceProvisioningServicePatch(); - foreach (var tag in current.Tags) + DeviceProvisioningServiceData current = Get(cancellationToken: cancellationToken).Value.Data; + DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1119,5 +912,114 @@ public virtual Response RemoveTag(string key, throw; } } + + /// Gets a collection of DeviceProvisioningServicesCertificates in the . + /// An object representing collection of DeviceProvisioningServicesCertificates and their operations over a DeviceProvisioningServicesCertificateResource. + public virtual DeviceProvisioningServicesCertificateCollection GetDeviceProvisioningServicesCertificates() + { + return GetCachedClient(client => new DeviceProvisioningServicesCertificateCollection(client, Id)); + } + + /// Get the certificate from the provisioning service. + /// Name of the certificate to retrieve. + /// ETag of the certificate. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeviceProvisioningServicesCertificateAsync(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); + + return await GetDeviceProvisioningServicesCertificates().GetAsync(certificateName, ifMatch, cancellationToken).ConfigureAwait(false); + } + + /// Get the certificate from the provisioning service. + /// Name of the certificate to retrieve. + /// ETag of the certificate. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeviceProvisioningServicesCertificate(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); + + return GetDeviceProvisioningServicesCertificates().Get(certificateName, ifMatch, cancellationToken); + } + + /// Gets a collection of DeviceProvisioningServicesPrivateEndpointConnections in the . + /// An object representing collection of DeviceProvisioningServicesPrivateEndpointConnections and their operations over a DeviceProvisioningServicesPrivateEndpointConnectionResource. + public virtual DeviceProvisioningServicesPrivateEndpointConnectionCollection GetDeviceProvisioningServicesPrivateEndpointConnections() + { + return GetCachedClient(client => new DeviceProvisioningServicesPrivateEndpointConnectionCollection(client, Id)); + } + + /// Get private endpoint connection properties. + /// Name of the provisioning service to retrieve. + /// The name of the private endpoint connection. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeviceProvisioningServicesPrivateEndpointConnectionAsync(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return await GetDeviceProvisioningServicesPrivateEndpointConnections().GetPrivateEndpointConnectionAsync(resourceName, privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// Get private endpoint connection properties. + /// Name of the provisioning service to retrieve. + /// The name of the private endpoint connection. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeviceProvisioningServicesPrivateEndpointConnection(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + return GetDeviceProvisioningServicesPrivateEndpointConnections().GetPrivateEndpointConnection(resourceName, privateEndpointConnectionName, cancellationToken); + } + + /// Gets a collection of DeviceProvisioningServicesPrivateLinkResources in the . + /// An object representing collection of DeviceProvisioningServicesPrivateLinkResources and their operations over a DeviceProvisioningServicesPrivateLinkResource. + public virtual DeviceProvisioningServicesPrivateLinkResourceCollection GetDeviceProvisioningServicesPrivateLinkResources() + { + return GetCachedClient(client => new DeviceProvisioningServicesPrivateLinkResourceCollection(client, Id)); + } + + /// Get the specified private link resource for the given provisioning service. + /// Name of the provisioning service to retrieve. + /// The name of the private link resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeviceProvisioningServicesPrivateLinkResourceAsync(string resourceName, string groupId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); + + return await GetDeviceProvisioningServicesPrivateLinkResources().GetPrivateLinkResourcesAsync(resourceName, groupId, cancellationToken).ConfigureAwait(false); + } + + /// Get the specified private link resource for the given provisioning service. + /// Name of the provisioning service to retrieve. + /// The name of the private link resource. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeviceProvisioningServicesPrivateLinkResource(string resourceName, string groupId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); + + return GetDeviceProvisioningServicesPrivateLinkResources().GetPrivateLinkResources(resourceName, groupId, cancellationToken); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateCollection.cs index 45d74fe17743..9c0c20a9ab00 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateCollection.cs @@ -8,12 +8,14 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.DeviceProvisioningServices.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { @@ -24,51 +26,49 @@ namespace Azure.ResourceManager.DeviceProvisioningServices /// public partial class DeviceProvisioningServicesCertificateCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics; - private readonly CertificateResponsesRestOperations _deviceProvisioningServicesCertificateCertificateResponsesRestClient; + private readonly ClientDiagnostics _certificateResponsesClientDiagnostics; + private readonly CertificateResponses _certificateResponsesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServicesCertificateCollection for mocking. protected DeviceProvisioningServicesCertificateCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServicesCertificateCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServicesCertificateResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DeviceProvisioningServicesCertificateResource.ResourceType, out string deviceProvisioningServicesCertificateCertificateResponsesApiVersion); - _deviceProvisioningServicesCertificateCertificateResponsesRestClient = new CertificateResponsesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServicesCertificateCertificateResponsesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DeviceProvisioningServicesCertificateResource.ResourceType, out string deviceProvisioningServicesCertificateApiVersion); + _certificateResponsesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServicesCertificateResource.ResourceType.Namespace, Diagnostics); + _certificateResponsesRestClient = new CertificateResponses(_certificateResponsesClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServicesCertificateApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DeviceProvisioningServiceResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DeviceProvisioningServiceResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, DeviceProvisioningServiceResource.ResourceType), id); + } } /// /// Add new certificate or update an existing certificate. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -77,23 +77,31 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The certificate body. /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. /// 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 certificateName, DeviceProvisioningServicesCertificateData data, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string certificateName, DeviceProvisioningServicesCertificateData data, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.CreateOrUpdate"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, data, ifMatch, cancellationToken).ConfigureAwait(false); - var uri = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, data, ifMatch); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, DeviceProvisioningServicesCertificateData.ToRequestContent(data), ifMatch, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -107,20 +115,16 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -129,23 +133,31 @@ public virtual async Task The certificate body. /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. /// 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 certificateName, DeviceProvisioningServicesCertificateData data, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string certificateName, DeviceProvisioningServicesCertificateData data, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.CreateOrUpdate"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.CreateOrUpdate"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, data, ifMatch, cancellationToken); - var uri = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, data, ifMatch); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, DeviceProvisioningServicesCertificateData.ToRequestContent(data), ifMatch, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -159,39 +171,43 @@ public virtual ArmOperation Creat /// Get the certificate from the provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the certificate to retrieve. /// ETag of the certificate. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual async Task> GetAsync(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Get"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Get"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -205,39 +221,43 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the certificate to retrieve. /// ETag of the certificate. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual Response Get(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Get"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Get"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -251,95 +271,139 @@ public virtual Response Get(strin /// Get all the certificates tied to the provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates - /// - /// - /// Operation Id - /// CertificateResponse_List + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// 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) + public virtual async Task> GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new DeviceProvisioningServicesCertificateResource(Client, DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(e)), _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics, Pipeline, "DeviceProvisioningServicesCertificateCollection.GetAll", "value", null, cancellationToken); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.GetAll"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetAllRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(CertificateListDescription.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// /// Get all the certificates tied to the provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates. /// /// - /// Operation Id - /// CertificateResponse_List + /// Operation Id. + /// CertificateResponses_List. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) + public virtual Response GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new DeviceProvisioningServicesCertificateResource(Client, DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(e)), _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics, Pipeline, "DeviceProvisioningServicesCertificateCollection.GetAll", "value", null, cancellationToken); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.GetAll"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetAllRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(CertificateListDescription.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the certificate to retrieve. /// ETag of the certificate. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual async Task> ExistsAsync(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Exists"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Exists"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesCertificateData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -353,37 +417,51 @@ public virtual async Task> ExistsAsync(string certificateName, st /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the certificate to retrieve. /// ETag of the certificate. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual Response Exists(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Exists"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.Exists"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesCertificateData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -397,39 +475,55 @@ public virtual Response Exists(string certificateName, string ifMatch = nu /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the certificate to retrieve. /// ETag of the certificate. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual async Task> GetIfExistsAsync(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.GetIfExists"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.GetIfExists"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesCertificateData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -443,39 +537,55 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} - /// - /// - /// Operation Id - /// CertificateResponse_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// Name of the certificate to retrieve. /// ETag of the certificate. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual NullableResponse GetIfExists(string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string certificateName, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.GetIfExists"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateCollection.GetIfExists"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, ifMatch, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesCertificateData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -495,6 +605,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.Serialization.cs index 00cad09cbd23..75f8b94d84cb 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - public partial class DeviceProvisioningServicesCertificateData : IUtf8JsonSerializable, IJsonModel + /// The X509 Certificate. + public partial class DeviceProvisioningServicesCertificateData : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesCertificateData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -50,98 +51,112 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DeviceProvisioningServicesCertificateData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesCertificateData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DeviceProvisioningServicesCertificateData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesCertificateData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesCertificateData(document.RootElement, options); } - internal static DeviceProvisioningServicesCertificateData DeserializeDeviceProvisioningServicesCertificateData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesCertificateData DeserializeDeviceProvisioningServicesCertificateData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DeviceProvisioningServicesCertificateProperties properties = default; - ETag? etag = default; ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DeviceProvisioningServicesCertificateProperties properties = default; + ETag? eTag = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = DeviceProvisioningServicesCertificateProperties.DeserializeDeviceProvisioningServicesCertificateProperties(property.Value, options); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("etag"u8)) + if (prop.NameEquals("name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - etag = new ETag(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("systemData"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("properties"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = DeviceProvisioningServicesCertificateProperties.DeserializeDeviceProvisioningServicesCertificateProperties(prop.Value, options); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("etag"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); + eTag = new ETag(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new DeviceProvisioningServicesCertificateData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, properties, - etag, - serializedAdditionalRawData); + eTag); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -151,15 +166,20 @@ BinaryData IPersistableModel.Write(Mo } } - DeviceProvisioningServicesCertificateData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesCertificateData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DeviceProvisioningServicesCertificateData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesCertificateData(document.RootElement, options); } default: @@ -167,6 +187,26 @@ DeviceProvisioningServicesCertificateData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DeviceProvisioningServicesCertificateData deviceProvisioningServicesCertificateData) + { + if (deviceProvisioningServicesCertificateData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(deviceProvisioningServicesCertificateData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DeviceProvisioningServicesCertificateData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeviceProvisioningServicesCertificateData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.cs index c8f38e0656c0..c617739c5d8e 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateData.cs @@ -7,49 +7,18 @@ using System; using System.Collections.Generic; +using Azure; using Azure.Core; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - /// - /// A class representing the DeviceProvisioningServicesCertificate data model. - /// The X509 Certificate. - /// + /// The X509 Certificate. public partial class DeviceProvisioningServicesCertificateData : 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DeviceProvisioningServicesCertificateData() @@ -57,22 +26,23 @@ public DeviceProvisioningServicesCertificateData() } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. /// properties of a certificate. - /// The entity tag. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesCertificateData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DeviceProvisioningServicesCertificateProperties properties, ETag? etag, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// The entity tag. + internal DeviceProvisioningServicesCertificateData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DeviceProvisioningServicesCertificateProperties properties, ETag? eTag) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - ETag = etag; - _serializedAdditionalRawData = serializedAdditionalRawData; + ETag = eTag; } /// properties of a certificate. public DeviceProvisioningServicesCertificateProperties Properties { get; set; } + /// The entity tag. public ETag? ETag { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.Serialization.cs index 6e9dfa4e8d4e..49dcc7422f01 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.Serialization.cs @@ -8,22 +8,33 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { - public partial class DeviceProvisioningServicesCertificateResource : IJsonModel + /// + public partial class DeviceProvisioningServicesCertificateResource : ArmResource, IJsonModel { - private static DeviceProvisioningServicesCertificateData s_dataDeserializationInstance; - private static DeviceProvisioningServicesCertificateData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DeviceProvisioningServicesCertificateData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - DeviceProvisioningServicesCertificateData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + DeviceProvisioningServicesCertificateData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DeviceProvisioningServicesCertificateData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.cs index 352649782145..5a1a7b2c3d35 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesCertificateResource.cs @@ -6,47 +6,36 @@ #nullable disable using System; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.DeviceProvisioningServices.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { /// - /// A Class representing a DeviceProvisioningServicesCertificate 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 GetDeviceProvisioningServicesCertificateResource method. - /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServicesCertificate method. + /// A class representing a DeviceProvisioningServicesCertificate 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 GetResource method. + /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServicesCertificates method. /// public partial class DeviceProvisioningServicesCertificateResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The provisioningServiceName. - /// The certificateName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics; - private readonly CertificateResponsesRestOperations _deviceProvisioningServicesCertificateCertificateResponsesRestClient; + private readonly ClientDiagnostics _certificateResponsesClientDiagnostics; + private readonly CertificateResponses _certificateResponsesRestClient; private readonly DeviceProvisioningServicesCertificateData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Devices/provisioningServices/certificates"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServicesCertificateResource for mocking. protected DeviceProvisioningServicesCertificateResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal DeviceProvisioningServicesCertificateResource(ArmClient client, DeviceProvisioningServicesCertificateData data) : this(client, data.Id) @@ -55,72 +44,94 @@ internal DeviceProvisioningServicesCertificateResource(ArmClient client, DeviceP _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServicesCertificateResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string deviceProvisioningServicesCertificateCertificateResponsesApiVersion); - _deviceProvisioningServicesCertificateCertificateResponsesRestClient = new CertificateResponsesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServicesCertificateCertificateResponsesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string deviceProvisioningServicesCertificateApiVersion); + _certificateResponsesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); + _certificateResponsesRestClient = new CertificateResponses(_certificateResponsesClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServicesCertificateApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } /// 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 DeviceProvisioningServicesCertificateData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The provisioningServiceName. + /// The certificateName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] 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)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get the certificate from the provisioning service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Operation Id - /// CertificateResponse_Get + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// ETag of the certificate. /// The cancellation token to use. - public virtual async Task> GetAsync(string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> GetAsync(ETag? ifMatch = default, CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Get"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Get"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,34 +145,42 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Operation Id - /// CertificateResponse_Get + /// Operation Id. + /// CertificateResponses_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// ETag of the certificate. /// The cancellation token to use. - public virtual Response Get(string ifMatch = null, CancellationToken cancellationToken = default) + public virtual Response Get(ETag? ifMatch = default, CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Get"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Get"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -175,41 +194,57 @@ public virtual Response Get(strin /// Deletes the specified certificate associated with the Provisioning Service /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Operation Id - /// CertificateResponse_Delete + /// Operation Id. + /// CertificateResponses_Delete. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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. - /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// ETag of the certificate. + /// This is optional, and it is the Common Name of the certificate. + /// Raw data within the certificate. + /// Indicates if certificate has been verified by owner of the private key. + /// A description that mentions the purpose of the certificate. + /// Time the certificate is created. + /// Certificate last updated time. + /// Indicates if the certificate contains a private key. + /// Random number generated to indicate Proof of Possession. /// The cancellation token to use. - /// is null. - public virtual async Task DeleteAsync(WaitUntil waitUntil, DeviceProvisioningServicesCertificateResourceDeleteOptions options, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task DeleteAsync(WaitUntil waitUntil, string ifMatch, string certificateCommonName = default, BinaryData certificateRawBytes = default, bool? certificateIsVerified = default, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = default, DateTimeOffset? certificateCreatedOn = default, DateTimeOffset? certificateLastUpdatedOn = default, bool? certificateHasPrivateKey = default, string certificateNonce = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); + Argument.AssertNotNullOrEmpty(ifMatch, nameof(ifMatch)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Delete"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Delete"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce, cancellationToken).ConfigureAwait(false); - var uri = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DeviceProvisioningServicesArmOperation(response, rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose.ToString(), certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(response, rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -223,41 +258,57 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, DeviceP /// Deletes the specified certificate associated with the Provisioning Service /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Operation Id - /// CertificateResponse_Delete + /// Operation Id. + /// CertificateResponses_Delete. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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. - /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// ETag of the certificate. + /// This is optional, and it is the Common Name of the certificate. + /// Raw data within the certificate. + /// Indicates if certificate has been verified by owner of the private key. + /// A description that mentions the purpose of the certificate. + /// Time the certificate is created. + /// Certificate last updated time. + /// Indicates if the certificate contains a private key. + /// Random number generated to indicate Proof of Possession. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Delete(WaitUntil waitUntil, DeviceProvisioningServicesCertificateResourceDeleteOptions options, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation Delete(WaitUntil waitUntil, string ifMatch, string certificateCommonName = default, BinaryData certificateRawBytes = default, bool? certificateIsVerified = default, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = default, DateTimeOffset? certificateCreatedOn = default, DateTimeOffset? certificateLastUpdatedOn = default, bool? certificateHasPrivateKey = default, string certificateNonce = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); + Argument.AssertNotNullOrEmpty(ifMatch, nameof(ifMatch)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Delete"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Delete"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce, cancellationToken); - var uri = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DeviceProvisioningServicesArmOperation(response, rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose.ToString(), certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(response, rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -268,46 +319,58 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, DeviceProvisioningServic } /// - /// Add new certificate or update an existing certificate. + /// Generate verification code for Proof of Possession. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode. /// /// - /// Operation Id - /// CertificateResponse_CreateOrUpdate + /// Operation Id. + /// CertificateResponses_GenerateVerificationCode. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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 certificate body. /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. + /// Common Name for the certificate. + /// Raw data of certificate. + /// Indicates if the certificate has been verified by owner of the private key. + /// Description mentioning the purpose of the certificate. + /// Time the certificate is created. + /// Certificate last updated time. + /// Indicates if the certificate contains private key. + /// Random number generated to indicate Proof of Possession. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, DeviceProvisioningServicesCertificateData data, string ifMatch = null, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GenerateVerificationCodeAsync(string ifMatch, string certificateCommonName = default, BinaryData certificateRawBytes = default, bool? certificateIsVerified = default, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = default, DateTimeOffset? certificateCreatedOn = default, DateTimeOffset? certificateLastUpdatedOn = default, bool? certificateHasPrivateKey = default, string certificateNonce = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNullOrEmpty(ifMatch, nameof(ifMatch)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Update"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.GenerateVerificationCode"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, ifMatch, cancellationToken).ConfigureAwait(false); - var uri = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, ifMatch); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGenerateVerificationCodeRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose.ToString(), certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(CertificateVerificationCodeResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; } catch (Exception e) { @@ -317,46 +380,58 @@ public virtual async Task - /// Add new certificate or update an existing certificate. + /// Generate verification code for Proof of Possession. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode. /// /// - /// Operation Id - /// CertificateResponse_CreateOrUpdate + /// Operation Id. + /// CertificateResponses_GenerateVerificationCode. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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 certificate body. /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. + /// Common Name for the certificate. + /// Raw data of certificate. + /// Indicates if the certificate has been verified by owner of the private key. + /// Description mentioning the purpose of the certificate. + /// Time the certificate is created. + /// Certificate last updated time. + /// Indicates if the certificate contains private key. + /// Random number generated to indicate Proof of Possession. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, DeviceProvisioningServicesCertificateData data, string ifMatch = null, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GenerateVerificationCode(string ifMatch, string certificateCommonName = default, BinaryData certificateRawBytes = default, bool? certificateIsVerified = default, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = default, DateTimeOffset? certificateCreatedOn = default, DateTimeOffset? certificateLastUpdatedOn = default, bool? certificateHasPrivateKey = default, string certificateNonce = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNullOrEmpty(ifMatch, nameof(ifMatch)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Update"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.GenerateVerificationCode"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, ifMatch, cancellationToken); - var uri = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, ifMatch); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateGenerateVerificationCodeRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose.ToString(), certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(CertificateVerificationCodeResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; } catch (Exception e) { @@ -366,39 +441,60 @@ public virtual ArmOperation Updat } /// - /// Generate verification code for Proof of Possession. + /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify. /// /// - /// Operation Id - /// CertificateResponses_GenerateVerificationCode + /// Operation Id. + /// CertificateResponses_VerifyCertificate. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// ETag of the certificate. + /// The name of the certificate. + /// Common Name for the certificate. + /// Raw data of certificate. + /// Indicates if the certificate has been verified by owner of the private key. + /// Describe the purpose of the certificate. + /// Time the certificate is created. + /// Certificate last updated time. + /// Indicates if the certificate contains private key. + /// Random number generated to indicate Proof of Possession. /// The cancellation token to use. - /// is null. - public virtual async Task> GenerateVerificationCodeAsync(DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> VerifyCertificateAsync(string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName = default, BinaryData certificateRawBytes = default, bool? certificateIsVerified = default, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = default, DateTimeOffset? certificateCreatedOn = default, DateTimeOffset? certificateLastUpdatedOn = default, bool? certificateHasPrivateKey = default, string certificateNonce = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); + Argument.AssertNotNullOrEmpty(ifMatch, nameof(ifMatch)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.GenerateVerificationCode"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.VerifyCertificate"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.GenerateVerificationCodeAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce, cancellationToken).ConfigureAwait(false); - return response; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateVerifyCertificateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, CertificateVerificationCodeContent.ToRequestContent(content), certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose.ToString(), certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -408,39 +504,60 @@ public virtual async Task> GenerateV } /// - /// Generate verification code for Proof of Possession. + /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify. /// /// - /// Operation Id - /// CertificateResponses_GenerateVerificationCode + /// Operation Id. + /// CertificateResponses_VerifyCertificate. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// ETag of the certificate. + /// The name of the certificate. + /// Common Name for the certificate. + /// Raw data of certificate. + /// Indicates if the certificate has been verified by owner of the private key. + /// Describe the purpose of the certificate. + /// Time the certificate is created. + /// Certificate last updated time. + /// Indicates if the certificate contains private key. + /// Random number generated to indicate Proof of Possession. /// The cancellation token to use. - /// is null. - public virtual Response GenerateVerificationCode(DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response VerifyCertificate(string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName = default, BinaryData certificateRawBytes = default, bool? certificateIsVerified = default, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = default, DateTimeOffset? certificateCreatedOn = default, DateTimeOffset? certificateLastUpdatedOn = default, bool? certificateHasPrivateKey = default, string certificateNonce = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); + Argument.AssertNotNullOrEmpty(ifMatch, nameof(ifMatch)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.GenerateVerificationCode"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.VerifyCertificate"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.GenerateVerificationCode(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce, cancellationToken); - return response; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateVerifyCertificateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ifMatch, CertificateVerificationCodeContent.ToRequestContent(content), certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose.ToString(), certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -450,39 +567,54 @@ public virtual Response GenerateVerificationC } /// - /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + /// Update a DeviceProvisioningServicesCertificate. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Operation Id - /// CertificateResponses_VerifyCertificate + /// Operation Id. + /// CertificateResponses_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// 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 certificate body. + /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. /// The cancellation token to use. - /// is null. - public virtual async Task> VerifyCertificateAsync(DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DeviceProvisioningServicesCertificateData data, ETag? ifMatch = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); + Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.VerifyCertificate"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Update"); scope.Start(); try { - var response = await _deviceProvisioningServicesCertificateCertificateResponsesRestClient.VerifyCertificateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.Content, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, DeviceProvisioningServicesCertificateData.ToRequestContent(data), ifMatch, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -492,39 +624,54 @@ public virtual async Task - /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + /// Update a DeviceProvisioningServicesCertificate. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}. /// /// - /// Operation Id - /// CertificateResponses_VerifyCertificate + /// Operation Id. + /// CertificateResponses_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// 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 certificate body. + /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. /// The cancellation token to use. - /// is null. - public virtual Response VerifyCertificate(DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DeviceProvisioningServicesCertificateData data, ETag? ifMatch = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); + Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServicesCertificateCertificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.VerifyCertificate"); + using DiagnosticScope scope = _certificateResponsesClientDiagnostics.CreateScope("DeviceProvisioningServicesCertificateResource.Update"); scope.Start(); try { - var response = _deviceProvisioningServicesCertificateCertificateResponsesRestClient.VerifyCertificate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, options.IfMatch, options.Content, options.CertificateCommonName, options.CertificateRawBytes, options.CertificateIsVerified, options.CertificatePurpose, options.CertificateCreatedOn, options.CertificateLastUpdatedOn, options.CertificateHasPrivateKey, options.CertificateNonce, cancellationToken); - return Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _certificateResponsesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, DeviceProvisioningServicesCertificateData.ToRequestContent(data), ifMatch, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesCertificateData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation(Response.FromValue(new DeviceProvisioningServicesCertificateResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; } catch (Exception e) { diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs index b5b012af8d06..972c151cde25 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs @@ -6,14 +6,13 @@ #nullable disable using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { @@ -22,75 +21,88 @@ namespace Azure.ResourceManager.DeviceProvisioningServices /// Each in the collection will belong to the same instance of . /// To get a instance call the GetDeviceProvisioningServicesPrivateEndpointConnections method from an instance of . /// - public partial class DeviceProvisioningServicesPrivateEndpointConnectionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + public partial class DeviceProvisioningServicesPrivateEndpointConnectionCollection : ArmCollection { - private readonly ClientDiagnostics _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics; - private readonly PrivateEndpointConnectionsRestOperations _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient; + private readonly ClientDiagnostics _privateEndpointConnectionsClientDiagnostics; + private readonly PrivateEndpointConnections _privateEndpointConnectionsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServicesPrivateEndpointConnectionCollection for mocking. protected DeviceProvisioningServicesPrivateEndpointConnectionCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServicesPrivateEndpointConnectionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServicesPrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DeviceProvisioningServicesPrivateEndpointConnectionResource.ResourceType, out string deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); - _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient = new PrivateEndpointConnectionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DeviceProvisioningServicesPrivateEndpointConnectionResource.ResourceType, out string deviceProvisioningServicesPrivateEndpointConnectionApiVersion); + _privateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServicesPrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); + _privateEndpointConnectionsRestClient = new PrivateEndpointConnections(_privateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServicesPrivateEndpointConnectionApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DeviceProvisioningServiceResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DeviceProvisioningServiceResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, DeviceProvisioningServiceResource.ResourceType), id); + } } /// /// Create or update the status of a private endpoint connection with the specified name /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_CreateOrUpdatePrivateEndpointConnection + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// PrivateEndpointConnections_CreateOrUpdatePrivateEndpointConnection. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// The private endpoint connection with updated properties. /// 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, DeviceProvisioningServicesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string resourceName, string privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.CreateOrUpdate"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateOrUpdatePrivateEndpointConnectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken).ConfigureAwait(false); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), + _privateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -104,42 +116,53 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_CreateOrUpdatePrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_CreateOrUpdatePrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// The private endpoint connection with updated properties. /// 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, DeviceProvisioningServicesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string resourceName, string privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.CreateOrUpdate"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.CreateOrUpdate"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateOrUpdatePrivateEndpointConnection(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), + _privateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -153,38 +176,44 @@ public virtual ArmOperation /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// 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) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetPrivateEndpointConnectionAsync(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetPrivateEndpointConnection"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +227,44 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// 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) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetPrivateEndpointConnection(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetPrivateEndpointConnection"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnection(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -239,98 +274,56 @@ public virtual Response - /// List private endpoint connection properties - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections - /// - /// - /// Operation Id - /// PrivateEndpointConnections_ListPrivateEndpointConnections - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListPrivateEndpointConnectionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(e)), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, "DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetAll", "", null, cancellationToken); - } - - /// - /// List private endpoint connection properties - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections - /// - /// - /// Operation Id - /// PrivateEndpointConnections_ListPrivateEndpointConnections - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateListPrivateEndpointConnectionsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(e)), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, "DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetAll", "", null, cancellationToken); - } - /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// 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) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.Exists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.Exists"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -344,36 +337,52 @@ public virtual async Task> ExistsAsync(string privateEndpointConn /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// 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) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response Exists(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.Exists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.Exists"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnection(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -387,38 +396,56 @@ public virtual Response Exists(string privateEndpointConnectionName, Cance /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} - /// - /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// 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) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetIfExists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetIfExists"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -432,38 +459,56 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private endpoint connection. /// 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) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetIfExists"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionCollection.GetIfExists"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnection(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, privateEndpointConnectionName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateEndpointConnectionData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -472,20 +517,5 @@ public virtual NullableResponse 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.Serialization.cs index 73322136b65f..fa860e5b142f 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - public partial class DeviceProvisioningServicesPrivateEndpointConnectionData : IUtf8JsonSerializable, IJsonModel + /// The private endpoint connection of a provisioning service. + public partial class DeviceProvisioningServicesPrivateEndpointConnectionData : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServicesPrivateEndpointConnectionData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,94 +38,107 @@ void IJsonModel.Write(U /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpointConnectionData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - DeviceProvisioningServicesPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DeviceProvisioningServicesPrivateEndpointConnectionData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpointConnectionData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(document.RootElement, options); } - internal static DeviceProvisioningServicesPrivateEndpointConnectionData DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesPrivateEndpointConnectionData DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DeviceProvisioningServicesPrivateEndpointConnectionProperties properties = default; ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DeviceProvisioningServicesPrivateEndpointConnectionProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) - { - properties = DeviceProvisioningServicesPrivateEndpointConnectionProperties.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionProperties(property.Value, options); - continue; - } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + properties = DeviceProvisioningServicesPrivateEndpointConnectionProperties.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new DeviceProvisioningServicesPrivateEndpointConnectionData( id, name, - type, + resourceType, systemData, - properties, - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -128,15 +148,20 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DeviceProvisioningServicesPrivateEndpointConnectionData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(document.RootElement, options); } default: @@ -144,6 +169,26 @@ DeviceProvisioningServicesPrivateEndpointConnectionData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DeviceProvisioningServicesPrivateEndpointConnectionData deviceProvisioningServicesPrivateEndpointConnectionData) + { + if (deviceProvisioningServicesPrivateEndpointConnectionData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(deviceProvisioningServicesPrivateEndpointConnectionData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DeviceProvisioningServicesPrivateEndpointConnectionData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.cs index 4ff0f25c6cf4..3df03f569fd8 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionData.cs @@ -13,43 +13,11 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - /// - /// A class representing the DeviceProvisioningServicesPrivateEndpointConnection data model. - /// The private endpoint connection of a provisioning service - /// + /// The private endpoint connection of a provisioning service. public partial class DeviceProvisioningServicesPrivateEndpointConnectionData : 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The properties of a private endpoint connection. @@ -62,21 +30,16 @@ public DeviceProvisioningServicesPrivateEndpointConnectionData(DeviceProvisionin } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. /// The properties of a private endpoint connection. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DeviceProvisioningServicesPrivateEndpointConnectionProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal DeviceProvisioningServicesPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DeviceProvisioningServicesPrivateEndpointConnectionProperties properties) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServicesPrivateEndpointConnectionData() - { } /// The properties of a private endpoint connection. diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.Serialization.cs index 7d101b5472cb..5cb9cf3c1907 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { + /// public partial class DeviceProvisioningServicesPrivateEndpointConnectionResource : IJsonModel { - private static DeviceProvisioningServicesPrivateEndpointConnectionData s_dataDeserializationInstance; - private static DeviceProvisioningServicesPrivateEndpointConnectionData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DeviceProvisioningServicesPrivateEndpointConnectionData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - DeviceProvisioningServicesPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateEndpointConnectionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DeviceProvisioningServicesPrivateEndpointConnectionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.cs index 55b51be7b53d..5f1200d2e477 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateEndpointConnectionResource.cs @@ -6,46 +6,35 @@ #nullable disable using System; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { /// - /// A Class representing a DeviceProvisioningServicesPrivateEndpointConnection 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 GetDeviceProvisioningServicesPrivateEndpointConnectionResource method. - /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServicesPrivateEndpointConnection method. + /// A class representing a DeviceProvisioningServicesPrivateEndpointConnection 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 GetResource method. + /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServicesPrivateEndpointConnections method. /// public partial class DeviceProvisioningServicesPrivateEndpointConnectionResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The resourceName. - /// The privateEndpointConnectionName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics; - private readonly PrivateEndpointConnectionsRestOperations _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient; + private readonly ClientDiagnostics _privateEndpointConnectionsClientDiagnostics; + private readonly PrivateEndpointConnections _privateEndpointConnectionsRestClient; private readonly DeviceProvisioningServicesPrivateEndpointConnectionData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Devices/provisioningServices/privateEndpointConnections"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServicesPrivateEndpointConnectionResource for mocking. protected DeviceProvisioningServicesPrivateEndpointConnectionResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal DeviceProvisioningServicesPrivateEndpointConnectionResource(ArmClient client, DeviceProvisioningServicesPrivateEndpointConnectionData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal DeviceProvisioningServicesPrivateEndpointConnectionResource(ArmClient c _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServicesPrivateEndpointConnectionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); - _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient = new PrivateEndpointConnectionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string deviceProvisioningServicesPrivateEndpointConnectionApiVersion); + _privateEndpointConnectionsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); + _privateEndpointConnectionsRestClient = new PrivateEndpointConnections(_privateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServicesPrivateEndpointConnectionApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } /// 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 DeviceProvisioningServicesPrivateEndpointConnectionData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The resourceName. + /// The privateEndpointConnectionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] 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)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get private endpoint connection properties /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.Get"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_GetPrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_GetPrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.Get"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.Get"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.GetPrivateEndpointConnection(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateEndpointConnectionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -172,35 +191,48 @@ public virtual Response /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_DeletePrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_DeletePrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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) + public virtual async Task> DeletePrivateEndpointConnectionAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.Delete"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.DeletePrivateEndpointConnection"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.DeletePrivateEndpointConnectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeletePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateDeletePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), + _privateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -214,35 +246,48 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_DeletePrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_DeletePrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// 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) + public virtual ArmOperation DeletePrivateEndpointConnection(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.Delete"); + using DiagnosticScope scope = _privateEndpointConnectionsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateEndpointConnectionResource.DeletePrivateEndpointConnection"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.DeletePrivateEndpointConnection(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new DeviceProvisioningServicesArmOperation(new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateDeletePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateDeletePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), + _privateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -253,23 +298,23 @@ public virtual ArmOperation - /// Create or update the status of a private endpoint connection with the specified name + /// Update a DeviceProvisioningServicesPrivateEndpointConnection. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_CreateOrUpdatePrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_CreateOrUpdatePrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -281,14 +326,27 @@ public virtual async Task(new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, DeviceProvisioningServicesPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), + _privateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -299,23 +357,23 @@ public virtual async Task - /// Create or update the status of a private endpoint connection with the specified name + /// Update a DeviceProvisioningServicesPrivateEndpointConnection. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}. /// /// - /// Operation Id - /// PrivateEndpointConnection_CreateOrUpdatePrivateEndpointConnection + /// Operation Id. + /// PrivateEndpointConnections_CreateOrUpdatePrivateEndpointConnection. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -327,14 +385,27 @@ public virtual ArmOperation(new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsClientDiagnostics, Pipeline, _deviceProvisioningServicesPrivateEndpointConnectionPrivateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _privateEndpointConnectionsRestClient.CreateCreateOrUpdatePrivateEndpointConnectionRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, DeviceProvisioningServicesPrivateEndpointConnectionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DeviceProvisioningServicesArmOperation operation = new DeviceProvisioningServicesArmOperation( + new DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(Client), + _privateEndpointConnectionsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.Serialization.cs index 13d6c54bf440..30f17e6257e1 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { + /// public partial class DeviceProvisioningServicesPrivateLinkResource : IJsonModel { - private static DeviceProvisioningServicesPrivateLinkResourceData s_dataDeserializationInstance; - private static DeviceProvisioningServicesPrivateLinkResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DeviceProvisioningServicesPrivateLinkResourceData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - DeviceProvisioningServicesPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DeviceProvisioningServicesPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.cs index 214c8c3bb0fe..10d04f9cc576 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResource.cs @@ -6,46 +6,35 @@ #nullable disable using System; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { /// - /// A Class representing a DeviceProvisioningServicesPrivateLinkResource 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 GetDeviceProvisioningServicesPrivateLinkResource method. - /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServicesPrivateLinkResource method. + /// A class representing a DeviceProvisioningServicesPrivateLinkResource 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 GetResource method. + /// Otherwise you can get one from its parent resource using the GetDeviceProvisioningServicesPrivateLinkResources method. /// public partial class DeviceProvisioningServicesPrivateLinkResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The resourceName. - /// The groupId. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string groupId) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics; - private readonly GroupIdInformationsRestOperations _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient; + private readonly ClientDiagnostics _groupIdInformationsClientDiagnostics; + private readonly GroupIdInformations _groupIdInformationsRestClient; private readonly DeviceProvisioningServicesPrivateLinkResourceData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Devices/provisioningServices/privateLinkResources"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServicesPrivateLinkResource for mocking. protected DeviceProvisioningServicesPrivateLinkResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal DeviceProvisioningServicesPrivateLinkResource(ArmClient client, DeviceProvisioningServicesPrivateLinkResourceData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal DeviceProvisioningServicesPrivateLinkResource(ArmClient client, DeviceP _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServicesPrivateLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsApiVersion); - _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient = new GroupIdInformationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string deviceProvisioningServicesPrivateLinkResourceApiVersion); + _groupIdInformationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ResourceType.Namespace, Diagnostics); + _groupIdInformationsRestClient = new GroupIdInformations(_groupIdInformationsClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServicesPrivateLinkResourceApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } /// 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 DeviceProvisioningServicesPrivateLinkResourceData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The resourceName. + /// The groupId. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string groupId) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] 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)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get the specified private link resource for the given provisioning service /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResource.Get"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResource.Get"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Default Api Version. + /// 2025-02-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResource.Get"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResource.Get"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResources(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceCollection.cs index 2ec8998dd140..44473d0c4ebc 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceCollection.cs @@ -6,14 +6,13 @@ #nullable disable using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { @@ -22,71 +21,79 @@ namespace Azure.ResourceManager.DeviceProvisioningServices /// Each in the collection will belong to the same instance of . /// To get a instance call the GetDeviceProvisioningServicesPrivateLinkResources method from an instance of . /// - public partial class DeviceProvisioningServicesPrivateLinkResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + public partial class DeviceProvisioningServicesPrivateLinkResourceCollection : ArmCollection { - private readonly ClientDiagnostics _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics; - private readonly GroupIdInformationsRestOperations _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient; + private readonly ClientDiagnostics _groupIdInformationsClientDiagnostics; + private readonly GroupIdInformations _groupIdInformationsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DeviceProvisioningServicesPrivateLinkResourceCollection for mocking. protected DeviceProvisioningServicesPrivateLinkResourceCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal DeviceProvisioningServicesPrivateLinkResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServicesPrivateLinkResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DeviceProvisioningServicesPrivateLinkResource.ResourceType, out string deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsApiVersion); - _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient = new GroupIdInformationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DeviceProvisioningServicesPrivateLinkResource.ResourceType, out string deviceProvisioningServicesPrivateLinkResourceApiVersion); + _groupIdInformationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServicesPrivateLinkResource.ResourceType.Namespace, Diagnostics); + _groupIdInformationsRestClient = new GroupIdInformations(_groupIdInformationsClientDiagnostics, Pipeline, Endpoint, deviceProvisioningServicesPrivateLinkResourceApiVersion ?? "2025-02-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DeviceProvisioningServiceResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DeviceProvisioningServiceResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, DeviceProvisioningServiceResource.ResourceType), id); + } } /// /// Get the specified private link resource for the given provisioning service /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} - /// - /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private link resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string groupId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetPrivateLinkResourcesAsync(string resourceName, string groupId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.Get"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.GetPrivateLinkResources"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, groupId, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, groupId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -100,38 +107,44 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private link resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string groupId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetPrivateLinkResources(string resourceName, string groupId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.Get"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.GetPrivateLinkResources"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResources(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, groupId, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, groupId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -141,98 +154,56 @@ public virtual Response Get(strin } } - /// - /// List private link resources for the given provisioning service - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources - /// - /// - /// Operation Id - /// GroupIdInformation_ListPrivateLinkResources - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.CreateListPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new DeviceProvisioningServicesPrivateLinkResource(Client, DeviceProvisioningServicesPrivateLinkResourceData.DeserializeDeviceProvisioningServicesPrivateLinkResourceData(e)), _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics, Pipeline, "DeviceProvisioningServicesPrivateLinkResourceCollection.GetAll", "value", null, cancellationToken); - } - - /// - /// List private link resources for the given provisioning service - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources - /// - /// - /// Operation Id - /// GroupIdInformation_ListPrivateLinkResources - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.CreateListPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new DeviceProvisioningServicesPrivateLinkResource(Client, DeviceProvisioningServicesPrivateLinkResourceData.DeserializeDeviceProvisioningServicesPrivateLinkResourceData(e)), _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics, Pipeline, "DeviceProvisioningServicesPrivateLinkResourceCollection.GetAll", "value", null, cancellationToken); - } - /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private link resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string groupId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string resourceName, string groupId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.Exists"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.Exists"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, groupId, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, groupId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -246,36 +217,52 @@ public virtual async Task> ExistsAsync(string groupId, Cancellati /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} - /// - /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private link resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string groupId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response Exists(string resourceName, string groupId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.Exists"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.Exists"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResources(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, groupId, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, groupId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -289,38 +276,56 @@ public virtual Response Exists(string groupId, CancellationToken cancellat /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private link resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string groupId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string resourceName, string groupId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.GetIfExists"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.GetIfExists"); scope.Start(); try { - var response = await _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, groupId, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, groupId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -334,38 +339,56 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId} - /// - /// - /// Operation Id - /// GroupIdInformation_GetPrivateLinkResources + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// GroupIdInformations_GetPrivateLinkResources. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// + /// Name of the provisioning service to retrieve. /// The name of the private link resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string groupId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string resourceName, string groupId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var scope = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.GetIfExists"); + using DiagnosticScope scope = _groupIdInformationsClientDiagnostics.CreateScope("DeviceProvisioningServicesPrivateLinkResourceCollection.GetIfExists"); scope.Start(); try { - var response = _deviceProvisioningServicesPrivateLinkResourceGroupIdInformationsRestClient.GetPrivateLinkResources(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, groupId, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _groupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, groupId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DeviceProvisioningServicesPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DeviceProvisioningServicesPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DeviceProvisioningServicesPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -374,20 +397,5 @@ public virtual NullableResponse G 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.Serialization.cs index ca666cdf80ff..54c4834e6b57 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - public partial class DeviceProvisioningServicesPrivateLinkResourceData : IUtf8JsonSerializable, IJsonModel + /// The group information for creating a private endpoint on a provisioning service. + public partial class DeviceProvisioningServicesPrivateLinkResourceData : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServicesPrivateLinkResourceData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,94 +38,107 @@ void IJsonModel.Write(Utf8Jso /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateLinkResourceData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - DeviceProvisioningServicesPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DeviceProvisioningServicesPrivateLinkResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateLinkResourceData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesPrivateLinkResourceData(document.RootElement, options); } - internal static DeviceProvisioningServicesPrivateLinkResourceData DeserializeDeviceProvisioningServicesPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesPrivateLinkResourceData DeserializeDeviceProvisioningServicesPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DeviceProvisioningServicesPrivateLinkResourceProperties properties = default; ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DeviceProvisioningServicesPrivateLinkResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) { - properties = DeviceProvisioningServicesPrivateLinkResourceProperties.DeserializeDeviceProvisioningServicesPrivateLinkResourceProperties(property.Value, options); - continue; - } - if (property.NameEquals("id"u8)) - { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + properties = DeviceProvisioningServicesPrivateLinkResourceProperties.DeserializeDeviceProvisioningServicesPrivateLinkResourceProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new DeviceProvisioningServicesPrivateLinkResourceData( id, name, - type, + resourceType, systemData, - properties, - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -128,15 +148,20 @@ BinaryData IPersistableModel. } } - DeviceProvisioningServicesPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DeviceProvisioningServicesPrivateLinkResourceData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesPrivateLinkResourceData(document.RootElement, options); } default: @@ -144,6 +169,14 @@ DeviceProvisioningServicesPrivateLinkResourceData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static DeviceProvisioningServicesPrivateLinkResourceData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeviceProvisioningServicesPrivateLinkResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.cs index aca0f24560c0..8d1813d43c44 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/DeviceProvisioningServicesPrivateLinkResourceData.cs @@ -13,70 +13,30 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - /// - /// A class representing the DeviceProvisioningServicesPrivateLinkResource data model. - /// The group information for creating a private endpoint on a provisioning service - /// + /// The group information for creating a private endpoint on a provisioning service. public partial class DeviceProvisioningServicesPrivateLinkResourceData : 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The properties for a group information object. - /// is null. internal DeviceProvisioningServicesPrivateLinkResourceData(DeviceProvisioningServicesPrivateLinkResourceProperties properties) { - Argument.AssertNotNull(properties, nameof(properties)); - Properties = properties; } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. /// The properties for a group information object. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DeviceProvisioningServicesPrivateLinkResourceProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal DeviceProvisioningServicesPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DeviceProvisioningServicesPrivateLinkResourceProperties properties) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServicesPrivateLinkResourceData() - { } /// The properties for a group information object. diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/DeviceProvisioningServicesExtensions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/DeviceProvisioningServicesExtensions.cs index def4cd3ebd7d..b9df99d2ef92 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/DeviceProvisioningServicesExtensions.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/DeviceProvisioningServicesExtensions.cs @@ -6,9 +6,12 @@ #nullable disable using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.DeviceProvisioningServices.Mocking; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Resources; @@ -18,30 +21,32 @@ namespace Azure.ResourceManager.DeviceProvisioningServices /// A class to add extension methods to Azure.ResourceManager.DeviceProvisioningServices. public static partial class DeviceProvisioningServicesExtensions { + /// private static MockableDeviceProvisioningServicesArmClient GetMockableDeviceProvisioningServicesArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableDeviceProvisioningServicesArmClient(client0)); + return client.GetCachedClient(client0 => new MockableDeviceProvisioningServicesArmClient(client0, ResourceIdentifier.Root)); } - private static MockableDeviceProvisioningServicesResourceGroupResource GetMockableDeviceProvisioningServicesResourceGroupResource(ArmResource resource) + /// + private static MockableDeviceProvisioningServicesResourceGroupResource GetMockableDeviceProvisioningServicesResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableDeviceProvisioningServicesResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableDeviceProvisioningServicesResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableDeviceProvisioningServicesSubscriptionResource GetMockableDeviceProvisioningServicesSubscriptionResource(ArmResource resource) + /// + private static MockableDeviceProvisioningServicesSubscriptionResource GetMockableDeviceProvisioningServicesSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableDeviceProvisioningServicesSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableDeviceProvisioningServicesSubscriptionResource(client, subscriptionResource.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. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -53,14 +58,13 @@ public static DeviceProvisioningServicesCertificateResource GetDeviceProvisionin } /// - /// 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. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -72,53 +76,51 @@ public static DeviceProvisioningServiceResource GetDeviceProvisioningServiceReso } /// - /// 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. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. - /// Returns a object. - public static DeviceProvisioningServicesPrivateLinkResource GetDeviceProvisioningServicesPrivateLinkResource(this ArmClient client, ResourceIdentifier id) + /// Returns a object. + public static DeviceProvisioningServicesPrivateEndpointConnectionResource GetDeviceProvisioningServicesPrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableDeviceProvisioningServicesArmClient(client).GetDeviceProvisioningServicesPrivateLinkResource(id); + return GetMockableDeviceProvisioningServicesArmClient(client).GetDeviceProvisioningServicesPrivateEndpointConnectionResource(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. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. - /// Returns a object. - public static DeviceProvisioningServicesPrivateEndpointConnectionResource GetDeviceProvisioningServicesPrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) + /// Returns a object. + public static DeviceProvisioningServicesPrivateLinkResource GetDeviceProvisioningServicesPrivateLinkResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableDeviceProvisioningServicesArmClient(client).GetDeviceProvisioningServicesPrivateEndpointConnectionResource(id); + return GetMockableDeviceProvisioningServicesArmClient(client).GetDeviceProvisioningServicesPrivateLinkResource(id); } /// - /// Gets a collection of DeviceProvisioningServiceResources in the ResourceGroupResource. + /// Gets a collection of DeviceProvisioningServices in the /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// is null. - /// An object representing collection of DeviceProvisioningServiceResources and their operations over a DeviceProvisioningServiceResource. + /// An object representing collection of DeviceProvisioningServices and their operations over a DeviceProvisioningServiceResource. public static DeviceProvisioningServiceCollection GetDeviceProvisioningServices(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -128,34 +130,15 @@ public static DeviceProvisioningServiceCollection GetDeviceProvisioningServices( /// /// Get the metadata of the provisioning service without SAS keys. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] public static async Task> GetDeviceProvisioningServiceAsync(this ResourceGroupResource resourceGroupResource, string provisioningServiceName, CancellationToken cancellationToken = default) { @@ -166,34 +149,15 @@ public static async Task> GetDeviceP /// /// Get the metadata of the provisioning service without SAS keys. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// /// - /// Operation Id - /// ProvisioningServiceDescription_Get - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// Name of the provisioning service to retrieve. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] public static Response GetDeviceProvisioningService(this ResourceGroupResource resourceGroupResource, string provisioningServiceName, CancellationToken cancellationToken = default) { @@ -203,34 +167,88 @@ public static Response GetDeviceProvisioningS } /// - /// List all the provisioning services for a given subscription id. - /// + /// List private link resources for the given provisioning service /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices + /// Mocking. + /// To mock this method, please mock instead. /// + /// + /// The the method will execute against. + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + public static async Task> GetDeviceProvisioningServicesPrivateLinkResourcesAsync(this ResourceGroupResource resourceGroupResource, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDeviceProvisioningServicesResourceGroupResource(resourceGroupResource).GetDeviceProvisioningServicesPrivateLinkResourcesAsync(resourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// List private link resources for the given provisioning service /// - /// Operation Id - /// ProvisioningServiceDescription_ListBySubscription + /// Mocking. + /// To mock this method, please mock instead. /// + /// + /// The the method will execute against. + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + public static Response GetDeviceProvisioningServicesPrivateLinkResources(this ResourceGroupResource resourceGroupResource, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDeviceProvisioningServicesResourceGroupResource(resourceGroupResource).GetDeviceProvisioningServicesPrivateLinkResources(resourceName, cancellationToken); + } + + /// + /// List private endpoint connection properties /// - /// Default Api Version - /// 2025-02-01-preview + /// Mocking. + /// To mock this method, please mock instead. /// + /// + /// The the method will execute against. + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + public static async Task>> GetPrivateEndpointConnectionsAsync(this ResourceGroupResource resourceGroupResource, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDeviceProvisioningServicesResourceGroupResource(resourceGroupResource).GetPrivateEndpointConnectionsAsync(resourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// List private endpoint connection properties /// - /// Resource - /// + /// Mocking. + /// To mock this method, please mock instead. /// - /// + /// + /// The the method will execute against. + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + public static Response> GetPrivateEndpointConnections(this ResourceGroupResource resourceGroupResource, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDeviceProvisioningServicesResourceGroupResource(resourceGroupResource).GetPrivateEndpointConnections(resourceName, cancellationToken); + } + + /// + /// List all the provisioning services for a given subscription id. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The 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. + /// A collection of that may take multiple service requests to iterate over. public static AsyncPageable GetDeviceProvisioningServicesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -240,30 +258,12 @@ public static AsyncPageable GetDeviceProvisio /// /// List all the provisioning services for a given subscription id. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_ListBySubscription - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The cancellation token to use. /// is null. /// A collection of that may take multiple service requests to iterate over. @@ -276,29 +276,15 @@ public static Pageable GetDeviceProvisioningS /// /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability - /// - /// - /// Operation Id - /// IotDpsResourceOperationGroup_CheckDeviceProvisioningServicesNameAvailability - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static async Task> CheckDeviceProvisioningServicesNameAvailabilityAsync(this SubscriptionResource subscriptionResource, DeviceProvisioningServicesNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -308,29 +294,15 @@ public static async Task /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability - /// /// - /// Operation Id - /// IotDpsResourceOperationGroup_CheckDeviceProvisioningServicesNameAvailability - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static Response CheckDeviceProvisioningServicesNameAvailability(this SubscriptionResource subscriptionResource, DeviceProvisioningServicesNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesArmClient.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesArmClient.cs index e426fadd3633..c83da99125d3 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesArmClient.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesArmClient.cs @@ -6,38 +6,27 @@ #nullable disable using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableDeviceProvisioningServicesArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDeviceProvisioningServicesArmClient for mocking. protected MockableDeviceProvisioningServicesArmClient() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableDeviceProvisioningServicesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableDeviceProvisioningServicesArmClient(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. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual DeviceProvisioningServicesCertificateResource GetDeviceProvisioningServicesCertificateResource(ResourceIdentifier id) @@ -46,10 +35,7 @@ public virtual DeviceProvisioningServicesCertificateResource GetDeviceProvisioni return new DeviceProvisioningServicesCertificateResource(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. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual DeviceProvisioningServiceResource GetDeviceProvisioningServiceResource(ResourceIdentifier id) @@ -58,22 +44,7 @@ public virtual DeviceProvisioningServiceResource GetDeviceProvisioningServiceRes return new DeviceProvisioningServiceResource(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 DeviceProvisioningServicesPrivateLinkResource GetDeviceProvisioningServicesPrivateLinkResource(ResourceIdentifier id) - { - DeviceProvisioningServicesPrivateLinkResource.ValidateResourceId(id); - return new DeviceProvisioningServicesPrivateLinkResource(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. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual DeviceProvisioningServicesPrivateEndpointConnectionResource GetDeviceProvisioningServicesPrivateEndpointConnectionResource(ResourceIdentifier id) @@ -81,5 +52,14 @@ public virtual DeviceProvisioningServicesPrivateEndpointConnectionResource GetDe DeviceProvisioningServicesPrivateEndpointConnectionResource.ValidateResourceId(id); return new DeviceProvisioningServicesPrivateEndpointConnectionResource(Client, id); } + + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The resource ID of the resource to get. + /// Returns a object. + public virtual DeviceProvisioningServicesPrivateLinkResource GetDeviceProvisioningServicesPrivateLinkResource(ResourceIdentifier id) + { + DeviceProvisioningServicesPrivateLinkResource.ValidateResourceId(id); + return new DeviceProvisioningServicesPrivateLinkResource(Client, id); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesResourceGroupResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesResourceGroupResource.cs index e2b7e37b9e16..146badef407a 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesResourceGroupResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesResourceGroupResource.cs @@ -6,35 +6,49 @@ #nullable disable using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.DeviceProvisioningServices; +using Azure.ResourceManager.DeviceProvisioningServices.Models; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DeviceProvisioningServices.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableDeviceProvisioningServicesResourceGroupResource : ArmResource { - /// Initializes a new instance of the class for mocking. + private ClientDiagnostics _groupIdInformationsClientDiagnostics; + private GroupIdInformations _groupIdInformationsRestClient; + private ClientDiagnostics _privateEndpointConnectionsClientDiagnostics; + private PrivateEndpointConnections _privateEndpointConnectionsRestClient; + + /// Initializes a new instance of MockableDeviceProvisioningServicesResourceGroupResource for mocking. protected MockableDeviceProvisioningServicesResourceGroupResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableDeviceProvisioningServicesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private ClientDiagnostics GroupIdInformationsClientDiagnostics => _groupIdInformationsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private GroupIdInformations GroupIdInformationsRestClient => _groupIdInformationsRestClient ??= new GroupIdInformations(GroupIdInformationsClientDiagnostics, Pipeline, Endpoint, "2025-02-01-preview"); + + private ClientDiagnostics PrivateEndpointConnectionsClientDiagnostics => _privateEndpointConnectionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - /// Gets a collection of DeviceProvisioningServiceResources in the ResourceGroupResource. - /// An object representing collection of DeviceProvisioningServiceResources and their operations over a DeviceProvisioningServiceResource. + private PrivateEndpointConnections PrivateEndpointConnectionsRestClient => _privateEndpointConnectionsRestClient ??= new PrivateEndpointConnections(PrivateEndpointConnectionsClientDiagnostics, Pipeline, Endpoint, "2025-02-01-preview"); + + /// Gets a collection of DeviceProvisioningServices in the . + /// An object representing collection of DeviceProvisioningServices and their operations over a DeviceProvisioningServiceResource. public virtual DeviceProvisioningServiceCollection GetDeviceProvisioningServices() { return GetCachedClient(client => new DeviceProvisioningServiceCollection(client, Id)); @@ -44,20 +58,16 @@ public virtual DeviceProvisioningServiceCollection GetDeviceProvisioningServices /// Get the metadata of the provisioning service without SAS keys. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} - /// - /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Default Api Version - /// 2025-02-01-preview + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -68,6 +78,8 @@ public virtual DeviceProvisioningServiceCollection GetDeviceProvisioningServices [ForwardsClientCalls] public virtual async Task> GetDeviceProvisioningServiceAsync(string provisioningServiceName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); + return await GetDeviceProvisioningServices().GetAsync(provisioningServiceName, cancellationToken).ConfigureAwait(false); } @@ -75,20 +87,16 @@ public virtual async Task> GetDevice /// Get the metadata of the provisioning service without SAS keys. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}. /// /// - /// Operation Id - /// ProvisioningServiceDescription_Get + /// Operation Id. + /// ProvisioningServiceDescriptions_Get. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -99,7 +107,205 @@ public virtual async Task> GetDevice [ForwardsClientCalls] public virtual Response GetDeviceProvisioningService(string provisioningServiceName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); + return GetDeviceProvisioningServices().Get(provisioningServiceName, cancellationToken); } + + /// + /// List private link resources for the given provisioning service + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources. + /// + /// + /// Operation Id. + /// GroupIdInformations_ListPrivateLinkResources. + /// + /// + /// Default Api Version. + /// 2025-02-01-preview. + /// + /// + /// + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetDeviceProvisioningServicesPrivateLinkResourcesAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using DiagnosticScope scope = GroupIdInformationsClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesResourceGroupResource.GetDeviceProvisioningServicesPrivateLinkResources"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = GroupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(PrivateLinkResources.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List private link resources for the given provisioning service + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources. + /// + /// + /// Operation Id. + /// GroupIdInformations_ListPrivateLinkResources. + /// + /// + /// Default Api Version. + /// 2025-02-01-preview. + /// + /// + /// + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetDeviceProvisioningServicesPrivateLinkResources(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using DiagnosticScope scope = GroupIdInformationsClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesResourceGroupResource.GetDeviceProvisioningServicesPrivateLinkResources"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = GroupIdInformationsRestClient.CreateGetPrivateLinkResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(PrivateLinkResources.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List private endpoint connection properties + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections. + /// + /// + /// Operation Id. + /// PrivateEndpointConnections_ListPrivateEndpointConnections. + /// + /// + /// Default Api Version. + /// 2025-02-01-preview. + /// + /// + /// + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task>> GetPrivateEndpointConnectionsAsync(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using DiagnosticScope scope = PrivateEndpointConnectionsClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesResourceGroupResource.GetPrivateEndpointConnections"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = PrivateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionsRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response> response = Response.FromValue(IList.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List private endpoint connection properties + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections. + /// + /// + /// Operation Id. + /// PrivateEndpointConnections_ListPrivateEndpointConnections. + /// + /// + /// Default Api Version. + /// 2025-02-01-preview. + /// + /// + /// + /// Name of the provisioning service to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response> GetPrivateEndpointConnections(string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using DiagnosticScope scope = PrivateEndpointConnectionsClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesResourceGroupResource.GetPrivateEndpointConnections"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = PrivateEndpointConnectionsRestClient.CreateGetPrivateEndpointConnectionsRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response> response = Response.FromValue(IList.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesSubscriptionResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesSubscriptionResource.cs index 92a0d7690e2f..df9f8b94215c 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesSubscriptionResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Extensions/MockableDeviceProvisioningServicesSubscriptionResource.cs @@ -8,92 +8,86 @@ using System; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.DeviceProvisioningServices; using Azure.ResourceManager.DeviceProvisioningServices.Models; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DeviceProvisioningServices.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableDeviceProvisioningServicesSubscriptionResource : ArmResource { - private ClientDiagnostics _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics; - private ProvisioningServiceDescriptionsRestOperations _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient; + private ClientDiagnostics _provisioningServiceDescriptionsClientDiagnostics; + private ProvisioningServiceDescriptions _provisioningServiceDescriptionsRestClient; private ClientDiagnostics _iotDpsResourceClientDiagnostics; - private IotDpsResourceRestOperations _iotDpsResourceRestClient; + private IotDpsResource _iotDpsResourceRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDeviceProvisioningServicesSubscriptionResource for mocking. protected MockableDeviceProvisioningServicesSubscriptionResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableDeviceProvisioningServicesSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics DeviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics => _deviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", DeviceProvisioningServiceResource.ResourceType.Namespace, Diagnostics); - private ProvisioningServiceDescriptionsRestOperations DeviceProvisioningServiceProvisioningServiceDescriptionsRestClient => _deviceProvisioningServiceProvisioningServiceDescriptionsRestClient ??= new ProvisioningServiceDescriptionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(DeviceProvisioningServiceResource.ResourceType)); - private ClientDiagnostics IotDpsResourceClientDiagnostics => _iotDpsResourceClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private IotDpsResourceRestOperations IotDpsResourceRestClient => _iotDpsResourceRestClient ??= new IotDpsResourceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics ProvisioningServiceDescriptionsClientDiagnostics => _provisioningServiceDescriptionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private ProvisioningServiceDescriptions ProvisioningServiceDescriptionsRestClient => _provisioningServiceDescriptionsRestClient ??= new ProvisioningServiceDescriptions(ProvisioningServiceDescriptionsClientDiagnostics, Pipeline, Endpoint, "2025-02-01-preview"); + + private ClientDiagnostics IotDpsResourceClientDiagnostics => _iotDpsResourceClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DeviceProvisioningServices.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private IotDpsResource IotDpsResourceRestClient => _iotDpsResourceRestClient ??= new IotDpsResource(IotDpsResourceClientDiagnostics, Pipeline, Endpoint, "2025-02-01-preview"); /// /// List all the provisioning services for a given subscription id. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices. /// /// - /// Operation Id - /// ProvisioningServiceDescription_ListBySubscription + /// Operation Id. + /// ProvisioningServiceDescriptions_ListBySubscription. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetDeviceProvisioningServicesAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DeviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DeviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeviceProvisioningServiceResource(Client, DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(e)), DeviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "MockableDeviceProvisioningServicesSubscriptionResource.GetDeviceProvisioningServices", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ProvisioningServiceDescriptionsGetBySubscriptionAsyncCollectionResultOfT(ProvisioningServiceDescriptionsRestClient, Id.SubscriptionId, context), data => new DeviceProvisioningServiceResource(Client, data)); } /// /// List all the provisioning services for a given subscription id. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices. /// /// - /// Operation Id - /// ProvisioningServiceDescription_ListBySubscription + /// Operation Id. + /// ProvisioningServiceDescriptions_ListBySubscription. /// /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-02-01-preview. /// /// /// @@ -101,28 +95,14 @@ public virtual AsyncPageable GetDeviceProvisi /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetDeviceProvisioningServices(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DeviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DeviceProvisioningServiceProvisioningServiceDescriptionsRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeviceProvisioningServiceResource(Client, DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(e)), DeviceProvisioningServiceProvisioningServiceDescriptionsClientDiagnostics, Pipeline, "MockableDeviceProvisioningServicesSubscriptionResource.GetDeviceProvisioningServices", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ProvisioningServiceDescriptionsGetBySubscriptionCollectionResultOfT(ProvisioningServiceDescriptionsRestClient, Id.SubscriptionId, context), data => new DeviceProvisioningServiceResource(Client, data)); } - /// - /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability - /// - /// - /// Operation Id - /// IotDpsResourceOperationGroup_CheckDeviceProvisioningServicesNameAvailability - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// + /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable. /// The request body. /// The cancellation token to use. /// is null. @@ -130,11 +110,21 @@ public virtual async Task response = Response.FromValue(DeviceProvisioningServicesNameAvailabilityResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -144,23 +134,7 @@ public virtual async Task - /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability - /// - /// - /// Operation Id - /// IotDpsResourceOperationGroup_CheckDeviceProvisioningServicesNameAvailability - /// - /// - /// Default Api Version - /// 2025-02-01-preview - /// - /// - /// + /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable. /// The request body. /// The cancellation token to use. /// is null. @@ -168,11 +142,21 @@ public virtual Response CheckD { Argument.AssertNotNull(content, nameof(content)); - using var scope = IotDpsResourceClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesSubscriptionResource.CheckDeviceProvisioningServicesNameAvailability"); + using DiagnosticScope scope = IotDpsResourceClientDiagnostics.CreateScope("MockableDeviceProvisioningServicesSubscriptionResource.CheckDeviceProvisioningServicesNameAvailability"); scope.Start(); try { - var response = IotDpsResourceRestClient.CheckDeviceProvisioningServicesNameAvailability(Id.SubscriptionId, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = IotDpsResourceRestClient.CreateCheckDeviceProvisioningServicesNameAvailabilityRequest(Id.SubscriptionId, DeviceProvisioningServicesNameAvailabilityContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DeviceProvisioningServicesNameAvailabilityResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Argument.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Argument.cs index 8c79aa649187..715b2ebd643d 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Argument.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - internal static class Argument + internal static partial class Argument { + /// The value. + /// The name. public static void AssertNotNull(T value, string name) { if (value is null) @@ -21,8 +23,10 @@ public static void AssertNotNull(T value, string name) } } + /// The value. + /// The name. public static void AssertNotNull(T? value, string name) - where T : struct + where T : struct { if (!value.HasValue) { @@ -30,6 +34,8 @@ public static void AssertNotNull(T? value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(IEnumerable value, string name) { if (value is null) @@ -51,6 +57,8 @@ public static void AssertNotNullOrEmpty(IEnumerable value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(string value, string name) { if (value is null) @@ -62,68 +70,5 @@ public static void AssertNotNullOrEmpty(string value, string name) 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..bcd50344f5b9 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/AsyncPageableWrapper.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class AsyncPageableWrapper : AsyncPageable + { + /// The source async pageable value of type AsyncPageable<T>. + private AsyncPageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the AsyncPageableWrapper class. + /// The source async pageable value of type AsyncPageable<T>. + /// The converter function from T to U. + public AsyncPageableWrapper(AsyncPageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from AsyncPageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingDictionary.cs index b44591423e3b..acf44be1d727 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull { private IDictionary _innerDictionary; @@ -19,6 +20,7 @@ public ChangeTrackingDictionary() { } + /// The inner dictionary. public ChangeTrackingDictionary(IDictionary dictionary) { if (dictionary == null) @@ -28,6 +30,7 @@ public ChangeTrackingDictionary(IDictionary dictionary) _innerDictionary = new Dictionary(dictionary); } + /// The inner dictionary. public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) { if (dictionary == null) @@ -41,16 +44,22 @@ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerDictionary == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + /// Gets the Keys. public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + /// Gets the Values. public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + /// Gets or sets the value associated with the specified key. public TValue this[TKey key] { get @@ -67,8 +76,10 @@ public TValue this[TKey key] } } + /// Gets the Keys. IEnumerable IReadOnlyDictionary.Keys => Keys; + /// Gets the Values. IEnumerable IReadOnlyDictionary.Values => Values; public IEnumerator> GetEnumerator() @@ -89,6 +100,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(KeyValuePair item) { EnsureDictionary().Add(item); @@ -99,6 +111,7 @@ public void Clear() EnsureDictionary().Clear(); } + /// The item to search for. public bool Contains(KeyValuePair item) { if (IsUndefined) @@ -108,6 +121,8 @@ public bool Contains(KeyValuePair item) return EnsureDictionary().Contains(item); } + /// The array to copy. + /// The index. public void CopyTo(KeyValuePair[] array, int index) { if (IsUndefined) @@ -117,6 +132,7 @@ public void CopyTo(KeyValuePair[] array, int index) EnsureDictionary().CopyTo(array, index); } + /// The item to remove. public bool Remove(KeyValuePair item) { if (IsUndefined) @@ -126,11 +142,14 @@ public bool Remove(KeyValuePair item) return EnsureDictionary().Remove(item); } + /// The key. + /// The value to add. public void Add(TKey key, TValue value) { EnsureDictionary().Add(key, value); } + /// The key to search for. public bool ContainsKey(TKey key) { if (IsUndefined) @@ -140,6 +159,7 @@ public bool ContainsKey(TKey key) return EnsureDictionary().ContainsKey(key); } + /// The key. public bool Remove(TKey key) { if (IsUndefined) @@ -149,6 +169,8 @@ public bool Remove(TKey key) return EnsureDictionary().Remove(key); } + /// The key to search for. + /// The value. public bool TryGetValue(TKey key, out TValue value) { if (IsUndefined) diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingList.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingList.cs index 6b66d3c8d3bb..ac42a88b1511 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - internal class ChangeTrackingList : IList, IReadOnlyList + internal partial class ChangeTrackingList : IList, IReadOnlyList { private IList _innerList; @@ -20,6 +20,7 @@ public ChangeTrackingList() { } + /// The inner list. public ChangeTrackingList(IList innerList) { if (innerList != null) @@ -28,6 +29,7 @@ public ChangeTrackingList(IList innerList) } } + /// The inner list. public ChangeTrackingList(IReadOnlyList innerList) { if (innerList != null) @@ -36,12 +38,16 @@ public ChangeTrackingList(IReadOnlyList innerList) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerList == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureList().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + /// Gets or sets the value associated with the specified key. public T this[int index] { get @@ -85,6 +91,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(T item) { EnsureList().Add(item); @@ -95,6 +102,7 @@ public void Clear() EnsureList().Clear(); } + /// The item. public bool Contains(T item) { if (IsUndefined) @@ -104,6 +112,8 @@ public bool Contains(T item) return EnsureList().Contains(item); } + /// The array to copy to. + /// The array index. public void CopyTo(T[] array, int arrayIndex) { if (IsUndefined) @@ -113,6 +123,7 @@ public void CopyTo(T[] array, int arrayIndex) EnsureList().CopyTo(array, arrayIndex); } + /// The item. public bool Remove(T item) { if (IsUndefined) @@ -122,6 +133,7 @@ public bool Remove(T item) return EnsureList().Remove(item); } + /// The item. public int IndexOf(T item) { if (IsUndefined) @@ -131,11 +143,14 @@ public int IndexOf(T item) return EnsureList().IndexOf(item); } + /// The inner list. + /// The item. public void Insert(int index, T item) { EnsureList().Insert(index, item); } + /// The inner list. public void RemoveAt(int index) { if (IsUndefined) diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..411d45a16a3c --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ErrorResult.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..c60661b328f6 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ModelSerializationExtensions.cs index e6e18d361eb7..cc13f36444c9 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/ModelSerializationExtensions.cs @@ -11,18 +11,16 @@ using System.Diagnostics; using System.Globalization; using System.Text.Json; -using System.Xml; -using Azure.Core; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal static class ModelSerializationExtensions + internal static partial class ModelSerializationExtensions { - internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); - internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); - internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; public static object GetObject(this JsonElement element) { @@ -48,14 +46,14 @@ public static object GetObject(this JsonElement element) case JsonValueKind.Null: return null; case JsonValueKind.Object: - var dictionary = new Dictionary(); + Dictionary 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(); + List list = new List(); foreach (var item in element.EnumerateArray()) { list.Add(item.GetObject()); @@ -93,7 +91,7 @@ public static char GetChar(this JsonElement element) { if (element.ValueKind == JsonValueKind.String) { - var text = element.GetString(); + string text = element.GetString(); if (text == null || text.Length != 1) { throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); @@ -107,14 +105,14 @@ public static char GetChar(this JsonElement element) } [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + 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"); + 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(); + string 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}'."); @@ -181,9 +179,6 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value, Mode case IJsonModel jsonModel: jsonModel.Write(writer, options ?? WireOptions); break; - case IUtf8JsonSerializable serializable: - serializable.Write(writer); - break; case byte[] bytes: writer.WriteBase64StringValue(bytes); break; @@ -259,151 +254,5 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, object value, Mo { 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Optional.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Optional.cs index 12e064fb9244..a20c8fbdf35d 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Optional.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - internal static class Optional + internal static partial class Optional { public static bool IsCollectionDefined(IEnumerable collection) { @@ -28,7 +28,7 @@ public static bool IsCollectionDefined(IReadOnlyDictionary(T? value) - where T : struct + where T : struct { return value.HasValue; } @@ -38,14 +38,14 @@ public static bool IsDefined(object value) return value != null; } - public static bool IsDefined(JsonElement value) + public static bool IsDefined(string value) { - return value.ValueKind != JsonValueKind.Undefined; + return value != null; } - public static bool IsDefined(string value) + public static bool IsDefined(JsonElement value) { - return value != null; + return value.ValueKind != JsonValueKind.Undefined; } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/PageableWrapper.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..9e4ce6daaa9c --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..c3f6705755f2 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/RequestContextExtensions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..8d7ce07845f9 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/SerializationFormat.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..651a91794c5c --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/TypeFormatters.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..4b0f43376fc1 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// 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.Xml; + +namespace Azure.ResourceManager.DeviceProvisioningServices +{ + internal static partial 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}. Generated clients require 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 ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return 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 formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Utf8JsonRequestContent.cs index d2ed99ca25f3..0ec9222c3b8b 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - internal class Utf8JsonRequestContent : RequestContent + internal partial class Utf8JsonRequestContent : RequestContent { private readonly MemoryStream _stream; private readonly RequestContent _content; @@ -25,20 +25,26 @@ public Utf8JsonRequestContent() JsonWriter = new Utf8JsonWriter(_stream); } + /// Gets the JsonWriter. public Utf8JsonWriter JsonWriter { get; } + /// The stream containing the data to be written. + /// The cancellation token to use. public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) { await JsonWriter.FlushAsync().ConfigureAwait(false); await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); } + /// The stream containing the data to be written. + /// The cancellation token to use. 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; diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServiceOperationSource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServiceOperationSource.cs index b9fab382f499..543d613dd23a 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServiceOperationSource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServiceOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal class DeviceProvisioningServiceOperationSource : IOperationSource + /// + internal partial class DeviceProvisioningServiceOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal DeviceProvisioningServiceOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// DeviceProvisioningServiceResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDeviceProvisioningServicesContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + DeviceProvisioningServiceData data = DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(document.RootElement, ModelSerializationExtensions.WireOptions); return new DeviceProvisioningServiceResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDeviceProvisioningServicesContext.Default); - return await Task.FromResult(new DeviceProvisioningServiceResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + DeviceProvisioningServiceData data = DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new DeviceProvisioningServiceResource(_client, data); } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperation.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperation.cs index fd9ad034c335..1879fe54c99c 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperation.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperation.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { -#pragma warning disable SA1649 // File name should match first type name - internal class DeviceProvisioningServicesArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class DeviceProvisioningServicesArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected DeviceProvisioningServicesArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal DeviceProvisioningServicesArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response); @@ -36,12 +37,20 @@ internal DeviceProvisioningServicesArmOperation(Response response, RehydrationTo _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal DeviceProvisioningServicesArmOperation(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) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,48 +58,49 @@ internal DeviceProvisioningServicesArmOperation(ClientDiagnostics clientDiagnost _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "DeviceProvisioningServicesArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "DeviceProvisioningServicesArmOperation", + null, + new SequentialDelayStrategy()); } + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. private string GetOperationId(RehydrationToken? rehydrationToken) { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerDeviceProvisioningServicesContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); + return rehydrationToken?.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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperationOfT.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperationOfT.cs index e7828cb9ce08..3ed7b6da912d 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperationOfT.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesArmOperationOfT.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { -#pragma warning disable SA1649 // File name should match first type name - internal class DeviceProvisioningServicesArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class DeviceProvisioningServicesArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected DeviceProvisioningServicesArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal DeviceProvisioningServicesArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal DeviceProvisioningServicesArmOperation(Response response, Rehydratio _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal DeviceProvisioningServicesArmOperation(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) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,54 +59,55 @@ internal DeviceProvisioningServicesArmOperation(IOperationSource source, Clie _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "DeviceProvisioningServicesArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "DeviceProvisioningServicesArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerDeviceProvisioningServicesContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); - } - /// + /// Gets the Id. public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// - public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - - /// + /// Gets the Value. public override T Value => _operation.Value; - /// + /// Gets the HasValue. public override bool HasValue => _operation.HasValue; - /// + /// Gets the HasCompleted. public override bool HasCompleted => _operation.HasCompleted; - /// + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesPrivateEndpointConnectionOperationSource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesPrivateEndpointConnectionOperationSource.cs index bdf2f8e56aae..9d161440dd65 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesPrivateEndpointConnectionOperationSource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/LongRunningOperation/DeviceProvisioningServicesPrivateEndpointConnectionOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal class DeviceProvisioningServicesPrivateEndpointConnectionOperationSource : IOperationSource + /// + internal partial class DeviceProvisioningServicesPrivateEndpointConnectionOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal DeviceProvisioningServicesPrivateEndpointConnectionOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// DeviceProvisioningServicesPrivateEndpointConnectionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDeviceProvisioningServicesContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + DeviceProvisioningServicesPrivateEndpointConnectionData data = DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); return new DeviceProvisioningServicesPrivateEndpointConnectionResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDeviceProvisioningServicesContext.Default); - return await Task.FromResult(new DeviceProvisioningServicesPrivateEndpointConnectionResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + DeviceProvisioningServicesPrivateEndpointConnectionData data = DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new DeviceProvisioningServicesPrivateEndpointConnectionResource(_client, data); } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/AzureResourceManagerDeviceProvisioningServicesContext.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/AzureResourceManagerDeviceProvisioningServicesContext.cs index b2a7c14ff301..2c992334b960 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/AzureResourceManagerDeviceProvisioningServicesContext.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/AzureResourceManagerDeviceProvisioningServicesContext.cs @@ -6,15 +6,15 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.DeviceProvisioningServices.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { /// /// 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' + /// For more information /// [ModelReaderWriterBuildable(typeof(CertificateListDescription))] [ModelReaderWriterBuildable(typeof(CertificateVerificationCodeContent))] @@ -27,12 +27,10 @@ namespace Azure.ResourceManager.DeviceProvisioningServices [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesCertificateData))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesCertificateProperties))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesCertificateResource))] - [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesCertificateResourceDeleteOptions))] - [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions))] - [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesIPFilterRule))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesNameAvailabilityContent))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesNameAvailabilityResult))] + [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesPrivateEndpoint))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesPrivateEndpointConnectionData))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesPrivateEndpointConnectionProperties))] [ModelReaderWriterBuildable(typeof(DeviceProvisioningServicesPrivateEndpointConnectionResource))] @@ -51,7 +49,6 @@ namespace Azure.ResourceManager.DeviceProvisioningServices [ModelReaderWriterBuildable(typeof(ProvisioningServiceDescriptionListResult))] [ModelReaderWriterBuildable(typeof(ResponseError))] [ModelReaderWriterBuildable(typeof(SharedAccessSignatureAuthorizationRuleListResult))] - [ModelReaderWriterBuildable(typeof(SubResource))] [ModelReaderWriterBuildable(typeof(SystemData))] [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] public partial class AzureResourceManagerDeviceProvisioningServicesContext : ModelReaderWriterContext diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.Serialization.cs index f37f52fed9a8..becb86a6e558 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - internal partial class CertificateListDescription : IUtf8JsonSerializable, IJsonModel + /// The JSON-serialized array of Certificate objects. + public partial class CertificateListDescription : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +30,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateListDescription)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DeviceProvisioningServicesCertificateData item in Value) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,39 +62,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - CertificateListDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CertificateListDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CertificateListDescription JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateListDescription)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCertificateListDescription(document.RootElement, options); } - internal static CertificateListDescription DeserializeCertificateListDescription(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CertificateListDescription DeserializeCertificateListDescription(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(item, options)); } @@ -102,17 +107,19 @@ internal static CertificateListDescription DeserializeCertificateListDescription } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new CertificateListDescription(value ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new CertificateListDescription(value ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - CertificateListDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + CertificateListDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CertificateListDescription PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeCertificateListDescription(document.RootElement, options); } default: @@ -138,6 +150,14 @@ CertificateListDescription IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static CertificateListDescription FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCertificateListDescription(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.cs index 69fef5a41054..453fb731b969 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateListDescription.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The JSON-serialized array of Certificate objects. - internal partial class CertificateListDescription + public partial class CertificateListDescription { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal CertificateListDescription() @@ -53,14 +25,14 @@ internal CertificateListDescription() /// Initializes a new instance of . /// The array of Certificate objects. - /// Keeps track of any properties unknown to the library. - internal CertificateListDescription(IReadOnlyList value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal CertificateListDescription(IList value, IDictionary additionalBinaryDataProperties) { Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The array of Certificate objects. - public IReadOnlyList Value { get; } + public IList Value { get; } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.Serialization.cs index aae187149702..e80444d36205 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class CertificateVerificationCodeContent : IUtf8JsonSerializable, IJsonModel + /// The JSON-serialized leaf certificate. + public partial class CertificateVerificationCodeContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +30,25 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateVerificationCodeContent)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Certificate)) { writer.WritePropertyName("certificate"u8); writer.WriteStringValue(Certificate); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -56,49 +57,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - CertificateVerificationCodeContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CertificateVerificationCodeContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CertificateVerificationCodeContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateVerificationCodeContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCertificateVerificationCodeContent(document.RootElement, options); } - internal static CertificateVerificationCodeContent DeserializeCertificateVerificationCodeContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CertificateVerificationCodeContent DeserializeCertificateVerificationCodeContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string certificate = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("certificate"u8)) + if (prop.NameEquals("certificate"u8)) { - certificate = property.Value.GetString(); + certificate = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new CertificateVerificationCodeContent(certificate, serializedAdditionalRawData); + return new CertificateVerificationCodeContent(certificate, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -108,15 +115,20 @@ BinaryData IPersistableModel.Write(ModelRead } } - CertificateVerificationCodeContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + CertificateVerificationCodeContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CertificateVerificationCodeContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeCertificateVerificationCodeContent(document.RootElement, options); } default: @@ -124,6 +136,19 @@ CertificateVerificationCodeContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(CertificateVerificationCodeContent certificateVerificationCodeContent) + { + if (certificateVerificationCodeContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(certificateVerificationCodeContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.cs index ab960816e51e..79d3b2531865 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeContent.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// The JSON-serialized leaf certificate. public partial class CertificateVerificationCodeContent { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public CertificateVerificationCodeContent() @@ -52,11 +23,11 @@ public CertificateVerificationCodeContent() /// Initializes a new instance of . /// base-64 representation of X509 certificate .cer file or just .pem file content. - /// Keeps track of any properties unknown to the library. - internal CertificateVerificationCodeContent(string certificate, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal CertificateVerificationCodeContent(string certificate, IDictionary additionalBinaryDataProperties) { Certificate = certificate; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// base-64 representation of X509 certificate .cer file or just .pem file content. diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.Serialization.cs index 3f93a9a9727c..858f4c37e8f8 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class CertificateVerificationCodeProperties : IUtf8JsonSerializable, IJsonModel + /// The CertificateVerificationCodeProperties. + public partial class CertificateVerificationCodeProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writ /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateVerificationCodeProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(VerificationCode)) { writer.WritePropertyName("verificationCode"u8); @@ -53,9 +53,9 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("thumbprint"u8); #if NET6_0_OR_GREATER - writer.WriteRawValue(Thumbprint); + writer.WriteRawValue(Thumbprint); #else - using (JsonDocument document = JsonDocument.Parse(Thumbprint, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(Thumbprint)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -70,9 +70,9 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("certificate"u8); #if NET6_0_OR_GREATER - writer.WriteRawValue(Certificate); + writer.WriteRawValue(Certificate); #else - using (JsonDocument document = JsonDocument.Parse(Certificate, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(Certificate)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -88,15 +88,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("updated"u8); writer.WriteStringValue(UpdatedOn.Value, "O"); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -105,124 +105,130 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - CertificateVerificationCodeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CertificateVerificationCodeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CertificateVerificationCodeProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateVerificationCodeProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCertificateVerificationCodeProperties(document.RootElement, options); } - internal static CertificateVerificationCodeProperties DeserializeCertificateVerificationCodeProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CertificateVerificationCodeProperties DeserializeCertificateVerificationCodeProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string verificationCode = default; string subject = default; - DateTimeOffset? expiry = default; + DateTimeOffset? expireOn = default; BinaryData thumbprint = default; bool? isVerified = default; BinaryData certificate = default; - DateTimeOffset? created = default; - DateTimeOffset? updated = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DateTimeOffset? createdOn = default; + DateTimeOffset? updatedOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("verificationCode"u8)) + if (prop.NameEquals("verificationCode"u8)) { - verificationCode = property.Value.GetString(); + verificationCode = prop.Value.GetString(); continue; } - if (property.NameEquals("subject"u8)) + if (prop.NameEquals("subject"u8)) { - subject = property.Value.GetString(); + subject = prop.Value.GetString(); continue; } - if (property.NameEquals("expiry"u8)) + if (prop.NameEquals("expiry"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expiry = property.Value.GetDateTimeOffset("O"); + expireOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("thumbprint"u8)) + if (prop.NameEquals("thumbprint"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - thumbprint = BinaryData.FromString(property.Value.GetRawText()); + thumbprint = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (property.NameEquals("isVerified"u8)) + if (prop.NameEquals("isVerified"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isVerified = property.Value.GetBoolean(); + isVerified = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("certificate"u8)) + if (prop.NameEquals("certificate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - certificate = BinaryData.FromString(property.Value.GetRawText()); + certificate = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (property.NameEquals("created"u8)) + if (prop.NameEquals("created"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - created = property.Value.GetDateTimeOffset("O"); + createdOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("updated"u8)) + if (prop.NameEquals("updated"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - updated = property.Value.GetDateTimeOffset("O"); + updatedOn = prop.Value.GetDateTimeOffset("O"); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new CertificateVerificationCodeProperties( verificationCode, subject, - expiry, + expireOn, thumbprint, isVerified, certificate, - created, - updated, - serializedAdditionalRawData); + createdOn, + updatedOn, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -232,15 +238,20 @@ BinaryData IPersistableModel.Write(ModelR } } - CertificateVerificationCodeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + CertificateVerificationCodeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CertificateVerificationCodeProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeCertificateVerificationCodeProperties(document.RootElement, options); } default: @@ -248,6 +259,7 @@ CertificateVerificationCodeProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.cs index 38134270fc75..a18a16ff8d72 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using System.Text.Json; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The CertificateVerificationCodeProperties. public partial class CertificateVerificationCodeProperties { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal CertificateVerificationCodeProperties() @@ -59,8 +31,8 @@ internal CertificateVerificationCodeProperties() /// base-64 representation of X509 certificate .cer file or just .pem file content. /// Certificate created time. /// Certificate updated time. - /// Keeps track of any properties unknown to the library. - internal CertificateVerificationCodeProperties(string verificationCode, string subject, DateTimeOffset? expireOn, BinaryData thumbprint, bool? isVerified, BinaryData certificate, DateTimeOffset? createdOn, DateTimeOffset? updatedOn, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal CertificateVerificationCodeProperties(string verificationCode, string subject, DateTimeOffset? expireOn, BinaryData thumbprint, bool? isVerified, BinaryData certificate, DateTimeOffset? createdOn, DateTimeOffset? updatedOn, IDictionary additionalBinaryDataProperties) { VerificationCode = verificationCode; Subject = subject; @@ -70,81 +42,80 @@ internal CertificateVerificationCodeProperties(string verificationCode, string s Certificate = certificate; CreatedOn = createdOn; UpdatedOn = updatedOn; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Verification code. public string VerificationCode { get; } + /// Certificate subject. public string Subject { get; } + /// Code expiry. public DateTimeOffset? ExpireOn { get; } + /// /// Certificate thumbprint. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . /// /// Examples: /// /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". /// /// - /// BinaryData.FromString("\"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.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. /// /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. /// /// /// /// public BinaryData Thumbprint { get; } + /// Indicate if the certificate is verified by owner of private key. public bool? IsVerified { get; } + /// /// base-64 representation of X509 certificate .cer file or just .pem file content. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . /// /// Examples: /// /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". /// /// - /// BinaryData.FromString("\"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.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. /// /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. /// /// /// /// public BinaryData Certificate { get; } + /// Certificate created time. public DateTimeOffset? CreatedOn { get; } + /// Certificate updated time. public DateTimeOffset? UpdatedOn { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.Serialization.cs index 144f77ed3f91..ab05d0f88e68 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.Serialization.cs @@ -8,17 +8,17 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Text; using System.Text.Json; -using Azure.Core; -using Azure.ResourceManager.Models; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class CertificateVerificationCodeResult : IUtf8JsonSerializable, IJsonModel + /// Description of the response of the verification code. + public partial class CertificateVerificationCodeResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,119 +28,142 @@ void IJsonModel.Write(Utf8JsonWriter writer, /// The JSON writer. /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateVerificationCodeResult)} does not support writing '{format}' format."); } - - base.JsonModelWriteCore(writer, options); + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } if (options.Format != "W" && Optional.IsDefined(ETag)) { writer.WritePropertyName("etag"u8); writer.WriteStringValue(ETag.Value.ToString()); } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } if (Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } } - CertificateVerificationCodeResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CertificateVerificationCodeResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CertificateVerificationCodeResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(CertificateVerificationCodeResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCertificateVerificationCodeResult(document.RootElement, options); } - internal static CertificateVerificationCodeResult DeserializeCertificateVerificationCodeResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CertificateVerificationCodeResult DeserializeCertificateVerificationCodeResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ETag? etag = default; - CertificateVerificationCodeProperties 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()) + ETag? eTag = default; + string id = default; + string @type = default; + CertificateVerificationCodeProperties properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("etag"u8)) + if (prop.NameEquals("name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - etag = new ETag(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("etag"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = CertificateVerificationCodeProperties.DeserializeCertificateVerificationCodeProperties(property.Value, options); + eTag = new ETag(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + id = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("type"u8)) { - name = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("properties"u8)) { - type = new ResourceType(property.Value.GetString()); - continue; - } - if (property.NameEquals("systemData"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDeviceProvisioningServicesContext.Default); + properties = CertificateVerificationCodeProperties.DeserializeCertificateVerificationCodeProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new CertificateVerificationCodeResult( - id, name, - type, - systemData, - etag, + eTag, + id, + @type, properties, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -150,15 +173,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - CertificateVerificationCodeResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + CertificateVerificationCodeResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CertificateVerificationCodeResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeCertificateVerificationCodeResult(document.RootElement, options); } default: @@ -166,6 +194,14 @@ CertificateVerificationCodeResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static CertificateVerificationCodeResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCertificateVerificationCodeResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.cs index 634377d96e2b..c2f00e03058c 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/CertificateVerificationCodeResult.cs @@ -7,45 +7,15 @@ using System; using System.Collections.Generic; -using Azure.Core; -using Azure.ResourceManager.Models; +using Azure; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// Description of the response of the verification code. - public partial class CertificateVerificationCodeResult : ResourceData + public partial class CertificateVerificationCodeResult { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal CertificateVerificationCodeResult() @@ -53,23 +23,35 @@ internal CertificateVerificationCodeResult() } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// Request etag. + /// Name of certificate. + /// Request etag. + /// The resource identifier. + /// The resource type. /// - /// Keeps track of any properties unknown to the library. - internal CertificateVerificationCodeResult(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, CertificateVerificationCodeProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// Keeps track of any properties unknown to the library. + internal CertificateVerificationCodeResult(string name, ETag? eTag, string id, string @type, CertificateVerificationCodeProperties properties, IDictionary additionalBinaryDataProperties) { - ETag = etag; + Name = name; + ETag = eTag; + Id = id; + Type = @type; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + /// Name of certificate. + public string Name { get; } + /// Request etag. public ETag? ETag { get; } - /// Gets the properties. + + /// The resource identifier. + public string Id { get; } + + /// The resource type. + public string Type { get; } + + /// Gets the Properties. public CertificateVerificationCodeProperties Properties { get; } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.Serialization.cs index 17869692219c..700c7100ffe4 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicePatch : IUtf8JsonSerializable, IJsonModel + /// A container holding only the Tags for a resource, allowing the user to update the tags on a Provisioning Service instance. + public partial class DeviceProvisioningServicePatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicePatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -41,19 +42,24 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -62,58 +68,71 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicePatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicePatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicePatch(document.RootElement, options); } - internal static DeviceProvisioningServicePatch DeserializeDeviceProvisioningServicePatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicePatch DeserializeDeviceProvisioningServicePatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } tags = dictionary; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicePatch(tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new DeviceProvisioningServicePatch(tags ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -123,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWr } } - DeviceProvisioningServicePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicePatch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicePatch(document.RootElement, options); } default: @@ -139,6 +163,19 @@ DeviceProvisioningServicePatch IPersistableModel } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DeviceProvisioningServicePatch deviceProvisioningServicePatch) + { + if (deviceProvisioningServicePatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(deviceProvisioningServicePatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.cs index 72d918f714a7..bf1927242bd5 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicePatch.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// A container holding only the Tags for a resource, allowing the user to update the tags on a Provisioning Service instance. public partial class DeviceProvisioningServicePatch { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DeviceProvisioningServicePatch() @@ -53,11 +25,11 @@ public DeviceProvisioningServicePatch() /// Initializes a new instance of . /// Resource tags. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicePatch(IDictionary tags, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicePatch(IDictionary tags, IDictionary additionalBinaryDataProperties) { Tags = tags; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Resource tags. diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.Serialization.cs index a59066920775..87ef50b764a8 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServiceProperties : IUtf8JsonSerializable, IJsonModel + /// the service specific properties of a provisioning service, including keys, linked iot hubs, current state, and system generated properties such as hostname and idScope. + public partial class DeviceProvisioningServiceProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServiceProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(State)) { writer.WritePropertyName("state"u8); @@ -44,11 +44,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("publicNetworkAccess"u8); writer.WriteStringValue(PublicNetworkAccess.Value.ToString()); } - if (Optional.IsCollectionDefined(IPFilterRules)) + if (Optional.IsCollectionDefined(IpFilterRules)) { writer.WritePropertyName("ipFilterRules"u8); writer.WriteStartArray(); - foreach (var item in IPFilterRules) + foreach (DeviceProvisioningServicesIPFilterRule item in IpFilterRules) { writer.WriteObjectValue(item, options); } @@ -58,7 +58,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("privateEndpointConnections"u8); writer.WriteStartArray(); - foreach (var item in PrivateEndpointConnections) + foreach (DeviceProvisioningServicesPrivateEndpointConnectionData item in PrivateEndpointConnections) { writer.WriteObjectValue(item, options); } @@ -73,7 +73,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("iotHubs"u8); writer.WriteStartArray(); - foreach (var item in IotHubs) + foreach (IotHubDefinitionDescription item in IotHubs) { writer.WriteObjectValue(item, options); } @@ -108,7 +108,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("authorizationPolicies"u8); writer.WriteStartArray(); - foreach (var item in AuthorizationPolicies) + foreach (DeviceProvisioningServicesSharedAccessKey item in AuthorizationPolicies) { writer.WriteObjectValue(item, options); } @@ -124,15 +124,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("portalOperationsHostName"u8); writer.WriteStringValue(PortalOperationsHostName); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -141,22 +141,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServiceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServiceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServiceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServiceProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServiceProperties(document.RootElement, options); } - internal static DeviceProvisioningServiceProperties DeserializeDeviceProvisioningServiceProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServiceProperties DeserializeDeviceProvisioningServiceProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -173,144 +178,142 @@ internal static DeviceProvisioningServiceProperties DeserializeDeviceProvisionin string deviceProvisioningHostName = default; string idScope = default; IList authorizationPolicies = default; - bool? enableDataResidency = default; + bool? isDataResidencyEnabled = default; string portalOperationsHostName = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("state"u8)) + if (prop.NameEquals("state"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - state = new DeviceProvisioningServicesState(property.Value.GetString()); + state = new DeviceProvisioningServicesState(prop.Value.GetString()); continue; } - if (property.NameEquals("publicNetworkAccess"u8)) + if (prop.NameEquals("publicNetworkAccess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - publicNetworkAccess = new DeviceProvisioningServicesPublicNetworkAccess(property.Value.GetString()); + publicNetworkAccess = new DeviceProvisioningServicesPublicNetworkAccess(prop.Value.GetString()); continue; } - if (property.NameEquals("ipFilterRules"u8)) + if (prop.NameEquals("ipFilterRules"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServicesIPFilterRule.DeserializeDeviceProvisioningServicesIPFilterRule(item, options)); } ipFilterRules = array; continue; } - if (property.NameEquals("privateEndpointConnections"u8)) + if (prop.NameEquals("privateEndpointConnections"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(item, options)); } privateEndpointConnections = array; continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - provisioningState = property.Value.GetString(); + provisioningState = prop.Value.GetString(); continue; } - if (property.NameEquals("iotHubs"u8)) + if (prop.NameEquals("iotHubs"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(IotHubDefinitionDescription.DeserializeIotHubDefinitionDescription(item, options)); } iotHubs = array; continue; } - if (property.NameEquals("deviceRegistryNamespace"u8)) + if (prop.NameEquals("deviceRegistryNamespace"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceRegistryNamespace = DeviceRegistryNamespaceDescription.DeserializeDeviceRegistryNamespaceDescription(property.Value, options); + deviceRegistryNamespace = DeviceRegistryNamespaceDescription.DeserializeDeviceRegistryNamespaceDescription(prop.Value, options); continue; } - if (property.NameEquals("allocationPolicy"u8)) + if (prop.NameEquals("allocationPolicy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allocationPolicy = new DeviceProvisioningServicesAllocationPolicy(property.Value.GetString()); + allocationPolicy = new DeviceProvisioningServicesAllocationPolicy(prop.Value.GetString()); continue; } - if (property.NameEquals("serviceOperationsHostName"u8)) + if (prop.NameEquals("serviceOperationsHostName"u8)) { - serviceOperationsHostName = property.Value.GetString(); + serviceOperationsHostName = prop.Value.GetString(); continue; } - if (property.NameEquals("deviceProvisioningHostName"u8)) + if (prop.NameEquals("deviceProvisioningHostName"u8)) { - deviceProvisioningHostName = property.Value.GetString(); + deviceProvisioningHostName = prop.Value.GetString(); continue; } - if (property.NameEquals("idScope"u8)) + if (prop.NameEquals("idScope"u8)) { - idScope = property.Value.GetString(); + idScope = prop.Value.GetString(); continue; } - if (property.NameEquals("authorizationPolicies"u8)) + if (prop.NameEquals("authorizationPolicies"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServicesSharedAccessKey.DeserializeDeviceProvisioningServicesSharedAccessKey(item, options)); } authorizationPolicies = array; continue; } - if (property.NameEquals("enableDataResidency"u8)) + if (prop.NameEquals("enableDataResidency"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - enableDataResidency = property.Value.GetBoolean(); + isDataResidencyEnabled = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("portalOperationsHostName"u8)) + if (prop.NameEquals("portalOperationsHostName"u8)) { - portalOperationsHostName = property.Value.GetString(); + portalOperationsHostName = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new DeviceProvisioningServiceProperties( state, publicNetworkAccess, @@ -324,15 +327,18 @@ internal static DeviceProvisioningServiceProperties DeserializeDeviceProvisionin deviceProvisioningHostName, idScope, authorizationPolicies ?? new ChangeTrackingList(), - enableDataResidency, + isDataResidencyEnabled, portalOperationsHostName, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -342,15 +348,20 @@ BinaryData IPersistableModel.Write(ModelRea } } - DeviceProvisioningServiceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServiceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServiceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServiceProperties(document.RootElement, options); } default: @@ -358,6 +369,7 @@ DeviceProvisioningServiceProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.cs index 06dc45795a5b..a7b0814471a9 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServiceProperties.cs @@ -7,48 +7,20 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// the service specific properties of a provisioning service, including keys, linked iot hubs, current state, and system generated properties such as hostname and idScope. public partial class DeviceProvisioningServiceProperties { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DeviceProvisioningServiceProperties() { - IPFilterRules = new ChangeTrackingList(); + IpFilterRules = new ChangeTrackingList(); PrivateEndpointConnections = new ChangeTrackingList(); IotHubs = new ChangeTrackingList(); AuthorizationPolicies = new ChangeTrackingList(); @@ -72,12 +44,12 @@ public DeviceProvisioningServiceProperties() /// Indicates if the DPS instance has Data Residency enabled, removing the cross geo-pair disaster recovery. /// /// Portal endpoint to enable CORS for this provisioning service. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServiceProperties(DeviceProvisioningServicesState? state, DeviceProvisioningServicesPublicNetworkAccess? publicNetworkAccess, IList ipFilterRules, IList privateEndpointConnections, string provisioningState, IList iotHubs, DeviceRegistryNamespaceDescription deviceRegistryNamespace, DeviceProvisioningServicesAllocationPolicy? allocationPolicy, string serviceOperationsHostName, string deviceProvisioningHostName, string idScope, IList authorizationPolicies, bool? isDataResidencyEnabled, string portalOperationsHostName, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServiceProperties(DeviceProvisioningServicesState? state, DeviceProvisioningServicesPublicNetworkAccess? publicNetworkAccess, IList ipFilterRules, IList privateEndpointConnections, string provisioningState, IList iotHubs, DeviceRegistryNamespaceDescription deviceRegistryNamespace, DeviceProvisioningServicesAllocationPolicy? allocationPolicy, string serviceOperationsHostName, string deviceProvisioningHostName, string idScope, IList authorizationPolicies, bool? isDataResidencyEnabled, string portalOperationsHostName, IDictionary additionalBinaryDataProperties) { State = state; PublicNetworkAccess = publicNetworkAccess; - IPFilterRules = ipFilterRules; + IpFilterRules = ipFilterRules; PrivateEndpointConnections = privateEndpointConnections; ProvisioningState = provisioningState; IotHubs = iotHubs; @@ -89,38 +61,51 @@ internal DeviceProvisioningServiceProperties(DeviceProvisioningServicesState? st AuthorizationPolicies = authorizationPolicies; IsDataResidencyEnabled = isDataResidencyEnabled; PortalOperationsHostName = portalOperationsHostName; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Current state of the provisioning service. public DeviceProvisioningServicesState? State { get; set; } + /// Whether requests from Public Network are allowed. public DeviceProvisioningServicesPublicNetworkAccess? PublicNetworkAccess { get; set; } + /// The IP filter rules. - public IList IPFilterRules { get; } + public IList IpFilterRules { get; } + /// Private endpoint connections created on this IotHub. public IList PrivateEndpointConnections { get; } + /// The ARM provisioning state of the provisioning service. public string ProvisioningState { get; set; } + /// List of IoT hubs associated with this provisioning service. public IList IotHubs { get; } + /// The Device Registry namespace that is linked to the provisioning service. public DeviceRegistryNamespaceDescription DeviceRegistryNamespace { get; set; } + /// Allocation policy to be used by this provisioning service. public DeviceProvisioningServicesAllocationPolicy? AllocationPolicy { get; set; } + /// Service endpoint for provisioning service. public string ServiceOperationsHostName { get; } + /// Device endpoint for this provisioning service. public string DeviceProvisioningHostName { get; } + /// Unique identifier of this provisioning service. public string IdScope { get; } + /// List of authorization keys for a provisioning service. public IList AuthorizationPolicies { get; } + /// /// Optional. /// Indicates if the DPS instance has Data Residency enabled, removing the cross geo-pair disaster recovery. /// public bool? IsDataResidencyEnabled { get; set; } + /// Portal endpoint to enable CORS for this provisioning service. public string PortalOperationsHostName { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAccessKeyRight.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAccessKeyRight.cs index 0060e9f444d4..57cc6fb5c9a8 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAccessKeyRight.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAccessKeyRight.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,14 +15,6 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceProvisioningServicesAccessKeyRight : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DeviceProvisioningServicesAccessKeyRight(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - private const string ServiceConfigValue = "ServiceConfig"; private const string EnrollmentReadValue = "EnrollmentRead"; private const string EnrollmentWriteValue = "EnrollmentWrite"; @@ -29,35 +22,64 @@ public DeviceProvisioningServicesAccessKeyRight(string value) private const string RegistrationStatusReadValue = "RegistrationStatusRead"; private const string RegistrationStatusWriteValue = "RegistrationStatusWrite"; - /// ServiceConfig. + /// Initializes a new instance of . + /// The value. + /// is null. + public DeviceProvisioningServicesAccessKeyRight(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the ServiceConfig. public static DeviceProvisioningServicesAccessKeyRight ServiceConfig { get; } = new DeviceProvisioningServicesAccessKeyRight(ServiceConfigValue); - /// EnrollmentRead. + + /// Gets the EnrollmentRead. public static DeviceProvisioningServicesAccessKeyRight EnrollmentRead { get; } = new DeviceProvisioningServicesAccessKeyRight(EnrollmentReadValue); - /// EnrollmentWrite. + + /// Gets the EnrollmentWrite. public static DeviceProvisioningServicesAccessKeyRight EnrollmentWrite { get; } = new DeviceProvisioningServicesAccessKeyRight(EnrollmentWriteValue); - /// DeviceConnect. + + /// Gets the DeviceConnect. public static DeviceProvisioningServicesAccessKeyRight DeviceConnect { get; } = new DeviceProvisioningServicesAccessKeyRight(DeviceConnectValue); - /// RegistrationStatusRead. + + /// Gets the RegistrationStatusRead. public static DeviceProvisioningServicesAccessKeyRight RegistrationStatusRead { get; } = new DeviceProvisioningServicesAccessKeyRight(RegistrationStatusReadValue); - /// RegistrationStatusWrite. + + /// Gets the RegistrationStatusWrite. public static DeviceProvisioningServicesAccessKeyRight RegistrationStatusWrite { get; } = new DeviceProvisioningServicesAccessKeyRight(RegistrationStatusWriteValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesAccessKeyRight left, DeviceProvisioningServicesAccessKeyRight right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesAccessKeyRight left, DeviceProvisioningServicesAccessKeyRight right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesAccessKeyRight(string value) => new DeviceProvisioningServicesAccessKeyRight(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesAccessKeyRight?(string value) => value == null ? null : new DeviceProvisioningServicesAccessKeyRight(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesAccessKeyRight other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesAccessKeyRight 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAllocationPolicy.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAllocationPolicy.cs index da4e9df21e98..8078a5f87b99 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAllocationPolicy.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesAllocationPolicy.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,41 +15,59 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceProvisioningServicesAllocationPolicy : IEquatable { private readonly string _value; + private const string HashedValue = "Hashed"; + private const string GeoLatencyValue = "GeoLatency"; + private const string StaticValue = "Static"; /// Initializes a new instance of . + /// The value. /// is null. public DeviceProvisioningServicesAllocationPolicy(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string HashedValue = "Hashed"; - private const string GeoLatencyValue = "GeoLatency"; - private const string StaticValue = "Static"; + _value = value; + } - /// Hashed. + /// Gets the Hashed. public static DeviceProvisioningServicesAllocationPolicy Hashed { get; } = new DeviceProvisioningServicesAllocationPolicy(HashedValue); - /// GeoLatency. + + /// Gets the GeoLatency. public static DeviceProvisioningServicesAllocationPolicy GeoLatency { get; } = new DeviceProvisioningServicesAllocationPolicy(GeoLatencyValue); - /// Static. + + /// Gets the Static. public static DeviceProvisioningServicesAllocationPolicy Static { get; } = new DeviceProvisioningServicesAllocationPolicy(StaticValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesAllocationPolicy left, DeviceProvisioningServicesAllocationPolicy right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesAllocationPolicy left, DeviceProvisioningServicesAllocationPolicy right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesAllocationPolicy(string value) => new DeviceProvisioningServicesAllocationPolicy(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesAllocationPolicy?(string value) => value == null ? null : new DeviceProvisioningServicesAllocationPolicy(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesAllocationPolicy other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesAllocationPolicy 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.Serialization.cs index 0d24e6f93c17..dca1db8f7c27 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesCertificateProperties : IUtf8JsonSerializable, IJsonModel + /// The description of an X509 CA Certificate. + public partial class DeviceProvisioningServicesCertificateProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonW /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesCertificateProperties)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Subject)) { writer.WritePropertyName("subject"u8); @@ -48,9 +48,9 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("thumbprint"u8); #if NET6_0_OR_GREATER - writer.WriteRawValue(Thumbprint); + writer.WriteRawValue(Thumbprint); #else - using (JsonDocument document = JsonDocument.Parse(Thumbprint, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(Thumbprint)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -65,9 +65,9 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("certificate"u8); #if NET6_0_OR_GREATER - writer.WriteRawValue(Certificate); + writer.WriteRawValue(Certificate); #else - using (JsonDocument document = JsonDocument.Parse(Certificate, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(Certificate)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -83,15 +83,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("updated"u8); writer.WriteStringValue(UpdatedOn.Value, "O"); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -100,117 +100,123 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesCertificateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesCertificateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesCertificateProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesCertificateProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesCertificateProperties(document.RootElement, options); } - internal static DeviceProvisioningServicesCertificateProperties DeserializeDeviceProvisioningServicesCertificateProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesCertificateProperties DeserializeDeviceProvisioningServicesCertificateProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string subject = default; - DateTimeOffset? expiry = default; + DateTimeOffset? expireOn = default; BinaryData thumbprint = default; bool? isVerified = default; BinaryData certificate = default; - DateTimeOffset? created = default; - DateTimeOffset? updated = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DateTimeOffset? createdOn = default; + DateTimeOffset? updatedOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("subject"u8)) + if (prop.NameEquals("subject"u8)) { - subject = property.Value.GetString(); + subject = prop.Value.GetString(); continue; } - if (property.NameEquals("expiry"u8)) + if (prop.NameEquals("expiry"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expiry = property.Value.GetDateTimeOffset("O"); + expireOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("thumbprint"u8)) + if (prop.NameEquals("thumbprint"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - thumbprint = BinaryData.FromString(property.Value.GetRawText()); + thumbprint = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (property.NameEquals("isVerified"u8)) + if (prop.NameEquals("isVerified"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isVerified = property.Value.GetBoolean(); + isVerified = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("certificate"u8)) + if (prop.NameEquals("certificate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - certificate = BinaryData.FromString(property.Value.GetRawText()); + certificate = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (property.NameEquals("created"u8)) + if (prop.NameEquals("created"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - created = property.Value.GetDateTimeOffset("O"); + createdOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("updated"u8)) + if (prop.NameEquals("updated"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - updated = property.Value.GetDateTimeOffset("O"); + updatedOn = prop.Value.GetDateTimeOffset("O"); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new DeviceProvisioningServicesCertificateProperties( subject, - expiry, + expireOn, thumbprint, isVerified, certificate, - created, - updated, - serializedAdditionalRawData); + createdOn, + updatedOn, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -220,15 +226,20 @@ BinaryData IPersistableModel.Wr } } - DeviceProvisioningServicesCertificateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesCertificateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesCertificateProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesCertificateProperties(document.RootElement, options); } default: @@ -236,6 +247,7 @@ DeviceProvisioningServicesCertificateProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.cs index ea7b1f528405..babe9a18a8e9 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificateProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using System.Text.Json; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The description of an X509 CA Certificate. public partial class DeviceProvisioningServicesCertificateProperties { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DeviceProvisioningServicesCertificateProperties() @@ -58,8 +30,8 @@ public DeviceProvisioningServicesCertificateProperties() /// base-64 representation of X509 certificate .cer file or just .pem file content. /// The certificate's creation date and time. /// The certificate's last update date and time. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesCertificateProperties(string subject, DateTimeOffset? expireOn, BinaryData thumbprint, bool? isVerified, BinaryData certificate, DateTimeOffset? createdOn, DateTimeOffset? updatedOn, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesCertificateProperties(string subject, DateTimeOffset? expireOn, BinaryData thumbprint, bool? isVerified, BinaryData certificate, DateTimeOffset? createdOn, DateTimeOffset? updatedOn, IDictionary additionalBinaryDataProperties) { Subject = subject; ExpireOn = expireOn; @@ -68,79 +40,77 @@ internal DeviceProvisioningServicesCertificateProperties(string subject, DateTim Certificate = certificate; CreatedOn = createdOn; UpdatedOn = updatedOn; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The certificate's subject name. public string Subject { get; } + /// The certificate's expiration date and time. public DateTimeOffset? ExpireOn { get; } + /// /// The certificate's thumbprint. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . /// /// Examples: /// /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". /// /// - /// BinaryData.FromString("\"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.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. /// /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. /// /// /// /// public BinaryData Thumbprint { get; } + /// Determines whether certificate has been verified. public bool? IsVerified { get; set; } + /// /// base-64 representation of X509 certificate .cer file or just .pem file content. - /// - /// To assign an object to this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . /// /// Examples: /// /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". /// /// - /// BinaryData.FromString("\"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.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. /// /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. /// /// /// /// public BinaryData Certificate { get; set; } + /// The certificate's creation date and time. public DateTimeOffset? CreatedOn { get; } + /// The certificate's last update date and time. public DateTimeOffset? UpdatedOn { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificatePurpose.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificatePurpose.cs index 0d7c640513cc..aeab448d3a59 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificatePurpose.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesCertificatePurpose.cs @@ -7,45 +7,63 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - /// The DeviceProvisioningServicesCertificatePurpose. + /// public readonly partial struct DeviceProvisioningServicesCertificatePurpose : IEquatable { private readonly string _value; + private const string ClientAuthenticationValue = "clientAuthentication"; + private const string ServerAuthenticationValue = "serverAuthentication"; /// Initializes a new instance of . + /// The value. /// is null. public DeviceProvisioningServicesCertificatePurpose(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string ClientAuthenticationValue = "clientAuthentication"; - private const string ServerAuthenticationValue = "serverAuthentication"; + _value = value; + } - /// clientAuthentication. + /// Gets the ClientAuthentication. public static DeviceProvisioningServicesCertificatePurpose ClientAuthentication { get; } = new DeviceProvisioningServicesCertificatePurpose(ClientAuthenticationValue); - /// serverAuthentication. + + /// Gets the ServerAuthentication. public static DeviceProvisioningServicesCertificatePurpose ServerAuthentication { get; } = new DeviceProvisioningServicesCertificatePurpose(ServerAuthenticationValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesCertificatePurpose left, DeviceProvisioningServicesCertificatePurpose right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesCertificatePurpose left, DeviceProvisioningServicesCertificatePurpose right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesCertificatePurpose(string value) => new DeviceProvisioningServicesCertificatePurpose(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesCertificatePurpose?(string value) => value == null ? null : new DeviceProvisioningServicesCertificatePurpose(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesCertificatePurpose other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesCertificatePurpose 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterActionType.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterActionType.Serialization.cs index 80dd00cdec26..f3505903f031 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterActionType.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterActionType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models { internal static partial class DeviceProvisioningServicesIPFilterActionTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DeviceProvisioningServicesIPFilterActionType value) => value switch { DeviceProvisioningServicesIPFilterActionType.Accept => "Accept", @@ -18,10 +19,17 @@ internal static partial class DeviceProvisioningServicesIPFilterActionTypeExtens _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DeviceProvisioningServicesIPFilterActionType value.") }; + /// The value to deserialize. public static DeviceProvisioningServicesIPFilterActionType ToDeviceProvisioningServicesIPFilterActionType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Accept")) return DeviceProvisioningServicesIPFilterActionType.Accept; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Reject")) return DeviceProvisioningServicesIPFilterActionType.Reject; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Accept")) + { + return DeviceProvisioningServicesIPFilterActionType.Accept; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Reject")) + { + return DeviceProvisioningServicesIPFilterActionType.Reject; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DeviceProvisioningServicesIPFilterActionType value."); } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.Serialization.cs index 23cab9167eb6..cae60a934f6d 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesIPFilterRule : IUtf8JsonSerializable, IJsonModel + /// The IP filter rules for a provisioning Service. + public partial class DeviceProvisioningServicesIPFilterRule : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServicesIPFilterRule() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,32 +34,31 @@ void IJsonModel.Write(Utf8JsonWriter wri /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesIPFilterRule)} does not support writing '{format}' format."); } - writer.WritePropertyName("filterName"u8); writer.WriteStringValue(FilterName); writer.WritePropertyName("action"u8); writer.WriteStringValue(Action.ToSerialString()); writer.WritePropertyName("ipMask"u8); - writer.WriteStringValue(IPMask); + writer.WriteStringValue(IpMask); if (Optional.IsDefined(Target)) { writer.WritePropertyName("target"u8); writer.WriteStringValue(Target.Value.ToSerialString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -62,22 +67,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesIPFilterRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesIPFilterRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesIPFilterRule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesIPFilterRule)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesIPFilterRule(document.RootElement, options); } - internal static DeviceProvisioningServicesIPFilterRule DeserializeDeviceProvisioningServicesIPFilterRule(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesIPFilterRule DeserializeDeviceProvisioningServicesIPFilterRule(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -86,47 +96,48 @@ internal static DeviceProvisioningServicesIPFilterRule DeserializeDeviceProvisio DeviceProvisioningServicesIPFilterActionType action = default; string ipMask = default; DeviceProvisioningServicesIPFilterTargetType? target = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filterName"u8)) + if (prop.NameEquals("filterName"u8)) { - filterName = property.Value.GetString(); + filterName = prop.Value.GetString(); continue; } - if (property.NameEquals("action"u8)) + if (prop.NameEquals("action"u8)) { - action = property.Value.GetString().ToDeviceProvisioningServicesIPFilterActionType(); + action = prop.Value.GetString().ToDeviceProvisioningServicesIPFilterActionType(); continue; } - if (property.NameEquals("ipMask"u8)) + if (prop.NameEquals("ipMask"u8)) { - ipMask = property.Value.GetString(); + ipMask = prop.Value.GetString(); continue; } - if (property.NameEquals("target"u8)) + if (prop.NameEquals("target"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - target = property.Value.GetString().ToDeviceProvisioningServicesIPFilterTargetType(); + target = prop.Value.GetString().ToDeviceProvisioningServicesIPFilterTargetType(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesIPFilterRule(filterName, action, ipMask, target, serializedAdditionalRawData); + return new DeviceProvisioningServicesIPFilterRule(filterName, action, ipMask, target, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -136,15 +147,20 @@ BinaryData IPersistableModel.Write(Model } } - DeviceProvisioningServicesIPFilterRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesIPFilterRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesIPFilterRule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesIPFilterRule(document.RootElement, options); } default: @@ -152,6 +168,7 @@ DeviceProvisioningServicesIPFilterRule IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.cs index 15b8f87c2b39..6f4e5b71fec0 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterRule.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The IP filter rules for a provisioning Service. public partial class DeviceProvisioningServicesIPFilterRule { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The name of the IP filter rule. @@ -57,7 +29,7 @@ public DeviceProvisioningServicesIPFilterRule(string filterName, DeviceProvision FilterName = filterName; Action = action; - IPMask = ipMask; + IpMask = ipMask; } /// Initializes a new instance of . @@ -65,27 +37,25 @@ public DeviceProvisioningServicesIPFilterRule(string filterName, DeviceProvision /// The desired action for requests captured by this rule. /// A string that contains the IP address range in CIDR notation for the rule. /// Target for requests captured by this rule. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesIPFilterRule(string filterName, DeviceProvisioningServicesIPFilterActionType action, string ipMask, DeviceProvisioningServicesIPFilterTargetType? target, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesIPFilterRule(string filterName, DeviceProvisioningServicesIPFilterActionType action, string ipMask, DeviceProvisioningServicesIPFilterTargetType? target, IDictionary additionalBinaryDataProperties) { FilterName = filterName; Action = action; - IPMask = ipMask; + IpMask = ipMask; Target = target; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServicesIPFilterRule() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the IP filter rule. public string FilterName { get; set; } + /// The desired action for requests captured by this rule. public DeviceProvisioningServicesIPFilterActionType Action { get; set; } + /// A string that contains the IP address range in CIDR notation for the rule. - public string IPMask { get; set; } + public string IpMask { get; set; } + /// Target for requests captured by this rule. public DeviceProvisioningServicesIPFilterTargetType? Target { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.Serialization.cs index 8188e210624f..92aeb79dd340 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models { internal static partial class DeviceProvisioningServicesIPFilterTargetTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DeviceProvisioningServicesIPFilterTargetType value) => value switch { DeviceProvisioningServicesIPFilterTargetType.All => "all", @@ -19,11 +20,21 @@ internal static partial class DeviceProvisioningServicesIPFilterTargetTypeExtens _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DeviceProvisioningServicesIPFilterTargetType value.") }; + /// The value to deserialize. public static DeviceProvisioningServicesIPFilterTargetType ToDeviceProvisioningServicesIPFilterTargetType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "all")) return DeviceProvisioningServicesIPFilterTargetType.All; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "serviceApi")) return DeviceProvisioningServicesIPFilterTargetType.ServiceApi; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "deviceApi")) return DeviceProvisioningServicesIPFilterTargetType.DeviceApi; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "all")) + { + return DeviceProvisioningServicesIPFilterTargetType.All; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "serviceApi")) + { + return DeviceProvisioningServicesIPFilterTargetType.ServiceApi; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "deviceApi")) + { + return DeviceProvisioningServicesIPFilterTargetType.DeviceApi; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DeviceProvisioningServicesIPFilterTargetType value."); } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.cs index 5396dcdfb755..aca64bd74c47 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesIPFilterTargetType.cs @@ -10,11 +10,11 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// Target for requests captured by this rule. public enum DeviceProvisioningServicesIPFilterTargetType { - /// all. + /// All. All, - /// serviceApi. + /// ServiceApi. ServiceApi, - /// deviceApi. + /// DeviceApi. DeviceApi } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.Serialization.cs index 170727ab18c3..c9e87687b8ed 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesNameAvailabilityContent : IUtf8JsonSerializable, IJsonModel + /// Input values for operation results call. + public partial class DeviceProvisioningServicesNameAvailabilityContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServicesNameAvailabilityContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,23 +35,22 @@ void IJsonModel.Write(Utf8Jso /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesNameAvailabilityContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -53,49 +59,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesNameAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesNameAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesNameAvailabilityContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesNameAvailabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesNameAvailabilityContent(document.RootElement, options); } - internal static DeviceProvisioningServicesNameAvailabilityContent DeserializeDeviceProvisioningServicesNameAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesNameAvailabilityContent DeserializeDeviceProvisioningServicesNameAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesNameAvailabilityContent(name, serializedAdditionalRawData); + return new DeviceProvisioningServicesNameAvailabilityContent(name, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -105,15 +117,20 @@ BinaryData IPersistableModel. } } - DeviceProvisioningServicesNameAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesNameAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesNameAvailabilityContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesNameAvailabilityContent(document.RootElement, options); } default: @@ -121,6 +138,19 @@ DeviceProvisioningServicesNameAvailabilityContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DeviceProvisioningServicesNameAvailabilityContent deviceProvisioningServicesNameAvailabilityContent) + { + if (deviceProvisioningServicesNameAvailabilityContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(deviceProvisioningServicesNameAvailabilityContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.cs index 2a9fd1f6c54e..a02946c6db46 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityContent.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// Input values for operation results call. public partial class DeviceProvisioningServicesNameAvailabilityContent { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The name of the Provisioning Service to check. @@ -57,16 +29,11 @@ public DeviceProvisioningServicesNameAvailabilityContent(string name) /// Initializes a new instance of . /// The name of the Provisioning Service to check. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesNameAvailabilityContent(string name, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesNameAvailabilityContent(string name, IDictionary additionalBinaryDataProperties) { Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServicesNameAvailabilityContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the Provisioning Service to check. diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.Serialization.cs index 45b95f7f4ee9..ce32475e0be1 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesNameAvailabilityResult : IUtf8JsonSerializable, IJsonModel + /// Description of name availability. + public partial class DeviceProvisioningServicesNameAvailabilityResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8Json /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesNameAvailabilityResult)} does not support writing '{format}' format."); } - if (Optional.IsDefined(IsNameAvailable)) { writer.WritePropertyName("nameAvailable"u8); @@ -49,15 +50,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,69 +67,75 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesNameAvailabilityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesNameAvailabilityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesNameAvailabilityResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesNameAvailabilityResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesNameAvailabilityResult(document.RootElement, options); } - internal static DeviceProvisioningServicesNameAvailabilityResult DeserializeDeviceProvisioningServicesNameAvailabilityResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesNameAvailabilityResult DeserializeDeviceProvisioningServicesNameAvailabilityResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - bool? nameAvailable = default; + bool? isNameAvailable = default; DeviceProvisioningServicesNameUnavailableReason? reason = default; string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("nameAvailable"u8)) + if (prop.NameEquals("nameAvailable"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nameAvailable = property.Value.GetBoolean(); + isNameAvailable = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("reason"u8)) + if (prop.NameEquals("reason"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reason = new DeviceProvisioningServicesNameUnavailableReason(property.Value.GetString()); + reason = new DeviceProvisioningServicesNameUnavailableReason(prop.Value.GetString()); continue; } - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesNameAvailabilityResult(nameAvailable, reason, message, serializedAdditionalRawData); + return new DeviceProvisioningServicesNameAvailabilityResult(isNameAvailable, reason, message, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -138,15 +145,20 @@ BinaryData IPersistableModel.W } } - DeviceProvisioningServicesNameAvailabilityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesNameAvailabilityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesNameAvailabilityResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesNameAvailabilityResult(document.RootElement, options); } default: @@ -154,6 +166,14 @@ DeviceProvisioningServicesNameAvailabilityResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static DeviceProvisioningServicesNameAvailabilityResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeviceProvisioningServicesNameAvailabilityResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.cs index 6f8ec86c5d0d..0891745ddd8e 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameAvailabilityResult.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// Description of name availability. public partial class DeviceProvisioningServicesNameAvailabilityResult { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal DeviceProvisioningServicesNameAvailabilityResult() @@ -54,19 +25,21 @@ internal DeviceProvisioningServicesNameAvailabilityResult() /// specifies if a name is available or not. /// specifies the reason a name is unavailable. /// message containing a detailed reason name is unavailable. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesNameAvailabilityResult(bool? isNameAvailable, DeviceProvisioningServicesNameUnavailableReason? reason, string message, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesNameAvailabilityResult(bool? isNameAvailable, DeviceProvisioningServicesNameUnavailableReason? reason, string message, IDictionary additionalBinaryDataProperties) { IsNameAvailable = isNameAvailable; Reason = reason; Message = message; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// specifies if a name is available or not. public bool? IsNameAvailable { get; } + /// specifies the reason a name is unavailable. public DeviceProvisioningServicesNameUnavailableReason? Reason { get; } + /// message containing a detailed reason name is unavailable. public string Message { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameUnavailableReason.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameUnavailableReason.cs index 9eac13f907bf..daa211c06285 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameUnavailableReason.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesNameUnavailableReason.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceProvisioningServicesNameUnavailableReason : IEquatable { private readonly string _value; + private const string InvalidValue = "Invalid"; + private const string AlreadyExistsValue = "AlreadyExists"; /// Initializes a new instance of . + /// The value. /// is null. public DeviceProvisioningServicesNameUnavailableReason(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string InvalidValue = "Invalid"; - private const string AlreadyExistsValue = "AlreadyExists"; + _value = value; + } - /// Invalid. + /// Gets the Invalid. public static DeviceProvisioningServicesNameUnavailableReason Invalid { get; } = new DeviceProvisioningServicesNameUnavailableReason(InvalidValue); - /// AlreadyExists. + + /// Gets the AlreadyExists. public static DeviceProvisioningServicesNameUnavailableReason AlreadyExists { get; } = new DeviceProvisioningServicesNameUnavailableReason(AlreadyExistsValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesNameUnavailableReason left, DeviceProvisioningServicesNameUnavailableReason right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesNameUnavailableReason left, DeviceProvisioningServicesNameUnavailableReason right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesNameUnavailableReason(string value) => new DeviceProvisioningServicesNameUnavailableReason(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesNameUnavailableReason?(string value) => value == null ? null : new DeviceProvisioningServicesNameUnavailableReason(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesNameUnavailableReason other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesNameUnavailableReason 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpoint.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpoint.Serialization.cs new file mode 100644 index 000000000000..6f71fe0d1aed --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpoint.Serialization.cs @@ -0,0 +1,141 @@ +// 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.ResourceManager.DeviceProvisioningServices; + +namespace Azure.ResourceManager.DeviceProvisioningServices.Models +{ + /// The private endpoint property of a private endpoint connection. + internal partial class DeviceProvisioningServicesPrivateEndpoint : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + 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) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpoint)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateEndpoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateEndpoint JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpoint)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeviceProvisioningServicesPrivateEndpoint(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesPrivateEndpoint DeserializeDeviceProvisioningServicesPrivateEndpoint(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DeviceProvisioningServicesPrivateEndpoint(id, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDeviceProvisioningServicesContext.Default); + default: + throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpoint)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateEndpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateEndpoint PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDeviceProvisioningServicesPrivateEndpoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpoint)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpoint.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpoint.cs new file mode 100644 index 000000000000..4983779fe803 --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpoint.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DeviceProvisioningServices.Models +{ + /// The private endpoint property of a private endpoint connection. + internal partial class DeviceProvisioningServicesPrivateEndpoint + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public DeviceProvisioningServicesPrivateEndpoint() + { + } + + /// Initializes a new instance of . + /// The resource identifier. + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesPrivateEndpoint(string id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The resource identifier. + public string Id { get; } + } +} diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.Serialization.cs index 4034d9decd41..7c91a62c49ae 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.Serialization.cs @@ -8,17 +8,21 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Text; using System.Text.Json; -using Azure.Core; -using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesPrivateEndpointConnectionProperties : IUtf8JsonSerializable, IJsonModel + /// The properties of a private endpoint connection. + public partial class DeviceProvisioningServicesPrivateEndpointConnectionProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServicesPrivateEndpointConnectionProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -30,28 +34,27 @@ void IJsonModel.W /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpointConnectionProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(PrivateEndpoint)) { writer.WritePropertyName("privateEndpoint"u8); - ((IJsonModel)PrivateEndpoint).Write(writer, options); + writer.WriteObjectValue(PrivateEndpoint, options); } writer.WritePropertyName("privateLinkServiceConnectionState"u8); writer.WriteObjectValue(ConnectionState, options); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -60,59 +63,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesPrivateEndpointConnectionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateEndpointConnectionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateEndpointConnectionProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateEndpointConnectionProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesPrivateEndpointConnectionProperties(document.RootElement, options); } - internal static DeviceProvisioningServicesPrivateEndpointConnectionProperties DeserializeDeviceProvisioningServicesPrivateEndpointConnectionProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesPrivateEndpointConnectionProperties DeserializeDeviceProvisioningServicesPrivateEndpointConnectionProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - SubResource privateEndpoint = default; - DeviceProvisioningServicesPrivateLinkServiceConnectionState privateLinkServiceConnectionState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DeviceProvisioningServicesPrivateEndpoint privateEndpoint = default; + DeviceProvisioningServicesPrivateLinkServiceConnectionState connectionState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("privateEndpoint"u8)) + if (prop.NameEquals("privateEndpoint"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - privateEndpoint = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDeviceProvisioningServicesContext.Default); + privateEndpoint = DeviceProvisioningServicesPrivateEndpoint.DeserializeDeviceProvisioningServicesPrivateEndpoint(prop.Value, options); continue; } - if (property.NameEquals("privateLinkServiceConnectionState"u8)) + if (prop.NameEquals("privateLinkServiceConnectionState"u8)) { - privateLinkServiceConnectionState = DeviceProvisioningServicesPrivateLinkServiceConnectionState.DeserializeDeviceProvisioningServicesPrivateLinkServiceConnectionState(property.Value, options); + connectionState = DeviceProvisioningServicesPrivateLinkServiceConnectionState.DeserializeDeviceProvisioningServicesPrivateLinkServiceConnectionState(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesPrivateEndpointConnectionProperties(privateEndpoint, privateLinkServiceConnectionState, serializedAdditionalRawData); + return new DeviceProvisioningServicesPrivateEndpointConnectionProperties(privateEndpoint, connectionState, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +131,20 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateEndpointConnectionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateEndpointConnectionProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesPrivateEndpointConnectionProperties(document.RootElement, options); } default: @@ -138,6 +152,7 @@ DeviceProvisioningServicesPrivateEndpointConnectionProperties IPersistableModel< } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.cs index 9fc3feb7e9d8..10a937f8027f 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateEndpointConnectionProperties.cs @@ -7,45 +7,15 @@ using System; using System.Collections.Generic; -using Azure.Core; -using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The properties of a private endpoint connection. public partial class DeviceProvisioningServicesPrivateEndpointConnectionProperties { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The current state of a private endpoint connection. @@ -60,28 +30,27 @@ public DeviceProvisioningServicesPrivateEndpointConnectionProperties(DeviceProvi /// Initializes a new instance of . /// The private endpoint property of a private endpoint connection. /// The current state of a private endpoint connection. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesPrivateEndpointConnectionProperties(SubResource privateEndpoint, DeviceProvisioningServicesPrivateLinkServiceConnectionState connectionState, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesPrivateEndpointConnectionProperties(DeviceProvisioningServicesPrivateEndpoint privateEndpoint, DeviceProvisioningServicesPrivateLinkServiceConnectionState connectionState, IDictionary additionalBinaryDataProperties) { PrivateEndpoint = privateEndpoint; ConnectionState = connectionState; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServicesPrivateEndpointConnectionProperties() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The private endpoint property of a private endpoint connection. - internal SubResource PrivateEndpoint { get; set; } - /// Gets Id. - public ResourceIdentifier PrivateEndpointId - { - get => PrivateEndpoint is null ? default : PrivateEndpoint.Id; - } + internal DeviceProvisioningServicesPrivateEndpoint PrivateEndpoint { get; set; } /// The current state of a private endpoint connection. public DeviceProvisioningServicesPrivateLinkServiceConnectionState ConnectionState { get; set; } + + /// The resource identifier. + public string PrivateEndpointId + { + get + { + return PrivateEndpoint is null ? default : PrivateEndpoint.Id; + } + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.Serialization.cs index c712b48368d7..7114062664b6 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesPrivateLinkResourceProperties : IUtf8JsonSerializable, IJsonModel + /// The properties for a group information object. + public partial class DeviceProvisioningServicesPrivateLinkResourceProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(U /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateLinkResourceProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(GroupId)) { writer.WritePropertyName("groupId"u8); @@ -43,8 +43,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("requiredMembers"u8); writer.WriteStartArray(); - foreach (var item in RequiredMembers) + foreach (string item in RequiredMembers) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -53,21 +58,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("requiredZoneNames"u8); writer.WriteStartArray(); - foreach (var item in RequiredZoneNames) + foreach (string item in RequiredZoneNames) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -76,22 +86,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateLinkResourceProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateLinkResourceProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesPrivateLinkResourceProperties(document.RootElement, options); } - internal static DeviceProvisioningServicesPrivateLinkResourceProperties DeserializeDeviceProvisioningServicesPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesPrivateLinkResourceProperties DeserializeDeviceProvisioningServicesPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -99,56 +114,71 @@ internal static DeviceProvisioningServicesPrivateLinkResourceProperties Deserial string groupId = default; IReadOnlyList requiredMembers = default; IReadOnlyList requiredZoneNames = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("groupId"u8)) + if (prop.NameEquals("groupId"u8)) { - groupId = property.Value.GetString(); + groupId = prop.Value.GetString(); continue; } - if (property.NameEquals("requiredMembers"u8)) + if (prop.NameEquals("requiredMembers"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } requiredMembers = array; continue; } - if (property.NameEquals("requiredZoneNames"u8)) + if (prop.NameEquals("requiredZoneNames"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } requiredZoneNames = array; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesPrivateLinkResourceProperties(groupId, requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new DeviceProvisioningServicesPrivateLinkResourceProperties(groupId, requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -158,15 +188,20 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateLinkResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateLinkResourceProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesPrivateLinkResourceProperties(document.RootElement, options); } default: @@ -174,6 +209,7 @@ DeviceProvisioningServicesPrivateLinkResourceProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.cs index 4af2ba7d3fb0..71a27b10f047 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkResourceProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The properties for a group information object. public partial class DeviceProvisioningServicesPrivateLinkResourceProperties { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal DeviceProvisioningServicesPrivateLinkResourceProperties() @@ -56,19 +28,21 @@ internal DeviceProvisioningServicesPrivateLinkResourceProperties() /// The group id. /// The required members for a specific group id. /// The required DNS zones for a specific group id. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesPrivateLinkResourceProperties(string groupId, IReadOnlyList requiredMembers, IReadOnlyList requiredZoneNames, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesPrivateLinkResourceProperties(string groupId, IReadOnlyList requiredMembers, IReadOnlyList requiredZoneNames, IDictionary additionalBinaryDataProperties) { GroupId = groupId; RequiredMembers = requiredMembers; RequiredZoneNames = requiredZoneNames; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The group id. public string GroupId { get; } + /// The required members for a specific group id. public IReadOnlyList RequiredMembers { get; } + /// The required DNS zones for a specific group id. public IReadOnlyList RequiredZoneNames { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.Serialization.cs index d4cad7ade098..d25da4a1f66d 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesPrivateLinkServiceConnectionState : IUtf8JsonSerializable, IJsonModel + /// The current state of a private endpoint connection. + public partial class DeviceProvisioningServicesPrivateLinkServiceConnectionState : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServicesPrivateLinkServiceConnectionState() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Wri /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateLinkServiceConnectionState)} does not support writing '{format}' format."); } - writer.WritePropertyName("status"u8); writer.WriteStringValue(Status.ToString()); writer.WritePropertyName("description"u8); @@ -43,15 +48,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("actionsRequired"u8); writer.WriteStringValue(ActionsRequired); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -60,22 +65,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesPrivateLinkServiceConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateLinkServiceConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateLinkServiceConnectionState JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesPrivateLinkServiceConnectionState)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesPrivateLinkServiceConnectionState(document.RootElement, options); } - internal static DeviceProvisioningServicesPrivateLinkServiceConnectionState DeserializeDeviceProvisioningServicesPrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesPrivateLinkServiceConnectionState DeserializeDeviceProvisioningServicesPrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -83,38 +93,39 @@ internal static DeviceProvisioningServicesPrivateLinkServiceConnectionState Dese DeviceProvisioningServicesPrivateLinkServiceConnectionStatus status = default; string description = default; string actionsRequired = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - status = new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(property.Value.GetString()); + status = new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("actionsRequired"u8)) + if (prop.NameEquals("actionsRequired"u8)) { - actionsRequired = property.Value.GetString(); + actionsRequired = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesPrivateLinkServiceConnectionState(status, description, actionsRequired, serializedAdditionalRawData); + return new DeviceProvisioningServicesPrivateLinkServiceConnectionState(status, description, actionsRequired, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -124,15 +135,20 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesPrivateLinkServiceConnectionState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesPrivateLinkServiceConnectionState PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesPrivateLinkServiceConnectionState(document.RootElement, options); } default: @@ -140,6 +156,7 @@ DeviceProvisioningServicesPrivateLinkServiceConnectionState IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.cs index 736fa4ba9ca1..780ad4768883 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionState.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The current state of a private endpoint connection. public partial class DeviceProvisioningServicesPrivateLinkServiceConnectionState { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The status of a private endpoint connection. @@ -61,24 +33,21 @@ public DeviceProvisioningServicesPrivateLinkServiceConnectionState(DeviceProvisi /// The status of a private endpoint connection. /// The description for the current state of a private endpoint connection. /// Actions required for a private endpoint connection. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesPrivateLinkServiceConnectionState(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus status, string description, string actionsRequired, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesPrivateLinkServiceConnectionState(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus status, string description, string actionsRequired, IDictionary additionalBinaryDataProperties) { Status = status; Description = description; ActionsRequired = actionsRequired; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServicesPrivateLinkServiceConnectionState() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The status of a private endpoint connection. public DeviceProvisioningServicesPrivateLinkServiceConnectionStatus Status { get; set; } + /// The description for the current state of a private endpoint connection. public string Description { get; set; } + /// Actions required for a private endpoint connection. public string ActionsRequired { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.cs index f6df0dc7a4ea..d3fd4cb89b6e 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,44 +15,63 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceProvisioningServicesPrivateLinkServiceConnectionStatus : IEquatable { private readonly string _value; + private const string PendingValue = "Pending"; + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + private const string DisconnectedValue = "Disconnected"; /// Initializes a new instance of . + /// The value. /// is null. public DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string PendingValue = "Pending"; - private const string ApprovedValue = "Approved"; - private const string RejectedValue = "Rejected"; - private const string DisconnectedValue = "Disconnected"; + _value = value; + } - /// Pending. + /// Gets the Pending. public static DeviceProvisioningServicesPrivateLinkServiceConnectionStatus Pending { get; } = new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(PendingValue); - /// Approved. + + /// Gets the Approved. public static DeviceProvisioningServicesPrivateLinkServiceConnectionStatus Approved { get; } = new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(ApprovedValue); - /// Rejected. + + /// Gets the Rejected. public static DeviceProvisioningServicesPrivateLinkServiceConnectionStatus Rejected { get; } = new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(RejectedValue); - /// Disconnected. + + /// Gets the Disconnected. public static DeviceProvisioningServicesPrivateLinkServiceConnectionStatus Disconnected { get; } = new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(DisconnectedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus left, DeviceProvisioningServicesPrivateLinkServiceConnectionStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus left, DeviceProvisioningServicesPrivateLinkServiceConnectionStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(string value) => new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesPrivateLinkServiceConnectionStatus?(string value) => value == null ? null : new DeviceProvisioningServicesPrivateLinkServiceConnectionStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesPrivateLinkServiceConnectionStatus other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPublicNetworkAccess.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPublicNetworkAccess.cs index 287468960f09..92568e429e67 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPublicNetworkAccess.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesPublicNetworkAccess.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceProvisioningServicesPublicNetworkAccess : IEquatable { private readonly string _value; + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; /// Initializes a new instance of . + /// The value. /// is null. public DeviceProvisioningServicesPublicNetworkAccess(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string EnabledValue = "Enabled"; - private const string DisabledValue = "Disabled"; + _value = value; + } - /// Enabled. + /// Gets the Enabled. public static DeviceProvisioningServicesPublicNetworkAccess Enabled { get; } = new DeviceProvisioningServicesPublicNetworkAccess(EnabledValue); - /// Disabled. + + /// Gets the Disabled. public static DeviceProvisioningServicesPublicNetworkAccess Disabled { get; } = new DeviceProvisioningServicesPublicNetworkAccess(DisabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesPublicNetworkAccess left, DeviceProvisioningServicesPublicNetworkAccess right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesPublicNetworkAccess left, DeviceProvisioningServicesPublicNetworkAccess right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesPublicNetworkAccess(string value) => new DeviceProvisioningServicesPublicNetworkAccess(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesPublicNetworkAccess?(string value) => value == null ? null : new DeviceProvisioningServicesPublicNetworkAccess(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesPublicNetworkAccess other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesPublicNetworkAccess 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.Serialization.cs index df96b6bcfba7..af484c5fa5b4 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesSharedAccessKey : IUtf8JsonSerializable, IJsonModel + /// Description of the shared access key. + public partial class DeviceProvisioningServicesSharedAccessKey : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceProvisioningServicesSharedAccessKey() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesSharedAccessKey)} does not support writing '{format}' format."); } - writer.WritePropertyName("keyName"u8); writer.WriteStringValue(KeyName); if (Optional.IsDefined(PrimaryKey)) @@ -48,15 +54,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName("rights"u8); writer.WriteStringValue(Rights.ToString()); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -65,22 +71,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesSharedAccessKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesSharedAccessKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesSharedAccessKey JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesSharedAccessKey)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesSharedAccessKey(document.RootElement, options); } - internal static DeviceProvisioningServicesSharedAccessKey DeserializeDeviceProvisioningServicesSharedAccessKey(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesSharedAccessKey DeserializeDeviceProvisioningServicesSharedAccessKey(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,43 +100,44 @@ internal static DeviceProvisioningServicesSharedAccessKey DeserializeDeviceProvi string primaryKey = default; string secondaryKey = default; DeviceProvisioningServicesAccessKeyRight rights = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("keyName"u8)) + if (prop.NameEquals("keyName"u8)) { - keyName = property.Value.GetString(); + keyName = prop.Value.GetString(); continue; } - if (property.NameEquals("primaryKey"u8)) + if (prop.NameEquals("primaryKey"u8)) { - primaryKey = property.Value.GetString(); + primaryKey = prop.Value.GetString(); continue; } - if (property.NameEquals("secondaryKey"u8)) + if (prop.NameEquals("secondaryKey"u8)) { - secondaryKey = property.Value.GetString(); + secondaryKey = prop.Value.GetString(); continue; } - if (property.NameEquals("rights"u8)) + if (prop.NameEquals("rights"u8)) { - rights = new DeviceProvisioningServicesAccessKeyRight(property.Value.GetString()); + rights = new DeviceProvisioningServicesAccessKeyRight(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesSharedAccessKey(keyName, primaryKey, secondaryKey, rights, serializedAdditionalRawData); + return new DeviceProvisioningServicesSharedAccessKey(keyName, primaryKey, secondaryKey, rights, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -135,15 +147,20 @@ BinaryData IPersistableModel.Write(Mo } } - DeviceProvisioningServicesSharedAccessKey IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesSharedAccessKey IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesSharedAccessKey PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesSharedAccessKey(document.RootElement, options); } default: @@ -151,6 +168,14 @@ DeviceProvisioningServicesSharedAccessKey IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static DeviceProvisioningServicesSharedAccessKey FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeviceProvisioningServicesSharedAccessKey(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.cs index 0ea6ad2e14e5..9d7f9d88d0c3 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSharedAccessKey.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// Description of the shared access key. public partial class DeviceProvisioningServicesSharedAccessKey { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Name of the key. @@ -62,27 +34,25 @@ public DeviceProvisioningServicesSharedAccessKey(string keyName, DeviceProvision /// Primary SAS key value. /// Secondary SAS key value. /// Rights that this key has. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesSharedAccessKey(string keyName, string primaryKey, string secondaryKey, DeviceProvisioningServicesAccessKeyRight rights, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesSharedAccessKey(string keyName, string primaryKey, string secondaryKey, DeviceProvisioningServicesAccessKeyRight rights, IDictionary additionalBinaryDataProperties) { KeyName = keyName; PrimaryKey = primaryKey; SecondaryKey = secondaryKey; Rights = rights; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceProvisioningServicesSharedAccessKey() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the key. public string KeyName { get; set; } + /// Primary SAS key value. public string PrimaryKey { get; set; } + /// Secondary SAS key value. public string SecondaryKey { get; set; } + /// Rights that this key has. public DeviceProvisioningServicesAccessKeyRight Rights { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSku.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSku.cs index 7702613c46d6..5e81cf47291c 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSku.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSku.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,35 +15,51 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceProvisioningServicesSku : IEquatable { private readonly string _value; + private const string S1Value = "S1"; /// Initializes a new instance of . + /// The value. /// is null. public DeviceProvisioningServicesSku(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string S1Value = "S1"; + _value = value; + } - /// S1. + /// Gets the S1. public static DeviceProvisioningServicesSku S1 { get; } = new DeviceProvisioningServicesSku(S1Value); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesSku left, DeviceProvisioningServicesSku right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesSku left, DeviceProvisioningServicesSku right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesSku(string value) => new DeviceProvisioningServicesSku(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesSku?(string value) => value == null ? null : new DeviceProvisioningServicesSku(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesSku other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesSku 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.Serialization.cs index 163821a36b53..e553a60eaf89 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesSkuDefinition : IUtf8JsonSerializable, IJsonModel + /// Available SKUs of tier and units. + public partial class DeviceProvisioningServicesSkuDefinition : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +29,25 @@ void IJsonModel.Write(Utf8JsonWriter wr /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesSkuDefinition)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); writer.WriteStringValue(Name.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesSkuDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesSkuDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesSkuDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesSkuDefinition)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesSkuDefinition(document.RootElement, options); } - internal static DeviceProvisioningServicesSkuDefinition DeserializeDeviceProvisioningServicesSkuDefinition(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesSkuDefinition DeserializeDeviceProvisioningServicesSkuDefinition(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DeviceProvisioningServicesSku? name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - name = new DeviceProvisioningServicesSku(property.Value.GetString()); + name = new DeviceProvisioningServicesSku(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesSkuDefinition(name, serializedAdditionalRawData); + return new DeviceProvisioningServicesSkuDefinition(name, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -112,15 +118,20 @@ BinaryData IPersistableModel.Write(Mode } } - DeviceProvisioningServicesSkuDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesSkuDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesSkuDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesSkuDefinition(document.RootElement, options); } default: @@ -128,6 +139,7 @@ DeviceProvisioningServicesSkuDefinition IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.cs index 5d79e62b2edf..6d15082f57c5 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuDefinition.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// Available SKUs of tier and units. public partial class DeviceProvisioningServicesSkuDefinition { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal DeviceProvisioningServicesSkuDefinition() @@ -52,11 +23,11 @@ internal DeviceProvisioningServicesSkuDefinition() /// Initializes a new instance of . /// Sku name. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesSkuDefinition(DeviceProvisioningServicesSku? name, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesSkuDefinition(DeviceProvisioningServicesSku? name, IDictionary additionalBinaryDataProperties) { Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Sku name. diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.Serialization.cs index ca8aa2b9ab83..e6e9915bba78 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceProvisioningServicesSkuInfo : IUtf8JsonSerializable, IJsonModel + /// List of possible provisioning service SKUs. + public partial class DeviceProvisioningServicesSkuInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesSkuInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("capacity"u8); writer.WriteNumberValue(Capacity.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceProvisioningServicesSkuInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceProvisioningServicesSkuInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesSkuInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceProvisioningServicesSkuInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceProvisioningServicesSkuInfo(document.RootElement, options); } - internal static DeviceProvisioningServicesSkuInfo DeserializeDeviceProvisioningServicesSkuInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceProvisioningServicesSkuInfo DeserializeDeviceProvisioningServicesSkuInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,46 +94,47 @@ internal static DeviceProvisioningServicesSkuInfo DeserializeDeviceProvisioningS DeviceProvisioningServicesSku? name = default; string tier = default; long? capacity = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - name = new DeviceProvisioningServicesSku(property.Value.GetString()); + name = new DeviceProvisioningServicesSku(prop.Value.GetString()); continue; } - if (property.NameEquals("tier"u8)) + if (prop.NameEquals("tier"u8)) { - tier = property.Value.GetString(); + tier = prop.Value.GetString(); continue; } - if (property.NameEquals("capacity"u8)) + if (prop.NameEquals("capacity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - capacity = property.Value.GetInt64(); + capacity = prop.Value.GetInt64(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceProvisioningServicesSkuInfo(name, tier, capacity, serializedAdditionalRawData); + return new DeviceProvisioningServicesSkuInfo(name, tier, capacity, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -138,15 +144,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - DeviceProvisioningServicesSkuInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceProvisioningServicesSkuInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceProvisioningServicesSkuInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceProvisioningServicesSkuInfo(document.RootElement, options); } default: @@ -154,6 +165,7 @@ DeviceProvisioningServicesSkuInfo IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.cs index 5d0aa57b9303..d01d9a3c3214 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesSkuInfo.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// List of possible provisioning service SKUs. public partial class DeviceProvisioningServicesSkuInfo { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DeviceProvisioningServicesSkuInfo() @@ -54,19 +25,21 @@ public DeviceProvisioningServicesSkuInfo() /// Sku name. /// Pricing tier name of the provisioning service. /// The number of units to provision. - /// Keeps track of any properties unknown to the library. - internal DeviceProvisioningServicesSkuInfo(DeviceProvisioningServicesSku? name, string tier, long? capacity, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceProvisioningServicesSkuInfo(DeviceProvisioningServicesSku? name, string tier, long? capacity, IDictionary additionalBinaryDataProperties) { Name = name; Tier = tier; Capacity = capacity; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Sku name. public DeviceProvisioningServicesSku? Name { get; set; } + /// Pricing tier name of the provisioning service. public string Tier { get; } + /// The number of units to provision. public long? Capacity { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesState.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesState.cs index 1b86c6200de8..290736e0d23a 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesState.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceProvisioningServicesState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,14 +15,6 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceProvisioningServicesState : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DeviceProvisioningServicesState(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - private const string ActivatingValue = "Activating"; private const string ActiveValue = "Active"; private const string DeletingValue = "Deleting"; @@ -35,47 +28,82 @@ public DeviceProvisioningServicesState(string value) private const string FailingOverValue = "FailingOver"; private const string FailoverFailedValue = "FailoverFailed"; - /// Activating. + /// Initializes a new instance of . + /// The value. + /// is null. + public DeviceProvisioningServicesState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Activating. public static DeviceProvisioningServicesState Activating { get; } = new DeviceProvisioningServicesState(ActivatingValue); - /// Active. + + /// Gets the Active. public static DeviceProvisioningServicesState Active { get; } = new DeviceProvisioningServicesState(ActiveValue); - /// Deleting. + + /// Gets the Deleting. public static DeviceProvisioningServicesState Deleting { get; } = new DeviceProvisioningServicesState(DeletingValue); - /// Deleted. + + /// Gets the Deleted. public static DeviceProvisioningServicesState Deleted { get; } = new DeviceProvisioningServicesState(DeletedValue); - /// ActivationFailed. + + /// Gets the ActivationFailed. public static DeviceProvisioningServicesState ActivationFailed { get; } = new DeviceProvisioningServicesState(ActivationFailedValue); - /// DeletionFailed. + + /// Gets the DeletionFailed. public static DeviceProvisioningServicesState DeletionFailed { get; } = new DeviceProvisioningServicesState(DeletionFailedValue); - /// Transitioning. + + /// Gets the Transitioning. public static DeviceProvisioningServicesState Transitioning { get; } = new DeviceProvisioningServicesState(TransitioningValue); - /// Suspending. + + /// Gets the Suspending. public static DeviceProvisioningServicesState Suspending { get; } = new DeviceProvisioningServicesState(SuspendingValue); - /// Suspended. + + /// Gets the Suspended. public static DeviceProvisioningServicesState Suspended { get; } = new DeviceProvisioningServicesState(SuspendedValue); - /// Resuming. + + /// Gets the Resuming. public static DeviceProvisioningServicesState Resuming { get; } = new DeviceProvisioningServicesState(ResumingValue); - /// FailingOver. + + /// Gets the FailingOver. public static DeviceProvisioningServicesState FailingOver { get; } = new DeviceProvisioningServicesState(FailingOverValue); - /// FailoverFailed. + + /// Gets the FailoverFailed. public static DeviceProvisioningServicesState FailoverFailed { get; } = new DeviceProvisioningServicesState(FailoverFailedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceProvisioningServicesState left, DeviceProvisioningServicesState right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceProvisioningServicesState left, DeviceProvisioningServicesState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceProvisioningServicesState(string value) => new DeviceProvisioningServicesState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceProvisioningServicesState?(string value) => value == null ? null : new DeviceProvisioningServicesState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceProvisioningServicesState other && Equals(other); - /// + + /// public bool Equals(DeviceProvisioningServicesState 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceAuthenticationType.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceAuthenticationType.cs index 4a888a8aa151..0cc351a4d61f 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceAuthenticationType.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceAuthenticationType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models public readonly partial struct DeviceRegistryNamespaceAuthenticationType : IEquatable { private readonly string _value; + /// User assigned authentication type. + private const string UserAssignedValue = "UserAssigned"; + /// System assigned authentication type. + private const string SystemAssignedValue = "SystemAssigned"; /// Initializes a new instance of . + /// The value. /// is null. public DeviceRegistryNamespaceAuthenticationType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string UserAssignedValue = "UserAssigned"; - private const string SystemAssignedValue = "SystemAssigned"; + _value = value; + } /// User assigned authentication type. public static DeviceRegistryNamespaceAuthenticationType UserAssigned { get; } = new DeviceRegistryNamespaceAuthenticationType(UserAssignedValue); + /// System assigned authentication type. public static DeviceRegistryNamespaceAuthenticationType SystemAssigned { get; } = new DeviceRegistryNamespaceAuthenticationType(SystemAssignedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DeviceRegistryNamespaceAuthenticationType left, DeviceRegistryNamespaceAuthenticationType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DeviceRegistryNamespaceAuthenticationType left, DeviceRegistryNamespaceAuthenticationType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DeviceRegistryNamespaceAuthenticationType(string value) => new DeviceRegistryNamespaceAuthenticationType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DeviceRegistryNamespaceAuthenticationType?(string value) => value == null ? null : new DeviceRegistryNamespaceAuthenticationType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DeviceRegistryNamespaceAuthenticationType other && Equals(other); - /// + + /// public bool Equals(DeviceRegistryNamespaceAuthenticationType 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/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.Serialization.cs index f8f4510270d7..3860aee81b78 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class DeviceRegistryNamespaceDescription : IUtf8JsonSerializable, IJsonModel + /// Description of the Device Registry namespace that is linked to the provisioning service. + public partial class DeviceRegistryNamespaceDescription : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DeviceRegistryNamespaceDescription() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceRegistryNamespaceDescription)} does not support writing '{format}' format."); } - writer.WritePropertyName("resourceId"u8); writer.WriteStringValue(ResourceId); writer.WritePropertyName("authenticationType"u8); @@ -43,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("selectedUserAssignedIdentityResourceId"u8); writer.WriteStringValue(SelectedUserAssignedIdentityResourceId); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -60,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceRegistryNamespaceDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceRegistryNamespaceDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceRegistryNamespaceDescription JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DeviceRegistryNamespaceDescription)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceRegistryNamespaceDescription(document.RootElement, options); } - internal static DeviceRegistryNamespaceDescription DeserializeDeviceRegistryNamespaceDescription(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceRegistryNamespaceDescription DeserializeDeviceRegistryNamespaceDescription(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -83,42 +94,43 @@ internal static DeviceRegistryNamespaceDescription DeserializeDeviceRegistryName ResourceIdentifier resourceId = default; DeviceRegistryNamespaceAuthenticationType authenticationType = default; ResourceIdentifier selectedUserAssignedIdentityResourceId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("resourceId"u8)) + if (prop.NameEquals("resourceId"u8)) { - resourceId = new ResourceIdentifier(property.Value.GetString()); + resourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("authenticationType"u8)) + if (prop.NameEquals("authenticationType"u8)) { - authenticationType = new DeviceRegistryNamespaceAuthenticationType(property.Value.GetString()); + authenticationType = new DeviceRegistryNamespaceAuthenticationType(prop.Value.GetString()); continue; } - if (property.NameEquals("selectedUserAssignedIdentityResourceId"u8)) + if (prop.NameEquals("selectedUserAssignedIdentityResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - selectedUserAssignedIdentityResourceId = new ResourceIdentifier(property.Value.GetString()); + selectedUserAssignedIdentityResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DeviceRegistryNamespaceDescription(resourceId, authenticationType, selectedUserAssignedIdentityResourceId, serializedAdditionalRawData); + return new DeviceRegistryNamespaceDescription(resourceId, authenticationType, selectedUserAssignedIdentityResourceId, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -128,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelRead } } - DeviceRegistryNamespaceDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DeviceRegistryNamespaceDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceRegistryNamespaceDescription PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDeviceRegistryNamespaceDescription(document.RootElement, options); } default: @@ -144,6 +161,7 @@ DeviceRegistryNamespaceDescription IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.cs index 2596d4be062a..019db4f62b92 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/DeviceRegistryNamespaceDescription.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// Description of the Device Registry namespace that is linked to the provisioning service. public partial class DeviceRegistryNamespaceDescription { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The ARM resource ID of the Device Registry namespace. @@ -62,24 +34,21 @@ public DeviceRegistryNamespaceDescription(ResourceIdentifier resourceId, DeviceR /// The ARM resource ID of the Device Registry namespace. /// Device Registry Namespace MI authentication type: UserAssigned, SystemAssigned. /// The selected user-assigned identity resource Id associated with Device Registry namespace. This is required when authenticationType is UserAssigned. - /// Keeps track of any properties unknown to the library. - internal DeviceRegistryNamespaceDescription(ResourceIdentifier resourceId, DeviceRegistryNamespaceAuthenticationType authenticationType, ResourceIdentifier selectedUserAssignedIdentityResourceId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceRegistryNamespaceDescription(ResourceIdentifier resourceId, DeviceRegistryNamespaceAuthenticationType authenticationType, ResourceIdentifier selectedUserAssignedIdentityResourceId, IDictionary additionalBinaryDataProperties) { ResourceId = resourceId; AuthenticationType = authenticationType; SelectedUserAssignedIdentityResourceId = selectedUserAssignedIdentityResourceId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DeviceRegistryNamespaceDescription() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The ARM resource ID of the Device Registry namespace. public ResourceIdentifier ResourceId { get; set; } + /// Device Registry Namespace MI authentication type: UserAssigned, SystemAssigned. public DeviceRegistryNamespaceAuthenticationType AuthenticationType { get; set; } + /// The selected user-assigned identity resource Id associated with Device Registry namespace. This is required when authenticationType is UserAssigned. public ResourceIdentifier SelectedUserAssignedIdentityResourceId { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.Serialization.cs index 1faa4f034b0b..907308f4ef19 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - internal partial class IotDpsSkuDefinitionListResult : IUtf8JsonSerializable, IJsonModel + /// List of available SKUs. + internal partial class IotDpsSkuDefinitionListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal IotDpsSkuDefinitionListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(IotDpsSkuDefinitionListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DeviceProvisioningServicesSkuDefinition item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - IotDpsSkuDefinitionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + IotDpsSkuDefinitionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IotDpsSkuDefinitionListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(IotDpsSkuDefinitionListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeIotDpsSkuDefinitionListResult(document.RootElement, options); } - internal static IotDpsSkuDefinitionListResult DeserializeIotDpsSkuDefinitionListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IotDpsSkuDefinitionListResult DeserializeIotDpsSkuDefinitionListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServicesSkuDefinition.DeserializeDeviceProvisioningServicesSkuDefinition(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = new Uri(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new IotDpsSkuDefinitionListResult(value, nextLink, serializedAdditionalRawData); + return new IotDpsSkuDefinitionListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - IotDpsSkuDefinitionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + IotDpsSkuDefinitionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IotDpsSkuDefinitionListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeIotDpsSkuDefinitionListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ IotDpsSkuDefinitionListResult IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static IotDpsSkuDefinitionListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIotDpsSkuDefinitionListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.cs index 1be0c09ae0fc..df75ed649efb 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotDpsSkuDefinitionListResult.cs @@ -14,66 +14,30 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// List of available SKUs. internal partial class IotDpsSkuDefinitionListResult { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The IotDpsSkuDefinition items on this page. - /// is null. internal IotDpsSkuDefinitionListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The IotDpsSkuDefinition items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal IotDpsSkuDefinitionListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal IotDpsSkuDefinitionListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal IotDpsSkuDefinitionListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The IotDpsSkuDefinition items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.Serialization.cs index 5d1862586c89..153b1bbe93ec 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - public partial class IotHubDefinitionDescription : IUtf8JsonSerializable, IJsonModel + /// Description of the IoT hub. + public partial class IotHubDefinitionDescription : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal IotHubDefinitionDescription() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(IotHubDefinitionDescription)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ApplyAllocationPolicy)) { writer.WritePropertyName("applyAllocationPolicy"u8); @@ -53,15 +59,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteStringValue(ConnectionString); writer.WritePropertyName("location"u8); writer.WriteStringValue(Location); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -70,22 +76,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - IotHubDefinitionDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + IotHubDefinitionDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual IotHubDefinitionDescription JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(IotHubDefinitionDescription)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeIotHubDefinitionDescription(document.RootElement, options); } - internal static IotHubDefinitionDescription DeserializeIotHubDefinitionDescription(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static IotHubDefinitionDescription DeserializeIotHubDefinitionDescription(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -95,62 +106,63 @@ internal static IotHubDefinitionDescription DeserializeIotHubDefinitionDescripti string name = default; string connectionString = default; AzureLocation location = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("applyAllocationPolicy"u8)) + if (prop.NameEquals("applyAllocationPolicy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - applyAllocationPolicy = property.Value.GetBoolean(); + applyAllocationPolicy = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("allocationWeight"u8)) + if (prop.NameEquals("allocationWeight"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allocationWeight = property.Value.GetInt32(); + allocationWeight = prop.Value.GetInt32(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("connectionString"u8)) + if (prop.NameEquals("connectionString"u8)) { - connectionString = property.Value.GetString(); + connectionString = prop.Value.GetString(); continue; } - if (property.NameEquals("location"u8)) + if (prop.NameEquals("location"u8)) { - location = new AzureLocation(property.Value.GetString()); + location = new AzureLocation(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new IotHubDefinitionDescription( applyAllocationPolicy, allocationWeight, name, connectionString, location, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -160,15 +172,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - IotHubDefinitionDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + IotHubDefinitionDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual IotHubDefinitionDescription PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeIotHubDefinitionDescription(document.RootElement, options); } default: @@ -176,6 +193,7 @@ IotHubDefinitionDescription IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.cs index 49bb1a23effd..9391f3494350 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/IotHubDefinitionDescription.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// Description of the IoT hub. public partial class IotHubDefinitionDescription { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// flag for applying allocationPolicy or not for a given iot hub. @@ -52,30 +23,29 @@ public partial class IotHubDefinitionDescription /// Host name of the IoT hub. /// Connection string of the IoT hub. /// ARM region of the IoT hub. - /// Keeps track of any properties unknown to the library. - internal IotHubDefinitionDescription(bool? applyAllocationPolicy, int? allocationWeight, string name, string connectionString, AzureLocation location, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal IotHubDefinitionDescription(bool? applyAllocationPolicy, int? allocationWeight, string name, string connectionString, AzureLocation location, IDictionary additionalBinaryDataProperties) { ApplyAllocationPolicy = applyAllocationPolicy; AllocationWeight = allocationWeight; Name = name; ConnectionString = connectionString; Location = location; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal IotHubDefinitionDescription() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// flag for applying allocationPolicy or not for a given iot hub. public bool? ApplyAllocationPolicy { get; set; } + /// weight to apply for a given iot h. public int? AllocationWeight { get; set; } + /// Host name of the IoT hub. public string Name { get; } + /// Connection string of the IoT hub. public string ConnectionString { get; set; } + /// ARM region of the IoT hub. public AzureLocation Location { get; set; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.Serialization.cs index a5c232ab1caa..02e6ee716c00 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - internal partial class PrivateLinkResources : IUtf8JsonSerializable, IJsonModel + /// The available private link resources for a provisioning service. + public partial class PrivateLinkResources : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +30,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(PrivateLinkResources)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DeviceProvisioningServicesPrivateLinkResourceData item in Value) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,39 +62,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - PrivateLinkResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PrivateLinkResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PrivateLinkResources JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(PrivateLinkResources)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializePrivateLinkResources(document.RootElement, options); } - internal static PrivateLinkResources DeserializePrivateLinkResources(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PrivateLinkResources DeserializePrivateLinkResources(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServicesPrivateLinkResourceData.DeserializeDeviceProvisioningServicesPrivateLinkResourceData(item, options)); } @@ -102,17 +107,19 @@ internal static PrivateLinkResources DeserializePrivateLinkResources(JsonElement } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new PrivateLinkResources(value ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new PrivateLinkResources(value ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - PrivateLinkResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + PrivateLinkResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PrivateLinkResources PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializePrivateLinkResources(document.RootElement, options); } default: @@ -138,6 +150,14 @@ PrivateLinkResources IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static PrivateLinkResources FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePrivateLinkResources(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.cs index 230bf8eb2c45..76870ff9296a 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/PrivateLinkResources.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The available private link resources for a provisioning service. - internal partial class PrivateLinkResources + public partial class PrivateLinkResources { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal PrivateLinkResources() @@ -53,14 +25,14 @@ internal PrivateLinkResources() /// Initializes a new instance of . /// The list of available private link resources for a provisioning service. - /// Keeps track of any properties unknown to the library. - internal PrivateLinkResources(IReadOnlyList value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal PrivateLinkResources(IList value, IDictionary additionalBinaryDataProperties) { Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The list of available private link resources for a provisioning service. - public IReadOnlyList Value { get; } + public IList Value { get; } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.Serialization.cs index 800c8d048a31..d66ee6ee82dd 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - internal partial class ProvisioningServiceDescriptionListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a ProvisioningServiceDescription list operation. + internal partial class ProvisioningServiceDescriptionListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ProvisioningServiceDescriptionListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter w /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ProvisioningServiceDescriptionListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DeviceProvisioningServiceData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ProvisioningServiceDescriptionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ProvisioningServiceDescriptionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProvisioningServiceDescriptionListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ProvisioningServiceDescriptionListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeProvisioningServiceDescriptionListResult(document.RootElement, options); } - internal static ProvisioningServiceDescriptionListResult DeserializeProvisioningServiceDescriptionListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProvisioningServiceDescriptionListResult DeserializeProvisioningServiceDescriptionListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = new Uri(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ProvisioningServiceDescriptionListResult(value, nextLink, serializedAdditionalRawData); + return new ProvisioningServiceDescriptionListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(Mod } } - ProvisioningServiceDescriptionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ProvisioningServiceDescriptionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProvisioningServiceDescriptionListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeProvisioningServiceDescriptionListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ ProvisioningServiceDescriptionListResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ProvisioningServiceDescriptionListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProvisioningServiceDescriptionListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.cs index 352bf7e5e2d1..74235705742c 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/ProvisioningServiceDescriptionListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { /// The response of a ProvisioningServiceDescription list operation. internal partial class ProvisioningServiceDescriptionListResult { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The ProvisioningServiceDescription items on this page. - /// is null. internal ProvisioningServiceDescriptionListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The ProvisioningServiceDescription items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal ProvisioningServiceDescriptionListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ProvisioningServiceDescriptionListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ProvisioningServiceDescriptionListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The ProvisioningServiceDescription items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.Serialization.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.Serialization.cs index 8b7301a78d97..6060a271a9c2 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.Serialization.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DeviceProvisioningServices; namespace Azure.ResourceManager.DeviceProvisioningServices.Models { - internal partial class SharedAccessSignatureAuthorizationRuleListResult : IUtf8JsonSerializable, IJsonModel + /// List of shared access keys. + internal partial class SharedAccessSignatureAuthorizationRuleListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SharedAccessSignatureAuthorizationRuleListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8Json /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SharedAccessSignatureAuthorizationRuleListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DeviceProvisioningServicesSharedAccessKey item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SharedAccessSignatureAuthorizationRuleListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SharedAccessSignatureAuthorizationRuleListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SharedAccessSignatureAuthorizationRuleListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SharedAccessSignatureAuthorizationRuleListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSharedAccessSignatureAuthorizationRuleListResult(document.RootElement, options); } - internal static SharedAccessSignatureAuthorizationRuleListResult DeserializeSharedAccessSignatureAuthorizationRuleListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SharedAccessSignatureAuthorizationRuleListResult DeserializeSharedAccessSignatureAuthorizationRuleListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeviceProvisioningServicesSharedAccessKey.DeserializeDeviceProvisioningServicesSharedAccessKey(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = new Uri(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SharedAccessSignatureAuthorizationRuleListResult(value, nextLink, serializedAdditionalRawData); + return new SharedAccessSignatureAuthorizationRuleListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.W } } - SharedAccessSignatureAuthorizationRuleListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SharedAccessSignatureAuthorizationRuleListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SharedAccessSignatureAuthorizationRuleListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSharedAccessSignatureAuthorizationRuleListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ SharedAccessSignatureAuthorizationRuleListResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SharedAccessSignatureAuthorizationRuleListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSharedAccessSignatureAuthorizationRuleListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.cs index 4d6bd6a3b963..72ad89113039 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/Models/SharedAccessSignatureAuthorizationRuleListResult.cs @@ -14,66 +14,30 @@ namespace Azure.ResourceManager.DeviceProvisioningServices.Models /// List of shared access keys. internal partial class SharedAccessSignatureAuthorizationRuleListResult { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The SharedAccessSignatureAuthorizationRuleAccessRightsDescription items on this page. - /// is null. internal SharedAccessSignatureAuthorizationRuleListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The SharedAccessSignatureAuthorizationRuleAccessRightsDescription items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal SharedAccessSignatureAuthorizationRuleListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SharedAccessSignatureAuthorizationRuleListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal SharedAccessSignatureAuthorizationRuleListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The SharedAccessSignatureAuthorizationRuleAccessRightsDescription items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ProviderConstants.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ProviderConstants.cs index 5514389e98f5..de868a599df0 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ProviderConstants.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.DeviceProvisioningServices { - internal static class ProviderConstants + internal static partial class ProviderConstants { + /// Gets the DefaultProviderNamespace. public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/CertificateResponsesRestOperations.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/CertificateResponsesRestOperations.cs index 7e392a330d29..d44c49f5180c 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/CertificateResponsesRestOperations.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/CertificateResponsesRestOperations.cs @@ -6,58 +6,44 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.DeviceProvisioningServices.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal partial class CertificateResponsesRestOperations + internal partial class CertificateResponses { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of CertificateResponsesRestOperations. - /// 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 CertificateResponsesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of CertificateResponses for mocking. + protected CertificateResponses() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-02-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch) + /// Initializes a new instance of CertificateResponses. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal CertificateResponses(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/certificates/", false); - uri.AppendPath(certificateName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, ETag? ifMatch, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -68,106 +54,21 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath("/certificates/", false); uri.AppendPath(certificateName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; + request.Method = RequestMethod.Get; if (ifMatch != null) { - request.Headers.Add("If-Match", ifMatch); + request.Headers.Add("If-Match", ifMatch.Value); } - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get the certificate from the provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, RequestContent content, ETag? ifMatch, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesCertificateData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServicesCertificateData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get the certificate from the provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesCertificateData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServicesCertificateData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, DeviceProvisioningServicesCertificateData data, string ifMatch) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/certificates/", false); - uri.AppendPath(certificateName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, DeviceProvisioningServicesCertificateData data, string ifMatch) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -178,142 +79,23 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/certificates/", false); uri.AppendPath(certificateName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; + request.Method = RequestMethod.Put; if (ifMatch != null) { - request.Headers.Add("If-Match", ifMatch); + request.Headers.Add("If-Match", ifMatch.Value); } - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Add new certificate or update an existing certificate. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// The certificate body. - /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. - /// 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 provisioningServiceName, string certificateName, DeviceProvisioningServicesCertificateData data, string ifMatch = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, data, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesCertificateData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Add new certificate or update an existing certificate. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// The certificate body. - /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. - /// 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 provisioningServiceName, string certificateName, DeviceProvisioningServicesCertificateData data, string ifMatch = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, data, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesCertificateData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName, byte[] certificateRawBytes, bool? certificateIsVerified, DeviceProvisioningServicesCertificatePurpose? certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/certificates/", false); - uri.AppendPath(certificateName, true); - uri.AppendQuery("api-version", _apiVersion, true); - if (certificateCommonName != null) - { - uri.AppendQuery("certificate.name", certificateCommonName, true); - } - if (certificateRawBytes != null) - { - uri.AppendQuery("certificate.rawBytes", certificateRawBytes, "D", true); - } - if (certificateIsVerified != null) - { - uri.AppendQuery("certificate.isVerified", certificateIsVerified.Value, true); - } - if (certificatePurpose != null) - { - uri.AppendQuery("certificate.purpose", certificatePurpose.Value.ToString(), true); - } - if (certificateCreatedOn != null) - { - uri.AppendQuery("certificate.created", certificateCreatedOn.Value, "O", true); - } - if (certificateLastUpdatedOn != null) - { - uri.AppendQuery("certificate.lastUpdated", certificateLastUpdatedOn.Value, "O", true); - } - if (certificateHasPrivateKey != null) - { - uri.AppendQuery("certificate.hasPrivateKey", certificateHasPrivateKey.Value, true); - } - if (certificateNonce != null) - { - uri.AppendQuery("certificate.nonce", certificateNonce, true); - } - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName, byte[] certificateRawBytes, bool? certificateIsVerified, DeviceProvisioningServicesCertificatePurpose? certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName, BinaryData certificateRawBytes, bool? certificateIsVerified, string certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -330,133 +112,43 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG } if (certificateRawBytes != null) { - uri.AppendQuery("certificate.rawBytes", certificateRawBytes, "D", true); + uri.AppendQuery("certificate.rawBytes", TypeFormatters.ConvertToString(certificateRawBytes, SerializationFormat.Bytes_Base64), true); } if (certificateIsVerified != null) { - uri.AppendQuery("certificate.isVerified", certificateIsVerified.Value, true); + uri.AppendQuery("certificate.isVerified", TypeFormatters.ConvertToString(certificateIsVerified), true); } if (certificatePurpose != null) { - uri.AppendQuery("certificate.purpose", certificatePurpose.Value.ToString(), true); + uri.AppendQuery("certificate.purpose", certificatePurpose, true); } if (certificateCreatedOn != null) { - uri.AppendQuery("certificate.created", certificateCreatedOn.Value, "O", true); + uri.AppendQuery("certificate.created", TypeFormatters.ConvertToString(certificateCreatedOn, SerializationFormat.DateTime_RFC3339), true); } if (certificateLastUpdatedOn != null) { - uri.AppendQuery("certificate.lastUpdated", certificateLastUpdatedOn.Value, "O", true); + uri.AppendQuery("certificate.lastUpdated", TypeFormatters.ConvertToString(certificateLastUpdatedOn, SerializationFormat.DateTime_RFC3339), true); } if (certificateHasPrivateKey != null) { - uri.AppendQuery("certificate.hasPrivateKey", certificateHasPrivateKey.Value, true); + uri.AppendQuery("certificate.hasPrivateKey", TypeFormatters.ConvertToString(certificateHasPrivateKey), true); } if (certificateNonce != null) { uri.AppendQuery("certificate.nonce", certificateNonce, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("If-Match", ifMatch); - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; + request.Headers.SetValue("If-Match", ifMatch); return message; } - /// Deletes the specified certificate associated with the Provisioning Service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// This is optional, and it is the Common Name of the certificate. - /// Raw data within the certificate. - /// Indicates if certificate has been verified by owner of the private key. - /// A description that mentions the purpose of the certificate. - /// Time the certificate is created. - /// Certificate last updated time. - /// Indicates if the certificate contains a private key. - /// Random number generated to indicate Proof of Possession. - /// 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 provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose, certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce); - 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 the specified certificate associated with the Provisioning Service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// This is optional, and it is the Common Name of the certificate. - /// Raw data within the certificate. - /// Indicates if certificate has been verified by owner of the private key. - /// A description that mentions the purpose of the certificate. - /// Time the certificate is created. - /// Certificate last updated time. - /// Indicates if the certificate contains a private key. - /// Random number generated to indicate Proof of Possession. - /// 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 provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose, certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce); - _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 provisioningServiceName) + internal HttpMessage CreateGetAllRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/certificates", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -466,73 +158,17 @@ internal HttpMessage CreateListRequest(string subscriptionId, string resourceGro uri.AppendPath(provisioningServiceName, true); uri.AppendPath("/certificates", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get all the certificates tied to the provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGenerateVerificationCodeRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName, BinaryData certificateRawBytes, bool? certificateIsVerified, string certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, provisioningServiceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - CertificateListDescription value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = CertificateListDescription.DeserializeCertificateListDescription(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get all the certificates tied to the provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListRequest(subscriptionId, resourceGroupName, provisioningServiceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - CertificateListDescription value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = CertificateListDescription.DeserializeCertificateListDescription(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGenerateVerificationCodeRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName, byte[] certificateRawBytes, bool? certificateIsVerified, DeviceProvisioningServicesCertificatePurpose? certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -550,228 +186,44 @@ internal RequestUriBuilder CreateGenerateVerificationCodeRequestUri(string subsc } if (certificateRawBytes != null) { - uri.AppendQuery("certificate.rawBytes", certificateRawBytes, "D", true); + uri.AppendQuery("certificate.rawBytes", TypeFormatters.ConvertToString(certificateRawBytes, SerializationFormat.Bytes_Base64), true); } if (certificateIsVerified != null) { - uri.AppendQuery("certificate.isVerified", certificateIsVerified.Value, true); + uri.AppendQuery("certificate.isVerified", TypeFormatters.ConvertToString(certificateIsVerified), true); } if (certificatePurpose != null) { - uri.AppendQuery("certificate.purpose", certificatePurpose.Value.ToString(), true); + uri.AppendQuery("certificate.purpose", certificatePurpose, true); } if (certificateCreatedOn != null) { - uri.AppendQuery("certificate.created", certificateCreatedOn.Value, "O", true); + uri.AppendQuery("certificate.created", TypeFormatters.ConvertToString(certificateCreatedOn, SerializationFormat.DateTime_RFC3339), true); } if (certificateLastUpdatedOn != null) { - uri.AppendQuery("certificate.lastUpdated", certificateLastUpdatedOn.Value, "O", true); + uri.AppendQuery("certificate.lastUpdated", TypeFormatters.ConvertToString(certificateLastUpdatedOn, SerializationFormat.DateTime_RFC3339), true); } if (certificateHasPrivateKey != null) { - uri.AppendQuery("certificate.hasPrivateKey", certificateHasPrivateKey.Value, true); - } - if (certificateNonce != null) - { - uri.AppendQuery("certificate.nonce", certificateNonce, true); - } - return uri; - } - - internal HttpMessage CreateGenerateVerificationCodeRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName, byte[] certificateRawBytes, bool? certificateIsVerified, DeviceProvisioningServicesCertificatePurpose? certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/certificates/", false); - uri.AppendPath(certificateName, true); - uri.AppendPath("/generateVerificationCode", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (certificateCommonName != null) - { - uri.AppendQuery("certificate.name", certificateCommonName, true); - } - if (certificateRawBytes != null) - { - uri.AppendQuery("certificate.rawBytes", certificateRawBytes, "D", true); - } - if (certificateIsVerified != null) - { - uri.AppendQuery("certificate.isVerified", certificateIsVerified.Value, true); - } - if (certificatePurpose != null) - { - uri.AppendQuery("certificate.purpose", certificatePurpose.Value.ToString(), true); - } - if (certificateCreatedOn != null) - { - uri.AppendQuery("certificate.created", certificateCreatedOn.Value, "O", true); - } - if (certificateLastUpdatedOn != null) - { - uri.AppendQuery("certificate.lastUpdated", certificateLastUpdatedOn.Value, "O", true); - } - if (certificateHasPrivateKey != null) - { - uri.AppendQuery("certificate.hasPrivateKey", certificateHasPrivateKey.Value, true); + uri.AppendQuery("certificate.hasPrivateKey", TypeFormatters.ConvertToString(certificateHasPrivateKey), true); } if (certificateNonce != null) { uri.AppendQuery("certificate.nonce", certificateNonce, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("If-Match", ifMatch); - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Post; + request.Headers.SetValue("If-Match", ifMatch); + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Generate verification code for Proof of Possession. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Description mentioning the purpose of the certificate. - /// Time the certificate is created. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GenerateVerificationCodeAsync(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) + internal HttpMessage CreateVerifyCertificateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, RequestContent content, string certificateCommonName, BinaryData certificateRawBytes, bool? certificateIsVerified, string certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - - using var message = CreateGenerateVerificationCodeRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose, certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - CertificateVerificationCodeResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = CertificateVerificationCodeResult.DeserializeCertificateVerificationCodeResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Generate verification code for Proof of Possession. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Description mentioning the purpose of the certificate. - /// Time the certificate is created. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response GenerateVerificationCode(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - - using var message = CreateGenerateVerificationCodeRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose, certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - CertificateVerificationCodeResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = CertificateVerificationCodeResult.DeserializeCertificateVerificationCodeResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateVerifyCertificateRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName, byte[] certificateRawBytes, bool? certificateIsVerified, DeviceProvisioningServicesCertificatePurpose? certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/certificates/", false); - uri.AppendPath(certificateName, true); - uri.AppendPath("/verify", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (certificateCommonName != null) - { - uri.AppendQuery("certificate.name", certificateCommonName, true); - } - if (certificateRawBytes != null) - { - uri.AppendQuery("certificate.rawBytes", certificateRawBytes, "D", true); - } - if (certificateIsVerified != null) - { - uri.AppendQuery("certificate.isVerified", certificateIsVerified.Value, true); - } - if (certificatePurpose != null) - { - uri.AppendQuery("certificate.purpose", certificatePurpose.Value.ToString(), true); - } - if (certificateCreatedOn != null) - { - uri.AppendQuery("certificate.created", certificateCreatedOn.Value, "O", true); - } - if (certificateLastUpdatedOn != null) - { - uri.AppendQuery("certificate.lastUpdated", certificateLastUpdatedOn.Value, "O", true); - } - if (certificateHasPrivateKey != null) - { - uri.AppendQuery("certificate.hasPrivateKey", certificateHasPrivateKey.Value, true); - } - if (certificateNonce != null) - { - uri.AppendQuery("certificate.nonce", certificateNonce, true); - } - return uri; - } - - internal HttpMessage CreateVerifyCertificateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName, byte[] certificateRawBytes, bool? certificateIsVerified, DeviceProvisioningServicesCertificatePurpose? certificatePurpose, DateTimeOffset? certificateCreatedOn, DateTimeOffset? certificateLastUpdatedOn, bool? certificateHasPrivateKey, string certificateNonce) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -789,127 +241,41 @@ internal HttpMessage CreateVerifyCertificateRequest(string subscriptionId, strin } if (certificateRawBytes != null) { - uri.AppendQuery("certificate.rawBytes", certificateRawBytes, "D", true); + uri.AppendQuery("certificate.rawBytes", TypeFormatters.ConvertToString(certificateRawBytes, SerializationFormat.Bytes_Base64), true); } if (certificateIsVerified != null) { - uri.AppendQuery("certificate.isVerified", certificateIsVerified.Value, true); + uri.AppendQuery("certificate.isVerified", TypeFormatters.ConvertToString(certificateIsVerified), true); } if (certificatePurpose != null) { - uri.AppendQuery("certificate.purpose", certificatePurpose.Value.ToString(), true); + uri.AppendQuery("certificate.purpose", certificatePurpose, true); } if (certificateCreatedOn != null) { - uri.AppendQuery("certificate.created", certificateCreatedOn.Value, "O", true); + uri.AppendQuery("certificate.created", TypeFormatters.ConvertToString(certificateCreatedOn, SerializationFormat.DateTime_RFC3339), true); } if (certificateLastUpdatedOn != null) { - uri.AppendQuery("certificate.lastUpdated", certificateLastUpdatedOn.Value, "O", true); + uri.AppendQuery("certificate.lastUpdated", TypeFormatters.ConvertToString(certificateLastUpdatedOn, SerializationFormat.DateTime_RFC3339), true); } if (certificateHasPrivateKey != null) { - uri.AppendQuery("certificate.hasPrivateKey", certificateHasPrivateKey.Value, true); + uri.AppendQuery("certificate.hasPrivateKey", TypeFormatters.ConvertToString(certificateHasPrivateKey), true); } if (certificateNonce != null) { uri.AppendQuery("certificate.nonce", certificateNonce, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("If-Match", ifMatch); - 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); + request.Method = RequestMethod.Post; + request.Headers.SetValue("If-Match", ifMatch); + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; return message; } - - /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// The name of the certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Describe the purpose of the certificate. - /// Time the certificate is created. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. - /// The cancellation token to use. - /// , , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> VerifyCertificateAsync(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateVerifyCertificateRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch, content, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose, certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesCertificateData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Name of the certificate to retrieve. - /// ETag of the certificate. - /// The name of the certificate. - /// Common Name for the certificate. - /// Raw data of certificate. - /// Indicates if the certificate has been verified by owner of the private key. - /// Describe the purpose of the certificate. - /// Time the certificate is created. - /// Certificate last updated time. - /// Indicates if the certificate contains private key. - /// Random number generated to indicate Proof of Possession. - /// The cancellation token to use. - /// , , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response VerifyCertificate(string subscriptionId, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch, CertificateVerificationCodeContent content, string certificateCommonName = null, byte[] certificateRawBytes = null, bool? certificateIsVerified = null, DeviceProvisioningServicesCertificatePurpose? certificatePurpose = null, DateTimeOffset? certificateCreatedOn = null, DateTimeOffset? certificateLastUpdatedOn = null, bool? certificateHasPrivateKey = null, string certificateNonce = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName)); - Argument.AssertNotNull(ifMatch, nameof(ifMatch)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateVerifyCertificateRequest(subscriptionId, resourceGroupName, provisioningServiceName, certificateName, ifMatch, content, certificateCommonName, certificateRawBytes, certificateIsVerified, certificatePurpose, certificateCreatedOn, certificateLastUpdatedOn, certificateHasPrivateKey, certificateNonce); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesCertificateData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServicesCertificateData.DeserializeDeviceProvisioningServicesCertificateData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/GroupIdInformationsRestOperations.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/GroupIdInformationsRestOperations.cs index 85edf932ba83..e8b2ad0401f6 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/GroupIdInformationsRestOperations.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/GroupIdInformationsRestOperations.cs @@ -6,58 +6,44 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.DeviceProvisioningServices.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal partial class GroupIdInformationsRestOperations + internal partial class GroupIdInformations { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of GroupIdInformationsRestOperations. - /// 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 GroupIdInformationsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of GroupIdInformations for mocking. + protected GroupIdInformations() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-02-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetPrivateLinkResourcesRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string groupId) + /// Initializes a new instance of GroupIdInformations. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal GroupIdInformations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - 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.Devices/provisioningServices/", false); - uri.AppendPath(resourceName, true); - uri.AppendPath("/privateLinkResources/", false); - uri.AppendPath(groupId, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetPrivateLinkResourcesRequest(string subscriptionId, string resourceGroupName, string resourceName, string groupId) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetPrivateLinkResourcesRequest(string subscriptionId, string resourceGroupName, string resourceName, string groupId, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -68,99 +54,17 @@ internal HttpMessage CreateGetPrivateLinkResourcesRequest(string subscriptionId, uri.AppendPath("/privateLinkResources/", false); uri.AppendPath(groupId, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get the specified private link resource for the given provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private link resource. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetPrivateLinkResourcesAsync(string subscriptionId, string resourceGroupName, string resourceName, string groupId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - - using var message = CreateGetPrivateLinkResourcesRequest(subscriptionId, resourceGroupName, resourceName, groupId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesPrivateLinkResourceData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServicesPrivateLinkResourceData.DeserializeDeviceProvisioningServicesPrivateLinkResourceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServicesPrivateLinkResourceData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get the specified private link resource for the given provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private link resource. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response GetPrivateLinkResources(string subscriptionId, string resourceGroupName, string resourceName, string groupId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - - using var message = CreateGetPrivateLinkResourcesRequest(subscriptionId, resourceGroupName, resourceName, groupId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesPrivateLinkResourceData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServicesPrivateLinkResourceData.DeserializeDeviceProvisioningServicesPrivateLinkResourceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServicesPrivateLinkResourceData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListPrivateLinkResourcesRequestUri(string subscriptionId, string resourceGroupName, string resourceName) + internal HttpMessage CreateGetPrivateLinkResourcesRequest(string subscriptionId, string resourceGroupName, string resourceName, RequestContext context) { - 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.Devices/provisioningServices/", false); - uri.AppendPath(resourceName, true); - uri.AppendPath("/privateLinkResources", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListPrivateLinkResourcesRequest(string subscriptionId, string resourceGroupName, string resourceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -170,68 +74,12 @@ internal HttpMessage CreateListPrivateLinkResourcesRequest(string subscriptionId uri.AppendPath(resourceName, true); uri.AppendPath("/privateLinkResources", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// List private link resources for the given provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListPrivateLinkResourcesAsync(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - - using var message = CreateListPrivateLinkResourcesRequest(subscriptionId, resourceGroupName, resourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - PrivateLinkResources value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = PrivateLinkResources.DeserializePrivateLinkResources(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List private link resources for the given provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListPrivateLinkResources(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - - using var message = CreateListPrivateLinkResourcesRequest(subscriptionId, resourceGroupName, resourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - PrivateLinkResources value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = PrivateLinkResources.DeserializePrivateLinkResources(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/IotDpsResourceRestOperations.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/IotDpsResourceRestOperations.cs index c5e9f99a3173..66aedc607db6 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/IotDpsResourceRestOperations.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/IotDpsResourceRestOperations.cs @@ -6,120 +6,57 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.DeviceProvisioningServices.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal partial class IotDpsResourceRestOperations + internal partial class IotDpsResource { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of IotDpsResourceRestOperations. - /// 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 IotDpsResourceRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of IotDpsResource for mocking. + protected IotDpsResource() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-02-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateCheckDeviceProvisioningServicesNameAvailabilityRequestUri(string subscriptionId, DeviceProvisioningServicesNameAvailabilityContent content) + /// Initializes a new instance of IotDpsResource. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal IotDpsResource(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateCheckDeviceProvisioningServicesNameAvailabilityRequest(string subscriptionId, DeviceProvisioningServicesNameAvailabilityContent content) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateCheckDeviceProvisioningServicesNameAvailabilityRequest(string subscriptionId, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; 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); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; return message; } - - /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable. - /// 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> CheckDeviceProvisioningServicesNameAvailabilityAsync(string subscriptionId, DeviceProvisioningServicesNameAvailabilityContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCheckDeviceProvisioningServicesNameAvailabilityRequest(subscriptionId, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesNameAvailabilityResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServicesNameAvailabilityResult.DeserializeDeviceProvisioningServicesNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable. - /// 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 CheckDeviceProvisioningServicesNameAvailability(string subscriptionId, DeviceProvisioningServicesNameAvailabilityContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCheckDeviceProvisioningServicesNameAvailabilityRequest(subscriptionId, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesNameAvailabilityResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServicesNameAvailabilityResult.DeserializeDeviceProvisioningServicesNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs index 3110e5fb5f42..d72920cc39ba 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs @@ -6,143 +6,44 @@ #nullable disable using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal partial class PrivateEndpointConnectionsRestOperations + internal partial class PrivateEndpointConnections { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of PrivateEndpointConnectionsRestOperations. - /// 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 PrivateEndpointConnectionsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) - { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-02-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetPrivateEndpointConnectionRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName) + /// Initializes a new instance of PrivateEndpointConnections for mocking. + protected PrivateEndpointConnections() { - 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.Devices/provisioningServices/", false); - uri.AppendPath(resourceName, true); - uri.AppendPath("/privateEndpointConnections/", false); - uri.AppendPath(privateEndpointConnectionName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetPrivateEndpointConnectionRequest(string subscriptionId, string resourceGroupName, string resourceName, 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.Devices/provisioningServices/", false); - uri.AppendPath(resourceName, 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; } - /// Get private endpoint connection properties. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private endpoint connection. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetPrivateEndpointConnectionAsync(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + /// Initializes a new instance of PrivateEndpointConnections. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal PrivateEndpointConnections(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - - using var message = CreateGetPrivateEndpointConnectionRequest(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesPrivateEndpointConnectionData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServicesPrivateEndpointConnectionData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get private endpoint connection properties. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private endpoint connection. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response GetPrivateEndpointConnection(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetPrivateEndpointConnectionRequest(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesPrivateEndpointConnectionData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServicesPrivateEndpointConnectionData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateCreateOrUpdatePrivateEndpointConnectionRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData data) + internal HttpMessage CreateGetPrivateEndpointConnectionRequest(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -153,15 +54,17 @@ internal RequestUriBuilder CreateCreateOrUpdatePrivateEndpointConnectionRequestU uri.AppendPath("/privateEndpointConnections/", false); uri.AppendPath(privateEndpointConnectionName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdatePrivateEndpointConnectionRequest(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData data) + internal HttpMessage CreateCreateOrUpdatePrivateEndpointConnectionRequest(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -172,96 +75,19 @@ internal HttpMessage CreateCreateOrUpdatePrivateEndpointConnectionRequest(string uri.AppendPath("/privateEndpointConnections/", false); uri.AppendPath(privateEndpointConnectionName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; 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.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create or update the status of a private endpoint connection with the specified name. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private endpoint connection. - /// The private endpoint connection with updated properties. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task CreateOrUpdatePrivateEndpointConnectionAsync(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdatePrivateEndpointConnectionRequest(subscriptionId, resourceGroupName, resourceName, 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); - } - } - - /// Create or update the status of a private endpoint connection with the specified name. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private endpoint connection. - /// The private endpoint connection with updated properties. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdatePrivateEndpointConnection(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, DeviceProvisioningServicesPrivateEndpointConnectionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdatePrivateEndpointConnectionRequest(subscriptionId, resourceGroupName, resourceName, 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 CreateDeletePrivateEndpointConnectionRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName) + internal HttpMessage CreateDeletePrivateEndpointConnectionRequest(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, RequestContext context) { - 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.Devices/provisioningServices/", false); - uri.AppendPath(resourceName, true); - uri.AppendPath("/privateEndpointConnections/", false); - uri.AppendPath(privateEndpointConnectionName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeletePrivateEndpointConnectionRequest(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -272,89 +98,17 @@ internal HttpMessage CreateDeletePrivateEndpointConnectionRequest(string subscri uri.AppendPath("/privateEndpointConnections/", false); uri.AppendPath(privateEndpointConnectionName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Delete private endpoint connection with the specified name. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private endpoint connection. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task DeletePrivateEndpointConnectionAsync(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - - using var message = CreateDeletePrivateEndpointConnectionRequest(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete private endpoint connection with the specified name. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The name of the private endpoint connection. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response DeletePrivateEndpointConnection(string subscriptionId, string resourceGroupName, string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); - - using var message = CreateDeletePrivateEndpointConnectionRequest(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListPrivateEndpointConnectionsRequestUri(string subscriptionId, string resourceGroupName, string resourceName) + internal HttpMessage CreateGetPrivateEndpointConnectionsRequest(string subscriptionId, string resourceGroupName, string resourceName, RequestContext context) { - 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.Devices/provisioningServices/", false); - uri.AppendPath(resourceName, true); - uri.AppendPath("/privateEndpointConnections", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListPrivateEndpointConnectionsRequest(string subscriptionId, string resourceGroupName, string resourceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -364,78 +118,12 @@ internal HttpMessage CreateListPrivateEndpointConnectionsRequest(string subscrip uri.AppendPath(resourceName, true); uri.AppendPath("/privateEndpointConnections", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// List private endpoint connection properties. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task>> ListPrivateEndpointConnectionsAsync(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - - using var message = CreateListPrivateEndpointConnectionsRequest(subscriptionId, resourceGroupName, resourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - IReadOnlyList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) - { - array.Add(DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(item)); - } - value = array; - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List private endpoint connection properties. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response> ListPrivateEndpointConnections(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - - using var message = CreateListPrivateEndpointConnectionsRequest(subscriptionId, resourceGroupName, resourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - IReadOnlyList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - List array = new List(); - foreach (var item in document.RootElement.EnumerateArray()) - { - array.Add(DeviceProvisioningServicesPrivateEndpointConnectionData.DeserializeDeviceProvisioningServicesPrivateEndpointConnectionData(item)); - } - value = array; - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/ProvisioningServiceDescriptionsRestOperations.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/ProvisioningServiceDescriptionsRestOperations.cs index 25d983adfad5..9871927fc9f3 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/ProvisioningServiceDescriptionsRestOperations.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/src/Generated/RestOperations/ProvisioningServiceDescriptionsRestOperations.cs @@ -6,135 +6,44 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.DeviceProvisioningServices.Models; namespace Azure.ResourceManager.DeviceProvisioningServices { - internal partial class ProvisioningServiceDescriptionsRestOperations + internal partial class ProvisioningServiceDescriptions { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of ProvisioningServiceDescriptionsRestOperations. - /// 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 ProvisioningServiceDescriptionsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of ProvisioningServiceDescriptions for mocking. + protected ProvisioningServiceDescriptions() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-02-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; } - /// Get the metadata of the provisioning service without SAS keys. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) + /// Initializes a new instance of ProvisioningServiceDescriptions. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal ProvisioningServiceDescriptions(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, provisioningServiceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServiceData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServiceData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get the metadata of the provisioning service without SAS keys. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, provisioningServiceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServiceData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServiceData.DeserializeDeviceProvisioningServiceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DeviceProvisioningServiceData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName, DeviceProvisioningServiceData data) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -143,15 +52,17 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath("/providers/Microsoft.Devices/provisioningServices/", false); uri.AppendPath(provisioningServiceName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, DeviceProvisioningServiceData data) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -160,90 +71,19 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/providers/Microsoft.Devices/provisioningServices/", false); uri.AppendPath(provisioningServiceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; 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.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values in a new body to update the provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Description of the provisioning service to create or update. - /// 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 provisioningServiceName, DeviceProvisioningServiceData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, provisioningServiceName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values in a new body to update the provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Description of the provisioning service to create or update. - /// 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 provisioningServiceName, DeviceProvisioningServiceData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, provisioningServiceName, 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 provisioningServiceName, DeviceProvisioningServicePatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContent content, RequestContext context) { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, DeviceProvisioningServicePatch patch) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -252,88 +92,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Devices/provisioningServices/", false); uri.AppendPath(provisioningServiceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; 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.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Updated tag information to set into the provisioning service instance. - /// 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 provisioningServiceName, DeviceProvisioningServicePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, provisioningServiceName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Updated tag information to set into the provisioning service instance. - /// 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 provisioningServiceName, DeviceProvisioningServicePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, provisioningServiceName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -342,84 +113,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.Devices/provisioningServices/", false); uri.AppendPath(provisioningServiceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Deletes the Provisioning Service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, provisioningServiceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - case 404: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Deletes the Provisioning Service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, provisioningServiceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - case 404: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) + internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, string resourceGroupName, RequestContext context) { - 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.Devices/provisioningServices", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -427,165 +130,57 @@ internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, str uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Devices/provisioningServices", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get a list of all provisioning services in the given resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get a list of all provisioning services in the given resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Devices/provisioningServices", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + internal HttpMessage CreateGetBySubscriptionRequest(string subscriptionId, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/providers/Microsoft.Devices/provisioningServices", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all the provisioning services for a given subscription id. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, string subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all the provisioning services for a given subscription id. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListValidSkusRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/skus", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateListValidSkusRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName) + internal HttpMessage CreateGetValidSkusRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -595,91 +190,29 @@ internal HttpMessage CreateListValidSkusRequest(string subscriptionId, string re uri.AppendPath(provisioningServiceName, true); uri.AppendPath("/skus", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Gets the list of valid SKUs and tiers for a provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListValidSkusAsync(string subscriptionId, string resourceGroupName, string provisioningServiceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetValidSkusRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListValidSkusRequest(subscriptionId, resourceGroupName, provisioningServiceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - IotDpsSkuDefinitionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = IotDpsSkuDefinitionListResult.DeserializeIotDpsSkuDefinitionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets the list of valid SKUs and tiers for a provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListValidSkus(string subscriptionId, string resourceGroupName, string provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListValidSkusRequest(subscriptionId, resourceGroupName, provisioningServiceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - IotDpsSkuDefinitionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = IotDpsSkuDefinitionListResult.DeserializeIotDpsSkuDefinitionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListKeysRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/listkeys", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateListKeysRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName) + internal HttpMessage CreateGetKeysRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -689,93 +222,29 @@ internal HttpMessage CreateListKeysRequest(string subscriptionId, string resourc uri.AppendPath(provisioningServiceName, true); uri.AppendPath("/listkeys", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List the primary and secondary keys for a provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetKeysRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string provisioningServiceName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListKeysRequest(subscriptionId, resourceGroupName, provisioningServiceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SharedAccessSignatureAuthorizationRuleListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SharedAccessSignatureAuthorizationRuleListResult.DeserializeSharedAccessSignatureAuthorizationRuleListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List the primary and secondary keys for a provisioning service. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// 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 provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListKeysRequest(subscriptionId, resourceGroupName, provisioningServiceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SharedAccessSignatureAuthorizationRuleListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SharedAccessSignatureAuthorizationRuleListResult.DeserializeSharedAccessSignatureAuthorizationRuleListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetKeyRequestUri(string subscriptionId, string resourceGroupName, string provisioningServiceName, string keyName) - { - 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.Devices/provisioningServices/", false); - uri.AppendPath(provisioningServiceName, true); - uri.AppendPath("/keys/", false); - uri.AppendPath(keyName, true); - uri.AppendPath("/listkeys", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateGetKeyRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string keyName) + internal HttpMessage CreateGetKeyRequest(string subscriptionId, string resourceGroupName, string provisioningServiceName, string keyName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -787,396 +256,12 @@ internal HttpMessage CreateGetKeyRequest(string subscriptionId, string resourceG uri.AppendPath(keyName, true); uri.AppendPath("/listkeys", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// List primary and secondary keys for a specific key name. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Logical key name to get key-values for. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> GetKeyAsync(string subscriptionId, string resourceGroupName, string provisioningServiceName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateGetKeyRequest(subscriptionId, resourceGroupName, provisioningServiceName, keyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesSharedAccessKey value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DeviceProvisioningServicesSharedAccessKey.DeserializeDeviceProvisioningServicesSharedAccessKey(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List primary and secondary keys for a specific key name. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// Name of the provisioning service to retrieve. - /// Logical key name to get key-values for. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response GetKey(string subscriptionId, string resourceGroupName, string provisioningServiceName, string keyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); - - using var message = CreateGetKeyRequest(subscriptionId, resourceGroupName, provisioningServiceName, keyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DeviceProvisioningServicesSharedAccessKey value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DeviceProvisioningServicesSharedAccessKey.DeserializeDeviceProvisioningServicesSharedAccessKey(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a list of all provisioning services in the given resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get a list of all provisioning services in the given resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// List all the provisioning services for a given subscription id. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all the provisioning services for a given subscription id. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ProvisioningServiceDescriptionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ProvisioningServiceDescriptionListResult.DeserializeProvisioningServiceDescriptionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListValidSkusNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListValidSkusNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets the list of valid SKUs and tiers for a provisioning service. - /// 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. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListValidSkusNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListValidSkusNextPageRequest(nextLink, subscriptionId, resourceGroupName, provisioningServiceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - IotDpsSkuDefinitionListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = IotDpsSkuDefinitionListResult.DeserializeIotDpsSkuDefinitionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets the list of valid SKUs and tiers for a provisioning service. - /// 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. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListValidSkusNextPage(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListValidSkusNextPageRequest(nextLink, subscriptionId, resourceGroupName, provisioningServiceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - IotDpsSkuDefinitionListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = IotDpsSkuDefinitionListResult.DeserializeIotDpsSkuDefinitionListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListKeysNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListKeysNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName) - { - 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); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// List the primary and secondary keys for a provisioning service. - /// 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. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListKeysNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListKeysNextPageRequest(nextLink, subscriptionId, resourceGroupName, provisioningServiceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SharedAccessSignatureAuthorizationRuleListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SharedAccessSignatureAuthorizationRuleListResult.DeserializeSharedAccessSignatureAuthorizationRuleListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List the primary and secondary keys for a provisioning service. - /// 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. - /// Name of the provisioning service to retrieve. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListKeysNextPage(string nextLink, string subscriptionId, string resourceGroupName, string provisioningServiceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(provisioningServiceName, nameof(provisioningServiceName)); - - using var message = CreateListKeysNextPageRequest(nextLink, subscriptionId, resourceGroupName, provisioningServiceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SharedAccessSignatureAuthorizationRuleListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SharedAccessSignatureAuthorizationRuleListResult.DeserializeSharedAccessSignatureAuthorizationRuleListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/tsp-location.yaml b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/tsp-location.yaml index b1bad5fb9c54..1f422e9da9a2 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/tsp-location.yaml +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/tsp-location.yaml @@ -1,5 +1,6 @@ directory: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/DeviceProvisioningServices repo: Azure/azure-rest-api-specs -commit: 6267b64842af3d744c5b092a3f3beef49729ad6d +commit: ab63b2c49ab779a8a993afe49ea3aa1a78ecabb0 additionalDirectories: [] -emitterPackageJsonPath: eng/legacy-emitter-package.json +# emitterPackageJsonPath: eng/legacy-emitter-package.json +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"