diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Azure.ResourceManager.DataBox.csproj b/sdk/databox/Azure.ResourceManager.DataBox/src/Azure.ResourceManager.DataBox.csproj index 68d582d347a6..a628835c7e57 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Azure.ResourceManager.DataBox.csproj +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Azure.ResourceManager.DataBox.csproj @@ -6,7 +6,6 @@ Azure.ResourceManager.DataBox Microsoft Azure Resource Manager client SDK for Azure resource provider Microsoft.DataBox. azure;management;arm;resource manager;databox - true true diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Custom/ArmDataBoxModelFactory.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Custom/ArmDataBoxModelFactory.cs index 4b83644c71fe..f86ff6514a3f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Custom/ArmDataBoxModelFactory.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Custom/ArmDataBoxModelFactory.cs @@ -114,7 +114,7 @@ public static MitigateJobContent MitigateJobContent(CustomerResolutionCode custo { serialNumberCustomerResolutionMap ??= new Dictionary(); - return new MitigateJobContent(customerResolutionCode, serialNumberCustomerResolutionMap, serializedAdditionalRawData: null); + return new MitigateJobContent(customerResolutionCode, serialNumberCustomerResolutionMap, additionalBinaryDataProperties: null); } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ArmDataBoxModelFactory.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ArmDataBoxModelFactory.cs index a0c455622e23..e69a9c5a2514 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ArmDataBoxModelFactory.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ArmDataBoxModelFactory.cs @@ -7,23 +7,24 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; +using Azure; using Azure.Core; +using Azure.ResourceManager.DataBox; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DataBox.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmDataBoxModelFactory { - /// 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. /// Type of the data transfer. /// Describes whether the job is cancellable or not. /// Describes whether the job is deletable or not. @@ -35,53 +36,54 @@ public static partial class ArmDataBoxModelFactory /// Name of the stage where delay might be present. /// Time at which the job was started in UTC ISO 8601 format. /// Top level error for the job. - /// - /// Details of a job run. This field will only be sent for expand details filter. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// Details of a job run. This field will only be sent for expand details filter. /// Reason for cancellation. /// Delivery type of Job. - /// Delivery Info of Job. /// Flag to indicate cancellation of scheduled job. /// Flag to indicate if all devices associated with the job are lost. + /// Scheduled date time. /// The sku type. /// Msi identity of the resource. /// A new instance for mocking. - public static DataBoxJobData DataBoxJobData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, DataBoxJobTransferType transferType = default, bool? isCancellable = null, bool? isDeletable = null, bool? isShippingAddressEditable = null, ReverseShippingDetailsEditStatus? reverseShippingDetailsUpdate = null, ReverseTransportPreferenceEditStatus? reverseTransportPreferenceUpdate = null, bool? isPrepareToShipEnabled = null, DataBoxStageName? status = null, DataBoxStageName? delayedStage = null, DateTimeOffset? startOn = null, ResponseError error = null, DataBoxBasicJobDetails details = null, string cancellationReason = null, JobDeliveryType? deliveryType = null, DateTimeOffset? deliveryInfoScheduledOn = null, bool? isCancellableWithoutFee = null, bool? areAllDevicesLost = null, DataBoxSku sku = null, ManagedServiceIdentity identity = null) + public static DataBoxJobData DataBoxJobData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, DataBoxJobTransferType? transferType = default, bool? isCancellable = default, bool? isDeletable = default, bool? isShippingAddressEditable = default, ReverseShippingDetailsEditStatus? reverseShippingDetailsUpdate = default, ReverseTransportPreferenceEditStatus? reverseTransportPreferenceUpdate = default, bool? isPrepareToShipEnabled = default, DataBoxStageName? status = default, DataBoxStageName? delayedStage = default, DateTimeOffset? startOn = default, ResponseError error = default, DataBoxBasicJobDetails details = default, string cancellationReason = default, JobDeliveryType? deliveryType = default, bool? isCancellableWithoutFee = default, bool? areAllDevicesLost = default, DateTimeOffset? deliveryInfoScheduledOn = default, DataBoxSku sku = default, ResourceIdentity identity = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new DataBoxJobData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - transferType, - isCancellable, - isDeletable, - isShippingAddressEditable, - reverseShippingDetailsUpdate, - reverseTransportPreferenceUpdate, - isPrepareToShipEnabled, - status, - delayedStage, - startOn, - error, - details, - cancellationReason, - deliveryType, - deliveryInfoScheduledOn != null ? new JobDeliveryInfo(deliveryInfoScheduledOn, serializedAdditionalRawData: null) : null, - isCancellableWithoutFee, - areAllDevicesLost, + transferType is null && isCancellable is null && isDeletable is null && isShippingAddressEditable is null && reverseShippingDetailsUpdate is null && reverseTransportPreferenceUpdate is null && isPrepareToShipEnabled is null && status is null && delayedStage is null && startOn is null && error is null && details is null && cancellationReason is null && deliveryType is null && isCancellableWithoutFee is null && areAllDevicesLost is null && deliveryInfoScheduledOn is null ? default : new JobProperties( + transferType.Value, + isCancellable, + isDeletable, + isShippingAddressEditable, + reverseShippingDetailsUpdate, + reverseTransportPreferenceUpdate, + isPrepareToShipEnabled, + status, + delayedStage, + startOn, + error, + details, + cancellationReason, + deliveryType, + new JobDeliveryInfo(deliveryInfoScheduledOn, null), + isCancellableWithoutFee, + areAllDevicesLost, + null), sku, - identity, - serializedAdditionalRawData: null); + identity); } - /// Initializes a new instance of . + /// + /// Job details. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// /// List of stages that run in the job. /// Contact details for notification and shipping. /// Shipping address of the customer. @@ -89,13 +91,10 @@ public static DataBoxJobData DataBoxJobData(ResourceIdentifier id = null, string /// Return package shipping details. /// Details of the data to be imported into azure. /// Details of the data to be exported from azure. + /// Indicates the type of job details. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -103,46 +102,42 @@ public static DataBoxJobData DataBoxJobData(ResourceIdentifier id = null, string /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. /// A new instance for mocking. - public static DataBoxBasicJobDetails DataBoxBasicJobDetails(IEnumerable jobStages = null, DataBoxContactDetails contactDetails = null, DataBoxShippingAddress shippingAddress = null, PackageShippingDetails deliveryPackage = null, PackageShippingDetails returnPackage = null, IEnumerable dataImportDetails = null, IEnumerable dataExportDetails = null, DataBoxOrderPreferences preferences = null, ReverseShippingDetails reverseShippingDetails = null, IEnumerable copyLogDetails = null, string reverseShipmentLabelSasKey = null, string chainOfCustodySasKey = null, DeviceErasureDetails deviceErasureDetails = null, DataBoxKeyEncryptionKey keyEncryptionKey = null, int? expectedDataSizeInTerabytes = null, IEnumerable actions = null, LastMitigationActionOnJob lastMitigationActionOnJob = null, DataCenterAddressResult dataCenterAddress = null, DataCenterCode? dataCenterCode = null) + public static DataBoxBasicJobDetails DataBoxBasicJobDetails(IEnumerable jobStages = default, DataBoxContactDetails contactDetails = default, DataBoxShippingAddress shippingAddress = default, PackageShippingDetails deliveryPackage = default, PackageShippingDetails returnPackage = default, IEnumerable dataImportDetails = default, IEnumerable dataExportDetails = default, string jobDetailsType = default, DataBoxOrderPreferences preferences = default, ReverseShippingDetails reverseShippingDetails = default, IEnumerable copyLogDetails = default, string reverseShipmentLabelSasKey = default, string chainOfCustodySasKey = default, DeviceErasureDetails deviceErasureDetails = default, DataBoxKeyEncryptionKey keyEncryptionKey = default, int? expectedDataSizeInTerabytes = default, IEnumerable actions = default, LastMitigationActionOnJob lastMitigationActionOnJob = default, DataCenterAddressResult dataCenterAddress = default, DataCenterCode? dataCenterCode = default) { - jobStages ??= new List(); - dataImportDetails ??= new List(); - dataExportDetails ??= new List(); - copyLogDetails ??= new List(); - actions ??= new List(); + jobStages ??= new ChangeTrackingList(); + dataImportDetails ??= new ChangeTrackingList(); + dataExportDetails ??= new ChangeTrackingList(); + copyLogDetails ??= new ChangeTrackingList(); + actions ??= new ChangeTrackingList(); - return new UnknownJobDetails( - jobStages?.ToList(), + return new UnknownDataBoxBasicJobDetails( + jobStages.ToList(), contactDetails, shippingAddress, deliveryPackage, returnPackage, - dataImportDetails?.ToList(), - dataExportDetails?.ToList(), - default, + dataImportDetails.ToList(), + dataExportDetails.ToList(), + jobDetailsType.ToDataBoxOrderType(), preferences, reverseShippingDetails, - copyLogDetails?.ToList(), + copyLogDetails.ToList(), reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, - actions?.ToList(), + actions.ToList(), lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Job stages. /// Name of the job stage. /// Display name of the job stage. /// Status of the job stage. @@ -150,9 +145,9 @@ public static DataBoxBasicJobDetails DataBoxBasicJobDetails(IEnumerable Job Stage Details. /// Delay information for the job stages. /// A new instance for mocking. - public static DataBoxJobStage DataBoxJobStage(DataBoxStageName? stageName = null, string displayName = null, DataBoxStageStatus? stageStatus = null, DateTimeOffset? stageTime = null, BinaryData jobStageDetails = null, IEnumerable delayInformation = null) + public static DataBoxJobStage DataBoxJobStage(DataBoxStageName? stageName = default, string displayName = default, DataBoxStageStatus? stageStatus = default, DateTimeOffset? stageTime = default, BinaryData jobStageDetails = default, IEnumerable delayInformation = default) { - delayInformation ??= new List(); + delayInformation ??= new ChangeTrackingList(); return new DataBoxJobStage( stageName, @@ -160,18 +155,18 @@ public static DataBoxJobStage DataBoxJobStage(DataBoxStageName? stageName = null stageStatus, stageTime, jobStageDetails, - delayInformation?.ToList(), - serializedAdditionalRawData: null); + delayInformation.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Job Delay Notification details. /// Status of notification. /// Delay Error code. /// Description of the delay. /// Timestamp when the delay notification was created. /// Timestamp when the delay notification was resolved. /// A new instance for mocking. - public static JobDelayDetails JobDelayDetails(DelayNotificationStatus? status = null, PortalDelayErrorCode? errorCode = null, string description = null, DateTimeOffset? startOn = null, DateTimeOffset? resolutionOn = null) + public static JobDelayDetails JobDelayDetails(DelayNotificationStatus? status = default, PortalDelayErrorCode? errorCode = default, string description = default, DateTimeOffset? startOn = default, DateTimeOffset? resolutionOn = default) { return new JobDelayDetails( status, @@ -179,29 +174,114 @@ public static JobDelayDetails JobDelayDetails(DelayNotificationStatus? status = description, startOn, resolutionOn, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Contact Details. + /// Contact name of the person. + /// Phone number of the contact person. + /// Phone extension number of the contact person. + /// Mobile number of the contact person. + /// List of Email-ids to be notified about job progress. + /// Notification preference for a job stage. + /// A new instance for mocking. + public static DataBoxContactDetails DataBoxContactDetails(string contactName = default, string phone = default, string phoneExtension = default, string mobile = default, IEnumerable emailList = default, IEnumerable notificationPreference = default) + { + emailList ??= new ChangeTrackingList(); + notificationPreference ??= new ChangeTrackingList(); + + return new DataBoxContactDetails( + contactName, + phone, + phoneExtension, + mobile, + emailList.ToList(), + notificationPreference.ToList(), + additionalBinaryDataProperties: null); + } + + /// package shipping details. /// Url where shipment can be tracked. /// Name of the carrier. /// Tracking Id of shipment. /// A new instance for mocking. - public static PackageShippingDetails PackageShippingDetails(Uri trackingUri = null, string carrierName = null, string trackingId = null) + public static PackageShippingDetails PackageShippingDetails(Uri trackingUri = default, string carrierName = default, string trackingId = default) { - return new PackageShippingDetails(trackingUri, carrierName, trackingId, serializedAdditionalRawData: null); + return new PackageShippingDetails(trackingUri, carrierName, trackingId, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Details of the filtering the transfer of data. + /// Type of the account of data. + /// Filter details to transfer blobs. + /// Filter details to transfer Azure files. + /// Details of the filter files to be used for data transfer. + /// A new instance for mocking. + public static TransferFilterDetails TransferFilterDetails(DataAccountType dataAccountType = default, BlobFilterDetails blobFilterDetails = default, AzureFileFilterDetails azureFileFilterDetails = default, IEnumerable filterFileDetails = default) + { + filterFileDetails ??= new ChangeTrackingList(); + + return new TransferFilterDetails(dataAccountType, blobFilterDetails, azureFileFilterDetails, filterFileDetails.ToList(), additionalBinaryDataProperties: null); + } + + /// Filter details to transfer Azure Blobs. + /// Prefix list of the Azure blobs to be transferred. + /// List of full path of the blobs to be transferred. + /// List of blob containers to be transferred. + /// A new instance for mocking. + public static BlobFilterDetails BlobFilterDetails(IEnumerable blobPrefixList = default, IEnumerable blobPathList = default, IEnumerable containerList = default) + { + blobPrefixList ??= new ChangeTrackingList(); + blobPathList ??= new ChangeTrackingList(); + containerList ??= new ChangeTrackingList(); + + return new BlobFilterDetails(blobPrefixList.ToList(), blobPathList.ToList(), containerList.ToList(), additionalBinaryDataProperties: null); + } + + /// Filter details to transfer Azure files. + /// Prefix list of the Azure files to be transferred. + /// List of full path of the files to be transferred. + /// List of file shares to be transferred. + /// A new instance for mocking. + public static AzureFileFilterDetails AzureFileFilterDetails(IEnumerable filePrefixList = default, IEnumerable filePathList = default, IEnumerable fileShareList = default) + { + filePrefixList ??= new ChangeTrackingList(); + filePathList ??= new ChangeTrackingList(); + fileShareList ??= new ChangeTrackingList(); + + return new AzureFileFilterDetails(filePrefixList.ToList(), filePathList.ToList(), fileShareList.ToList(), additionalBinaryDataProperties: null); + } + + /// Preferences related to the order. + /// Preferred data center region. + /// Preferences related to the shipment logistics of the sku. + /// Optional Preferences related to the reverse shipment logistics of the sku. + /// Preferences related to the Encryption. + /// Preferences related to the Access Tier of storage accounts. + /// A new instance for mocking. + public static DataBoxOrderPreferences DataBoxOrderPreferences(IEnumerable preferredDataCenterRegion = default, TransportPreferences transportPreferences = default, TransportPreferences reverseTransportPreferences = default, DataBoxEncryptionPreferences encryptionPreferences = default, IEnumerable storageAccountAccessTierPreferences = default) + { + preferredDataCenterRegion ??= new ChangeTrackingList(); + storageAccountAccessTierPreferences ??= new ChangeTrackingList(); + + return new DataBoxOrderPreferences( + preferredDataCenterRegion.ToList(), + transportPreferences, + reverseTransportPreferences, + encryptionPreferences, + storageAccountAccessTierPreferences.ToList(), + additionalBinaryDataProperties: null); + } + + /// Preferences related to the shipment logistics of the sku. /// Indicates Shipment Logistics type that the customer preferred. /// Read only property which indicates whether transport preferences has been updated or not after device is prepared. /// A new instance for mocking. - public static TransportPreferences TransportPreferences(TransportShipmentType preferredShipmentType = default, bool? isUpdated = null) + public static TransportPreferences TransportPreferences(TransportShipmentType preferredShipmentType = default, bool? isUpdated = default) { - return new TransportPreferences(preferredShipmentType, isUpdated, serializedAdditionalRawData: null); + return new TransportPreferences(preferredShipmentType, isUpdated, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Reverse Shipping Address and contact details for a job. /// Contact Info. /// Shipping address where customer wishes to receive the device. /// @@ -209,65 +289,65 @@ public static TransportPreferences TransportPreferences(TransportShipmentType pr /// Read only field /// /// A new instance for mocking. - public static ReverseShippingDetails ReverseShippingDetails(ContactInfo contactDetails = null, DataBoxShippingAddress shippingAddress = null, bool? isUpdated = null) + public static ReverseShippingDetails ReverseShippingDetails(ContactInfo contactDetails = default, DataBoxShippingAddress shippingAddress = default, bool? isUpdated = default) { - return new ReverseShippingDetails(contactDetails, shippingAddress, isUpdated, serializedAdditionalRawData: null); + return new ReverseShippingDetails(contactDetails, shippingAddress, isUpdated, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Copy log details for a storage account of a DataBox job. /// Account name. /// Link for copy logs. /// Link for copy verbose logs. This will be set only when LogCollectionLevel is set to Verbose. /// A new instance for mocking. - public static DataBoxAccountCopyLogDetails DataBoxAccountCopyLogDetails(string accountName = null, string copyLogLink = null, string copyVerboseLogLink = null) + public static DataBoxAccountCopyLogDetails DataBoxAccountCopyLogDetails(string accountName = default, string copyLogLink = default, string copyVerboseLogLink = default) { - return new DataBoxAccountCopyLogDetails(DataBoxOrderType.DataBox, serializedAdditionalRawData: null, accountName, copyLogLink, copyVerboseLogLink); + return new DataBoxAccountCopyLogDetails(DataBoxOrderType.DataBox, additionalBinaryDataProperties: null, accountName, copyLogLink, copyVerboseLogLink); } - /// Initializes a new instance of . + /// Copy Log Details for customer disk. /// Disk Serial Number. /// Link for copy error logs. /// Link for copy verbose logs. /// A new instance for mocking. - public static DataBoxCustomerDiskCopyLogDetails DataBoxCustomerDiskCopyLogDetails(string serialNumber = null, string errorLogLink = null, string verboseLogLink = null) + public static DataBoxCustomerDiskCopyLogDetails DataBoxCustomerDiskCopyLogDetails(string serialNumber = default, string errorLogLink = default, string verboseLogLink = default) { - return new DataBoxCustomerDiskCopyLogDetails(DataBoxOrderType.DataBoxCustomerDisk, serializedAdditionalRawData: null, serialNumber, errorLogLink, verboseLogLink); + return new DataBoxCustomerDiskCopyLogDetails(DataBoxOrderType.DataBoxCustomerDisk, additionalBinaryDataProperties: null, serialNumber, errorLogLink, verboseLogLink); } - /// Initializes a new instance of . + /// Copy Log Details for a disk. /// Disk Serial Number. /// Link for copy error logs. /// Link for copy verbose logs. /// A new instance for mocking. - public static DataBoxDiskCopyLogDetails DataBoxDiskCopyLogDetails(string diskSerialNumber = null, string errorLogLink = null, string verboseLogLink = null) + public static DataBoxDiskCopyLogDetails DataBoxDiskCopyLogDetails(string diskSerialNumber = default, string errorLogLink = default, string verboseLogLink = default) { - return new DataBoxDiskCopyLogDetails(DataBoxOrderType.DataBoxDisk, serializedAdditionalRawData: null, diskSerialNumber, errorLogLink, verboseLogLink); + return new DataBoxDiskCopyLogDetails(DataBoxOrderType.DataBoxDisk, additionalBinaryDataProperties: null, diskSerialNumber, errorLogLink, verboseLogLink); } - /// Initializes a new instance of . + /// Copy log details for a storage account for Databox heavy. /// Account name. /// Link for copy logs. /// Link for copy verbose logs. This will be set only when the LogCollectionLevel is set to verbose. /// A new instance for mocking. - public static DataBoxHeavyAccountCopyLogDetails DataBoxHeavyAccountCopyLogDetails(string accountName = null, IEnumerable copyLogLink = null, IEnumerable copyVerboseLogLink = null) + public static DataBoxHeavyAccountCopyLogDetails DataBoxHeavyAccountCopyLogDetails(string accountName = default, IEnumerable copyLogLink = default, IEnumerable copyVerboseLogLink = default) { - copyLogLink ??= new List(); - copyVerboseLogLink ??= new List(); + copyLogLink ??= new ChangeTrackingList(); + copyVerboseLogLink ??= new ChangeTrackingList(); - return new DataBoxHeavyAccountCopyLogDetails(DataBoxOrderType.DataBoxHeavy, serializedAdditionalRawData: null, accountName, copyLogLink?.ToList(), copyVerboseLogLink?.ToList()); + return new DataBoxHeavyAccountCopyLogDetails(DataBoxOrderType.DataBoxHeavy, additionalBinaryDataProperties: null, accountName, copyLogLink.ToList(), copyVerboseLogLink.ToList()); } - /// Initializes a new instance of . + /// Device erasure details with erasure completion status, secure erasure sas key and erasureordestructionlog sas key. /// Holds the device erasure completion status. /// Shared access key to download cleanup or destruction certificate for device. /// Shared access key to download secure erasure certificate for the device. /// A new instance for mocking. - public static DeviceErasureDetails DeviceErasureDetails(DataBoxStageStatus? deviceErasureStatus = null, string erasureOrDestructionCertificateSasKey = null, string secureErasureCertificateSasKey = null) + public static DeviceErasureDetails DeviceErasureDetails(DataBoxStageStatus? deviceErasureStatus = default, string erasureOrDestructionCertificateSasKey = default, string secureErasureCertificateSasKey = default) { - return new DeviceErasureDetails(deviceErasureStatus, erasureOrDestructionCertificateSasKey, secureErasureCertificateSasKey, serializedAdditionalRawData: null); + return new DeviceErasureDetails(deviceErasureStatus, erasureOrDestructionCertificateSasKey, secureErasureCertificateSasKey, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Last Mitigation Action Performed On Job. /// Action performed date time. /// /// Action performed by customer, @@ -275,35 +355,39 @@ public static DeviceErasureDetails DeviceErasureDetails(DataBoxStageStatus? devi /// /// Resolution code provided by customer. /// A new instance for mocking. - public static LastMitigationActionOnJob LastMitigationActionOnJob(DateTimeOffset? actionPerformedOn = null, bool? isPerformedByCustomer = null, CustomerResolutionCode? customerResolution = null) + public static LastMitigationActionOnJob LastMitigationActionOnJob(DateTimeOffset? actionPerformedOn = default, bool? isPerformedByCustomer = default, CustomerResolutionCode? customerResolution = default) { - return new LastMitigationActionOnJob(actionPerformedOn, isPerformedByCustomer, customerResolution, serializedAdditionalRawData: null); + return new LastMitigationActionOnJob(actionPerformedOn, isPerformedByCustomer, customerResolution, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// + /// Datacenter address for given storage location. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + /// Data center address type. /// List of supported carriers for return shipment. /// Azure Location where the Data Center serves primarily. /// A new instance for mocking. - public static DataCenterAddressResult DataCenterAddressResult(IEnumerable supportedCarriersForReturnShipment = null, AzureLocation? dataCenterAzureLocation = null) + public static DataCenterAddressResult DataCenterAddressResult(string datacenterAddressType = default, IEnumerable supportedCarriersForReturnShipment = default, AzureLocation? dataCenterAzureLocation = default) { - supportedCarriersForReturnShipment ??= new List(); + supportedCarriersForReturnShipment ??= new ChangeTrackingList(); - return new UnknownDataCenterAddressResponse(default, supportedCarriersForReturnShipment?.ToList(), dataCenterAzureLocation, serializedAdditionalRawData: null); + return new UnknownDataCenterAddressResult(datacenterAddressType.ToDatacenterAddressType(), supportedCarriersForReturnShipment.ToList(), dataCenterAzureLocation, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Datacenter instruction for given storage location. /// List of supported carriers for return shipment. /// Azure Location where the Data Center serves primarily. /// Data center communication instruction. /// A new instance for mocking. - public static DataCenterAddressInstructionResult DataCenterAddressInstructionResult(IEnumerable supportedCarriersForReturnShipment = null, AzureLocation? dataCenterAzureLocation = null, string communicationInstruction = null) + public static DataCenterAddressInstructionResult DataCenterAddressInstructionResult(IEnumerable supportedCarriersForReturnShipment = default, AzureLocation? dataCenterAzureLocation = default, string communicationInstruction = default) { - supportedCarriersForReturnShipment ??= new List(); + supportedCarriersForReturnShipment ??= new ChangeTrackingList(); - return new DataCenterAddressInstructionResult(DatacenterAddressType.DatacenterAddressInstruction, supportedCarriersForReturnShipment?.ToList(), dataCenterAzureLocation, serializedAdditionalRawData: null, communicationInstruction); + return new DataCenterAddressInstructionResult(DatacenterAddressType.DatacenterAddressInstruction, supportedCarriersForReturnShipment.ToList(), dataCenterAzureLocation, additionalBinaryDataProperties: null, communicationInstruction); } - /// Initializes a new instance of . + /// Datacenter address for given storage location. /// List of supported carriers for return shipment. /// Azure Location where the Data Center serves primarily. /// Contact person name. @@ -320,15 +404,15 @@ public static DataCenterAddressInstructionResult DataCenterAddressInstructionRes /// Address type. /// Special instruction for shipping. /// A new instance for mocking. - public static DataCenterAddressLocationResult DataCenterAddressLocationResult(IEnumerable supportedCarriersForReturnShipment = null, AzureLocation? dataCenterAzureLocation = null, string contactPersonName = null, string company = null, string street1 = null, string street2 = null, string street3 = null, string city = null, string state = null, string zip = null, string country = null, string phone = null, string phoneExtension = null, string addressType = null, string additionalShippingInformation = null) + public static DataCenterAddressLocationResult DataCenterAddressLocationResult(IEnumerable supportedCarriersForReturnShipment = default, AzureLocation? dataCenterAzureLocation = default, string contactPersonName = default, string company = default, string street1 = default, string street2 = default, string street3 = default, string city = default, string state = default, string zip = default, string country = default, string phone = default, string phoneExtension = default, string addressType = default, string additionalShippingInformation = default) { - supportedCarriersForReturnShipment ??= new List(); + supportedCarriersForReturnShipment ??= new ChangeTrackingList(); return new DataCenterAddressLocationResult( DatacenterAddressType.DatacenterAddressLocation, - supportedCarriersForReturnShipment?.ToList(), + supportedCarriersForReturnShipment.ToList(), dataCenterAzureLocation, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, contactPersonName, company, street1, @@ -344,7 +428,7 @@ public static DataCenterAddressLocationResult DataCenterAddressLocationResult(IE additionalShippingInformation); } - /// Initializes a new instance of . + /// Customer disk job details. /// List of stages that run in the job. /// Contact details for notification and shipping. /// Shipping address of the customer. @@ -354,11 +438,7 @@ public static DataCenterAddressLocationResult DataCenterAddressLocationResult(IE /// Details of the data to be exported from azure. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -366,11 +446,7 @@ public static DataCenterAddressLocationResult DataCenterAddressLocationResult(IE /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. /// Contains the map of disk serial number to the disk details for import jobs. /// Contains the map of disk serial number to the disk details for export jobs. @@ -379,69 +455,69 @@ public static DataCenterAddressLocationResult DataCenterAddressLocationResult(IE /// Return package shipping details. /// Flag to indicate if disk manifest should be backed-up in the Storage Account. /// A new instance for mocking. - public static DataBoxCustomerDiskJobDetails DataBoxCustomerDiskJobDetails(IEnumerable jobStages = null, DataBoxContactDetails contactDetails = null, DataBoxShippingAddress shippingAddress = null, PackageShippingDetails deliveryPackage = null, PackageShippingDetails returnPackage = null, IEnumerable dataImportDetails = null, IEnumerable dataExportDetails = null, DataBoxOrderPreferences preferences = null, ReverseShippingDetails reverseShippingDetails = null, IEnumerable copyLogDetails = null, string reverseShipmentLabelSasKey = null, string chainOfCustodySasKey = null, DeviceErasureDetails deviceErasureDetails = null, DataBoxKeyEncryptionKey keyEncryptionKey = null, int? expectedDataSizeInTerabytes = null, IEnumerable actions = null, LastMitigationActionOnJob lastMitigationActionOnJob = null, DataCenterAddressResult dataCenterAddress = null, DataCenterCode? dataCenterCode = null, IDictionary importDiskDetails = null, IReadOnlyDictionary exportDiskDetails = null, IEnumerable copyProgress = null, PackageCarrierInfo deliverToDataCenterPackageDetails = null, PackageCarrierDetails returnToCustomerPackageDetails = null, bool? enableManifestBackup = null) + public static DataBoxCustomerDiskJobDetails DataBoxCustomerDiskJobDetails(IEnumerable jobStages = default, DataBoxContactDetails contactDetails = default, DataBoxShippingAddress shippingAddress = default, PackageShippingDetails deliveryPackage = default, PackageShippingDetails returnPackage = default, IEnumerable dataImportDetails = default, IEnumerable dataExportDetails = default, DataBoxOrderPreferences preferences = default, ReverseShippingDetails reverseShippingDetails = default, IEnumerable copyLogDetails = default, string reverseShipmentLabelSasKey = default, string chainOfCustodySasKey = default, DeviceErasureDetails deviceErasureDetails = default, DataBoxKeyEncryptionKey keyEncryptionKey = default, int? expectedDataSizeInTerabytes = default, IEnumerable actions = default, LastMitigationActionOnJob lastMitigationActionOnJob = default, DataCenterAddressResult dataCenterAddress = default, DataCenterCode? dataCenterCode = default, IDictionary importDiskDetails = default, IReadOnlyDictionary exportDiskDetails = default, IEnumerable copyProgress = default, PackageCarrierInfo deliverToDataCenterPackageDetails = default, PackageCarrierDetails returnToCustomerPackageDetails = default, bool? enableManifestBackup = default) { - jobStages ??= new List(); - dataImportDetails ??= new List(); - dataExportDetails ??= new List(); - copyLogDetails ??= new List(); - actions ??= new List(); - importDiskDetails ??= new Dictionary(); - exportDiskDetails ??= new Dictionary(); - copyProgress ??= new List(); + jobStages ??= new ChangeTrackingList(); + dataImportDetails ??= new ChangeTrackingList(); + dataExportDetails ??= new ChangeTrackingList(); + copyLogDetails ??= new ChangeTrackingList(); + actions ??= new ChangeTrackingList(); + importDiskDetails ??= new ChangeTrackingDictionary(); + exportDiskDetails ??= new ChangeTrackingDictionary(); + copyProgress ??= new ChangeTrackingList(); return new DataBoxCustomerDiskJobDetails( - jobStages?.ToList(), + jobStages.ToList(), contactDetails, shippingAddress, deliveryPackage, returnPackage, - dataImportDetails?.ToList(), - dataExportDetails?.ToList(), + dataImportDetails.ToList(), + dataExportDetails.ToList(), DataBoxOrderType.DataBoxCustomerDisk, preferences, reverseShippingDetails, - copyLogDetails?.ToList(), + copyLogDetails.ToList(), reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, - actions?.ToList(), + actions.ToList(), lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, importDiskDetails, exportDiskDetails, - copyProgress?.ToList(), + copyProgress.ToList(), deliverToDataCenterPackageDetails, returnToCustomerPackageDetails, enableManifestBackup); } - /// Initializes a new instance of . + /// Import disk details. /// The relative path of the manifest file on the disk. /// The Base16-encoded MD5 hash of the manifest file on the disk. /// BitLocker key used to encrypt the disk. /// Path to backed up manifest, only returned if enableManifestBackup is true. /// A new instance for mocking. - public static ImportDiskDetails ImportDiskDetails(string manifestFile = null, string manifestHash = null, string bitLockerKey = null, string backupManifestCloudPath = null) + public static ImportDiskDetails ImportDiskDetails(string manifestFile = default, string manifestHash = default, string bitLockerKey = default, string backupManifestCloudPath = default) { - return new ImportDiskDetails(manifestFile, manifestHash, bitLockerKey, backupManifestCloudPath, serializedAdditionalRawData: null); + return new ImportDiskDetails(manifestFile, manifestHash, bitLockerKey, backupManifestCloudPath, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Export disk details. /// The relative path of the manifest file on the disk. /// The Base16-encoded MD5 hash of the manifest file on the disk. /// Path to backed up manifest, only returned if enableManifestBackup is true. /// A new instance for mocking. - public static ExportDiskDetails ExportDiskDetails(string manifestFile = null, string manifestHash = null, string backupManifestCloudPath = null) + public static ExportDiskDetails ExportDiskDetails(string manifestFile = default, string manifestHash = default, string backupManifestCloudPath = default) { - return new ExportDiskDetails(manifestFile, manifestHash, backupManifestCloudPath, serializedAdditionalRawData: null); + return new ExportDiskDetails(manifestFile, manifestHash, backupManifestCloudPath, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// DataBox CustomerDisk Copy Progress. /// Name of the storage account. This will be empty for data account types other than storage account. /// Transfer type of data. /// Data Account Type. @@ -465,9 +541,9 @@ public static ExportDiskDetails ExportDiskDetails(string manifestFile = null, st /// Disk Serial Number. /// The Status of the copy. /// A new instance for mocking. - public static DataBoxCustomerDiskCopyProgress DataBoxCustomerDiskCopyProgress(string storageAccountName = null, DataBoxJobTransferType? transferType = null, DataAccountType? dataAccountType = null, ResourceIdentifier accountId = null, long? bytesProcessed = null, long? totalBytesToProcess = null, long? filesProcessed = null, long? totalFilesToProcess = null, long? invalidFilesProcessed = null, long? invalidFileBytesUploaded = null, long? renamedContainerCount = null, long? filesErroredOut = null, long? directoriesErroredOut = null, long? invalidDirectoriesProcessed = null, bool? isEnumerationInProgress = null, ResponseError error = null, IEnumerable actions = null, string serialNumber = null, DataBoxCopyStatus? copyStatus = null) + public static DataBoxCustomerDiskCopyProgress DataBoxCustomerDiskCopyProgress(string storageAccountName = default, DataBoxJobTransferType? transferType = default, DataAccountType? dataAccountType = default, ResourceIdentifier accountId = default, long? bytesProcessed = default, long? totalBytesToProcess = default, long? filesProcessed = default, long? totalFilesToProcess = default, long? invalidFilesProcessed = default, long? invalidFileBytesUploaded = default, long? renamedContainerCount = default, long? filesErroredOut = default, long? directoriesErroredOut = default, long? invalidDirectoriesProcessed = default, bool? isEnumerationInProgress = default, ResponseError error = default, IEnumerable actions = default, string serialNumber = default, DataBoxCopyStatus? copyStatus = default) { - actions ??= new List(); + actions ??= new ChangeTrackingList(); return new DataBoxCustomerDiskCopyProgress( storageAccountName, @@ -486,13 +562,13 @@ public static DataBoxCustomerDiskCopyProgress DataBoxCustomerDiskCopyProgress(st invalidDirectoriesProcessed, isEnumerationInProgress, error, - actions?.ToList(), - serializedAdditionalRawData: null, + actions.ToList(), + additionalBinaryDataProperties: null, serialNumber, copyStatus); } - /// Initializes a new instance of . + /// Copy progress. /// Name of the storage account. This will be empty for data account types other than storage account. /// Transfer type of data. /// Data Account Type. @@ -514,9 +590,9 @@ public static DataBoxCustomerDiskCopyProgress DataBoxCustomerDiskCopyProgress(st /// Error, if any, in the stage. /// Available actions on the job. /// A new instance for mocking. - public static DataBoxCopyProgress DataBoxCopyProgress(string storageAccountName = null, DataBoxJobTransferType? transferType = null, DataAccountType? dataAccountType = null, ResourceIdentifier accountId = null, long? bytesProcessed = null, long? totalBytesToProcess = null, long? filesProcessed = null, long? totalFilesToProcess = null, long? invalidFilesProcessed = null, long? invalidFileBytesUploaded = null, long? renamedContainerCount = null, long? filesErroredOut = null, long? directoriesErroredOut = null, long? invalidDirectoriesProcessed = null, bool? isEnumerationInProgress = null, ResponseError error = null, IEnumerable actions = null) + public static DataBoxCopyProgress DataBoxCopyProgress(string storageAccountName = default, DataBoxJobTransferType? transferType = default, DataAccountType? dataAccountType = default, ResourceIdentifier accountId = default, long? bytesProcessed = default, long? totalBytesToProcess = default, long? filesProcessed = default, long? totalFilesToProcess = default, long? invalidFilesProcessed = default, long? invalidFileBytesUploaded = default, long? renamedContainerCount = default, long? filesErroredOut = default, long? directoriesErroredOut = default, long? invalidDirectoriesProcessed = default, bool? isEnumerationInProgress = default, ResponseError error = default, IEnumerable actions = default) { - actions ??= new List(); + actions ??= new ChangeTrackingList(); return new DataBoxCopyProgress( storageAccountName, @@ -535,11 +611,11 @@ public static DataBoxCopyProgress DataBoxCopyProgress(string storageAccountName invalidDirectoriesProcessed, isEnumerationInProgress, error, - actions?.ToList(), - serializedAdditionalRawData: null); + actions.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// DataBox Disk Job Details. /// List of stages that run in the job. /// Contact details for notification and shipping. /// Shipping address of the customer. @@ -549,11 +625,7 @@ public static DataBoxCopyProgress DataBoxCopyProgress(string storageAccountName /// Details of the data to be exported from azure. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -561,11 +633,7 @@ public static DataBoxCopyProgress DataBoxCopyProgress(string storageAccountName /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. /// User preference on what size disks are needed for the job. The map is from the disk size in TB to the count. Eg. {2,5} means 5 disks of 2 TB size. Key is string but will be checked against an int. /// Copy progress per disk. @@ -574,50 +642,50 @@ public static DataBoxCopyProgress DataBoxCopyProgress(string storageAccountName /// Contains the map of disk serial number to the disk size being used for the job. Is returned only after the disks are shipped to the customer. /// User entered passkey for DataBox Disk job. /// A new instance for mocking. - public static DataBoxDiskJobDetails DataBoxDiskJobDetails(IEnumerable jobStages = null, DataBoxContactDetails contactDetails = null, DataBoxShippingAddress shippingAddress = null, PackageShippingDetails deliveryPackage = null, PackageShippingDetails returnPackage = null, IEnumerable dataImportDetails = null, IEnumerable dataExportDetails = null, DataBoxOrderPreferences preferences = null, ReverseShippingDetails reverseShippingDetails = null, IEnumerable copyLogDetails = null, string reverseShipmentLabelSasKey = null, string chainOfCustodySasKey = null, DeviceErasureDetails deviceErasureDetails = null, DataBoxKeyEncryptionKey keyEncryptionKey = null, int? expectedDataSizeInTerabytes = null, IEnumerable actions = null, LastMitigationActionOnJob lastMitigationActionOnJob = null, DataCenterAddressResult dataCenterAddress = null, DataCenterCode? dataCenterCode = null, IDictionary preferredDisks = null, IEnumerable copyProgress = null, IEnumerable granularCopyProgress = null, IEnumerable granularCopyLogDetails = null, IReadOnlyDictionary disksAndSizeDetails = null, string passkey = null) - { - jobStages ??= new List(); - dataImportDetails ??= new List(); - dataExportDetails ??= new List(); - copyLogDetails ??= new List(); - actions ??= new List(); - preferredDisks ??= new Dictionary(); - copyProgress ??= new List(); - granularCopyProgress ??= new List(); - granularCopyLogDetails ??= new List(); - disksAndSizeDetails ??= new Dictionary(); + public static DataBoxDiskJobDetails DataBoxDiskJobDetails(IEnumerable jobStages = default, DataBoxContactDetails contactDetails = default, DataBoxShippingAddress shippingAddress = default, PackageShippingDetails deliveryPackage = default, PackageShippingDetails returnPackage = default, IEnumerable dataImportDetails = default, IEnumerable dataExportDetails = default, DataBoxOrderPreferences preferences = default, ReverseShippingDetails reverseShippingDetails = default, IEnumerable copyLogDetails = default, string reverseShipmentLabelSasKey = default, string chainOfCustodySasKey = default, DeviceErasureDetails deviceErasureDetails = default, DataBoxKeyEncryptionKey keyEncryptionKey = default, int? expectedDataSizeInTerabytes = default, IEnumerable actions = default, LastMitigationActionOnJob lastMitigationActionOnJob = default, DataCenterAddressResult dataCenterAddress = default, DataCenterCode? dataCenterCode = default, IDictionary preferredDisks = default, IEnumerable copyProgress = default, IEnumerable granularCopyProgress = default, IEnumerable granularCopyLogDetails = default, IReadOnlyDictionary disksAndSizeDetails = default, string passkey = default) + { + jobStages ??= new ChangeTrackingList(); + dataImportDetails ??= new ChangeTrackingList(); + dataExportDetails ??= new ChangeTrackingList(); + copyLogDetails ??= new ChangeTrackingList(); + actions ??= new ChangeTrackingList(); + preferredDisks ??= new ChangeTrackingDictionary(); + copyProgress ??= new ChangeTrackingList(); + granularCopyProgress ??= new ChangeTrackingList(); + granularCopyLogDetails ??= new ChangeTrackingList(); + disksAndSizeDetails ??= new ChangeTrackingDictionary(); return new DataBoxDiskJobDetails( - jobStages?.ToList(), + jobStages.ToList(), contactDetails, shippingAddress, deliveryPackage, returnPackage, - dataImportDetails?.ToList(), - dataExportDetails?.ToList(), + dataImportDetails.ToList(), + dataExportDetails.ToList(), DataBoxOrderType.DataBoxDisk, preferences, reverseShippingDetails, - copyLogDetails?.ToList(), + copyLogDetails.ToList(), reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, - actions?.ToList(), + actions.ToList(), lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, preferredDisks, - copyProgress?.ToList(), - granularCopyProgress?.ToList(), - granularCopyLogDetails?.ToList(), + copyProgress.ToList(), + granularCopyProgress.ToList(), + granularCopyLogDetails.ToList(), disksAndSizeDetails, passkey); } - /// Initializes a new instance of . + /// DataBox Disk Copy Progress. /// The serial number of the disk. /// Bytes copied during the copy of disk. /// Indicates the percentage completed for the copy of the disk. @@ -625,9 +693,9 @@ public static DataBoxDiskJobDetails DataBoxDiskJobDetails(IEnumerable Error, if any, in the stage. /// Available actions on the job. /// A new instance for mocking. - public static DataBoxDiskCopyProgress DataBoxDiskCopyProgress(string serialNumber = null, long? bytesCopied = null, int? percentComplete = null, DataBoxCopyStatus? status = null, ResponseError error = null, IEnumerable actions = null) + public static DataBoxDiskCopyProgress DataBoxDiskCopyProgress(string serialNumber = default, long? bytesCopied = default, int? percentComplete = default, DataBoxCopyStatus? status = default, ResponseError error = default, IEnumerable actions = default) { - actions ??= new List(); + actions ??= new ChangeTrackingList(); return new DataBoxDiskCopyProgress( serialNumber, @@ -635,11 +703,11 @@ public static DataBoxDiskCopyProgress DataBoxDiskCopyProgress(string serialNumbe percentComplete, status, error, - actions?.ToList(), - serializedAdditionalRawData: null); + actions.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// DataBox Disk Granular Copy Progress. /// Name of the storage account. This will be empty for data account types other than storage account. /// Transfer type of data. /// Data Account Type. @@ -663,9 +731,9 @@ public static DataBoxDiskCopyProgress DataBoxDiskCopyProgress(string serialNumbe /// Disk Serial Number. /// The Status of the copy. /// A new instance for mocking. - public static DataBoxDiskGranularCopyProgress DataBoxDiskGranularCopyProgress(string storageAccountName = null, DataBoxJobTransferType? transferType = null, DataAccountType? dataAccountType = null, ResourceIdentifier accountId = null, long? bytesProcessed = null, long? totalBytesToProcess = null, long? filesProcessed = null, long? totalFilesToProcess = null, long? invalidFilesProcessed = null, long? invalidFileBytesUploaded = null, long? renamedContainerCount = null, long? filesErroredOut = null, long? directoriesErroredOut = null, long? invalidDirectoriesProcessed = null, bool? isEnumerationInProgress = null, ResponseError error = null, IEnumerable actions = null, string serialNumber = null, DataBoxCopyStatus? copyStatus = null) + public static DataBoxDiskGranularCopyProgress DataBoxDiskGranularCopyProgress(string storageAccountName = default, DataBoxJobTransferType? transferType = default, DataAccountType? dataAccountType = default, ResourceIdentifier accountId = default, long? bytesProcessed = default, long? totalBytesToProcess = default, long? filesProcessed = default, long? totalFilesToProcess = default, long? invalidFilesProcessed = default, long? invalidFileBytesUploaded = default, long? renamedContainerCount = default, long? filesErroredOut = default, long? directoriesErroredOut = default, long? invalidDirectoriesProcessed = default, bool? isEnumerationInProgress = default, ResponseError error = default, IEnumerable actions = default, string serialNumber = default, DataBoxCopyStatus? copyStatus = default) { - actions ??= new List(); + actions ??= new ChangeTrackingList(); return new DataBoxDiskGranularCopyProgress( storageAccountName, @@ -684,13 +752,13 @@ public static DataBoxDiskGranularCopyProgress DataBoxDiskGranularCopyProgress(st invalidDirectoriesProcessed, isEnumerationInProgress, error, - actions?.ToList(), - serializedAdditionalRawData: null, + actions.ToList(), + additionalBinaryDataProperties: null, serialNumber, copyStatus); } - /// Initializes a new instance of . + /// Granular Copy progress. /// Name of the storage account. This will be empty for data account types other than storage account. /// Transfer type of data. /// Data Account Type. @@ -712,9 +780,9 @@ public static DataBoxDiskGranularCopyProgress DataBoxDiskGranularCopyProgress(st /// Error, if any, in the stage. /// Available actions on the job. /// A new instance for mocking. - public static GranularCopyProgress GranularCopyProgress(string storageAccountName = null, DataBoxJobTransferType? transferType = null, DataAccountType? dataAccountType = null, ResourceIdentifier accountId = null, long? bytesProcessed = null, long? totalBytesToProcess = null, long? filesProcessed = null, long? totalFilesToProcess = null, long? invalidFilesProcessed = null, long? invalidFileBytesUploaded = null, long? renamedContainerCount = null, long? filesErroredOut = null, long? directoriesErroredOut = null, long? invalidDirectoriesProcessed = null, bool? isEnumerationInProgress = null, ResponseError error = null, IEnumerable actions = null) + public static GranularCopyProgress GranularCopyProgress(string storageAccountName = default, DataBoxJobTransferType? transferType = default, DataAccountType? dataAccountType = default, ResourceIdentifier accountId = default, long? bytesProcessed = default, long? totalBytesToProcess = default, long? filesProcessed = default, long? totalFilesToProcess = default, long? invalidFilesProcessed = default, long? invalidFileBytesUploaded = default, long? renamedContainerCount = default, long? filesErroredOut = default, long? directoriesErroredOut = default, long? invalidDirectoriesProcessed = default, bool? isEnumerationInProgress = default, ResponseError error = default, IEnumerable actions = default) { - actions ??= new List(); + actions ??= new ChangeTrackingList(); return new GranularCopyProgress( storageAccountName, @@ -733,28 +801,28 @@ public static GranularCopyProgress GranularCopyProgress(string storageAccountNam invalidDirectoriesProcessed, isEnumerationInProgress, error, - actions?.ToList(), - serializedAdditionalRawData: null); + actions.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Granular Copy Log Details for customer disk. /// Disk Serial Number. /// Account id. /// Link for copy error logs. /// Link for copy verbose logs. /// A new instance for mocking. - public static DataBoxDiskGranularCopyLogDetails DataBoxDiskGranularCopyLogDetails(string serialNumber = null, ResourceIdentifier accountId = null, string errorLogLink = null, string verboseLogLink = null) + public static DataBoxDiskGranularCopyLogDetails DataBoxDiskGranularCopyLogDetails(string serialNumber = default, ResourceIdentifier accountId = default, string errorLogLink = default, string verboseLogLink = default) { return new DataBoxDiskGranularCopyLogDetails( DataBoxOrderType.DataBoxCustomerDisk, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, serialNumber, accountId, errorLogLink, verboseLogLink); } - /// Initializes a new instance of . + /// Databox Heavy Device Job Details. /// List of stages that run in the job. /// Contact details for notification and shipping. /// Shipping address of the customer. @@ -764,11 +832,7 @@ public static DataBoxDiskGranularCopyLogDetails DataBoxDiskGranularCopyLogDetail /// Details of the data to be exported from azure. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -776,51 +840,47 @@ public static DataBoxDiskGranularCopyLogDetails DataBoxDiskGranularCopyLogDetail /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. /// Copy progress per account. /// Set Device password for unlocking Databox Heavy. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. /// A new instance for mocking. - public static DataBoxHeavyJobDetails DataBoxHeavyJobDetails(IEnumerable jobStages = null, DataBoxContactDetails contactDetails = null, DataBoxShippingAddress shippingAddress = null, PackageShippingDetails deliveryPackage = null, PackageShippingDetails returnPackage = null, IEnumerable dataImportDetails = null, IEnumerable dataExportDetails = null, DataBoxOrderPreferences preferences = null, ReverseShippingDetails reverseShippingDetails = null, IEnumerable copyLogDetails = null, string reverseShipmentLabelSasKey = null, string chainOfCustodySasKey = null, DeviceErasureDetails deviceErasureDetails = null, DataBoxKeyEncryptionKey keyEncryptionKey = null, int? expectedDataSizeInTerabytes = null, IEnumerable actions = null, LastMitigationActionOnJob lastMitigationActionOnJob = null, DataCenterAddressResult dataCenterAddress = null, DataCenterCode? dataCenterCode = null, IEnumerable copyProgress = null, string devicePassword = null) + public static DataBoxHeavyJobDetails DataBoxHeavyJobDetails(IEnumerable jobStages = default, DataBoxContactDetails contactDetails = default, DataBoxShippingAddress shippingAddress = default, PackageShippingDetails deliveryPackage = default, PackageShippingDetails returnPackage = default, IEnumerable dataImportDetails = default, IEnumerable dataExportDetails = default, DataBoxOrderPreferences preferences = default, ReverseShippingDetails reverseShippingDetails = default, IEnumerable copyLogDetails = default, string reverseShipmentLabelSasKey = default, string chainOfCustodySasKey = default, DeviceErasureDetails deviceErasureDetails = default, DataBoxKeyEncryptionKey keyEncryptionKey = default, int? expectedDataSizeInTerabytes = default, IEnumerable actions = default, LastMitigationActionOnJob lastMitigationActionOnJob = default, DataCenterAddressResult dataCenterAddress = default, DataCenterCode? dataCenterCode = default, IEnumerable copyProgress = default, string devicePassword = default) { - jobStages ??= new List(); - dataImportDetails ??= new List(); - dataExportDetails ??= new List(); - copyLogDetails ??= new List(); - actions ??= new List(); - copyProgress ??= new List(); + jobStages ??= new ChangeTrackingList(); + dataImportDetails ??= new ChangeTrackingList(); + dataExportDetails ??= new ChangeTrackingList(); + copyLogDetails ??= new ChangeTrackingList(); + actions ??= new ChangeTrackingList(); + copyProgress ??= new ChangeTrackingList(); return new DataBoxHeavyJobDetails( - jobStages?.ToList(), + jobStages.ToList(), contactDetails, shippingAddress, deliveryPackage, returnPackage, - dataImportDetails?.ToList(), - dataExportDetails?.ToList(), + dataImportDetails.ToList(), + dataExportDetails.ToList(), DataBoxOrderType.DataBoxHeavy, preferences, reverseShippingDetails, - copyLogDetails?.ToList(), + copyLogDetails.ToList(), reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, - actions?.ToList(), + actions.ToList(), lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, - serializedAdditionalRawData: null, - copyProgress?.ToList(), + additionalBinaryDataProperties: null, + copyProgress.ToList(), devicePassword); } - /// Initializes a new instance of . + /// Databox Job Details. /// List of stages that run in the job. /// Contact details for notification and shipping. /// Shipping address of the customer. @@ -830,11 +890,7 @@ public static DataBoxHeavyJobDetails DataBoxHeavyJobDetails(IEnumerable Details of the data to be exported from azure. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -842,409 +898,450 @@ public static DataBoxHeavyJobDetails DataBoxHeavyJobDetails(IEnumerable The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. /// Copy progress per storage account. /// Set Device password for unlocking Databox. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. /// A new instance for mocking. - public static DataBoxJobDetails DataBoxJobDetails(IEnumerable jobStages = null, DataBoxContactDetails contactDetails = null, DataBoxShippingAddress shippingAddress = null, PackageShippingDetails deliveryPackage = null, PackageShippingDetails returnPackage = null, IEnumerable dataImportDetails = null, IEnumerable dataExportDetails = null, DataBoxOrderPreferences preferences = null, ReverseShippingDetails reverseShippingDetails = null, IEnumerable copyLogDetails = null, string reverseShipmentLabelSasKey = null, string chainOfCustodySasKey = null, DeviceErasureDetails deviceErasureDetails = null, DataBoxKeyEncryptionKey keyEncryptionKey = null, int? expectedDataSizeInTerabytes = null, IEnumerable actions = null, LastMitigationActionOnJob lastMitigationActionOnJob = null, DataCenterAddressResult dataCenterAddress = null, DataCenterCode? dataCenterCode = null, IEnumerable copyProgress = null, string devicePassword = null) + public static DataBoxJobDetails DataBoxJobDetails(IEnumerable jobStages = default, DataBoxContactDetails contactDetails = default, DataBoxShippingAddress shippingAddress = default, PackageShippingDetails deliveryPackage = default, PackageShippingDetails returnPackage = default, IEnumerable dataImportDetails = default, IEnumerable dataExportDetails = default, DataBoxOrderPreferences preferences = default, ReverseShippingDetails reverseShippingDetails = default, IEnumerable copyLogDetails = default, string reverseShipmentLabelSasKey = default, string chainOfCustodySasKey = default, DeviceErasureDetails deviceErasureDetails = default, DataBoxKeyEncryptionKey keyEncryptionKey = default, int? expectedDataSizeInTerabytes = default, IEnumerable actions = default, LastMitigationActionOnJob lastMitigationActionOnJob = default, DataCenterAddressResult dataCenterAddress = default, DataCenterCode? dataCenterCode = default, IEnumerable copyProgress = default, string devicePassword = default) { - jobStages ??= new List(); - dataImportDetails ??= new List(); - dataExportDetails ??= new List(); - copyLogDetails ??= new List(); - actions ??= new List(); - copyProgress ??= new List(); + jobStages ??= new ChangeTrackingList(); + dataImportDetails ??= new ChangeTrackingList(); + dataExportDetails ??= new ChangeTrackingList(); + copyLogDetails ??= new ChangeTrackingList(); + actions ??= new ChangeTrackingList(); + copyProgress ??= new ChangeTrackingList(); return new DataBoxJobDetails( - jobStages?.ToList(), + jobStages.ToList(), contactDetails, shippingAddress, deliveryPackage, returnPackage, - dataImportDetails?.ToList(), - dataExportDetails?.ToList(), + dataImportDetails.ToList(), + dataExportDetails.ToList(), DataBoxOrderType.DataBox, preferences, reverseShippingDetails, - copyLogDetails?.ToList(), + copyLogDetails.ToList(), reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, - actions?.ToList(), + actions.ToList(), lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, - serializedAdditionalRawData: null, - copyProgress?.ToList(), + additionalBinaryDataProperties: null, + copyProgress.ToList(), devicePassword); } - /// Initializes a new instance of . + /// Msi identity details of the resource. + /// Identity type. + /// Service Principal Id backing the Msi. + /// Home Tenant Id. + /// User Assigned Identities. + /// A new instance for mocking. + public static ResourceIdentity ResourceIdentity(string @type = default, string principalId = default, string tenantId = default, IDictionary userAssignedIdentities = default) + { + userAssignedIdentities ??= new ChangeTrackingDictionary(); + + return new ResourceIdentity(@type, principalId, tenantId, userAssignedIdentities, additionalBinaryDataProperties: null); + } + + /// Details of a job to be updated. + /// The list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). + /// Msi identity of the resource. + /// A new instance for mocking. + public static DataBoxJobPatch DataBoxJobPatch(UpdateJobDetails details = default, IDictionary tags = default, ResourceIdentity identity = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new DataBoxJobPatch(details is null ? default : new UpdateJobProperties(details, null), tags, identity, additionalBinaryDataProperties: null); + } + + /// Shipment pick up request details. + /// Minimum date after which the pick up should commence, this must be in local time of pick up area. + /// Maximum date before which the pick up should commence, this must be in local time of pick up area. + /// Shipment Location in the pickup place. Eg.front desk. + /// A new instance for mocking. + public static ShipmentPickUpContent ShipmentPickUpContent(DateTimeOffset startOn = default, DateTimeOffset endOn = default, string shipmentLocation = default) + { + return new ShipmentPickUpContent(startOn, endOn, shipmentLocation, additionalBinaryDataProperties: null); + } + + /// Shipment pick up response. /// Confirmation number for the pick up request. /// Time by which shipment should be ready for pick up, this is in local time of pick up area. /// A new instance for mocking. - public static DataBoxShipmentPickUpResult DataBoxShipmentPickUpResult(string confirmationNumber = null, DateTimeOffset? readyBy = null) + public static DataBoxShipmentPickUpResult DataBoxShipmentPickUpResult(string confirmationNumber = default, DateTimeOffset? readyBy = default) { - return new DataBoxShipmentPickUpResult(confirmationNumber, readyBy, serializedAdditionalRawData: null); + return new DataBoxShipmentPickUpResult(confirmationNumber, readyBy, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Reason for cancellation. + /// Reason for cancellation. + /// A new instance for mocking. + public static DataBoxJobCancellationReason DataBoxJobCancellationReason(string reason = default) + { + return new DataBoxJobCancellationReason(reason, additionalBinaryDataProperties: null); + } + + /// Unencrypted credentials for accessing device. /// Name of the job. - /// - /// Secrets related to this job. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// Secrets related to this job. /// A new instance for mocking. - public static UnencryptedCredentials UnencryptedCredentials(string jobName = null, JobSecrets jobSecrets = null) + public static UnencryptedCredentials UnencryptedCredentials(string jobName = default, JobSecrets jobSecrets = default) { - return new UnencryptedCredentials(jobName, jobSecrets, serializedAdditionalRawData: null); + return new UnencryptedCredentials(jobName, jobSecrets, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// + /// The base class for the secrets + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + /// Used to indicate what type of job secrets object. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. /// A new instance for mocking. - public static JobSecrets JobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = null, ResponseError error = null) + public static JobSecrets JobSecrets(string jobSecretsType = default, DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default, ResponseError error = default) { - return new UnknownJobSecrets(default, dataCenterAccessSecurityCode, error, serializedAdditionalRawData: null); + return new UnknownJobSecrets(jobSecretsType.ToDataBoxOrderType(), dataCenterAccessSecurityCode, error, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Dc access security code. /// Reverse Dc access security code. /// Forward Dc access security code. /// A new instance for mocking. - public static DataCenterAccessSecurityCode DataCenterAccessSecurityCode(string reverseDataCenterAccessCode = null, string forwardDataCenterAccessCode = null) + public static DataCenterAccessSecurityCode DataCenterAccessSecurityCode(string reverseDataCenterAccessCode = default, string forwardDataCenterAccessCode = default) { - return new DataCenterAccessSecurityCode(reverseDataCenterAccessCode, forwardDataCenterAccessCode, serializedAdditionalRawData: null); + return new DataCenterAccessSecurityCode(reverseDataCenterAccessCode, forwardDataCenterAccessCode, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The secrets related to customer disk job. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. /// Contains the list of secrets object for that device. /// Carrier Account Number of the customer. /// A new instance for mocking. - public static CustomerDiskJobSecrets CustomerDiskJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = null, ResponseError error = null, IEnumerable diskSecrets = null, string carrierAccountNumber = null) + public static CustomerDiskJobSecrets CustomerDiskJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default, ResponseError error = default, IEnumerable diskSecrets = default, string carrierAccountNumber = default) { - diskSecrets ??= new List(); + diskSecrets ??= new ChangeTrackingList(); return new CustomerDiskJobSecrets( DataBoxOrderType.DataBoxCustomerDisk, dataCenterAccessSecurityCode, error, - serializedAdditionalRawData: null, - diskSecrets?.ToList(), + additionalBinaryDataProperties: null, + diskSecrets.ToList(), carrierAccountNumber); } - /// Initializes a new instance of . + /// Contains all the secrets of a Disk. /// Serial number of the assigned disk. /// Bit Locker key of the disk which can be used to unlock the disk to copy data. /// A new instance for mocking. - public static DataBoxDiskSecret DataBoxDiskSecret(string diskSerialNumber = null, string bitLockerKey = null) + public static DataBoxDiskSecret DataBoxDiskSecret(string diskSerialNumber = default, string bitLockerKey = default) { - return new DataBoxDiskSecret(diskSerialNumber, bitLockerKey, serializedAdditionalRawData: null); + return new DataBoxDiskSecret(diskSerialNumber, bitLockerKey, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The secrets related to disk job. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. /// Contains the list of secrets object for that device. /// PassKey for the disk Job. /// Whether passkey was provided by user. /// A new instance for mocking. - public static DataBoxDiskJobSecrets DataBoxDiskJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = null, ResponseError error = null, IEnumerable diskSecrets = null, string passkey = null, bool? isPasskeyUserDefined = null) + public static DataBoxDiskJobSecrets DataBoxDiskJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default, ResponseError error = default, IEnumerable diskSecrets = default, string passkey = default, bool? isPasskeyUserDefined = default) { - diskSecrets ??= new List(); + diskSecrets ??= new ChangeTrackingList(); return new DataBoxDiskJobSecrets( DataBoxOrderType.DataBoxDisk, dataCenterAccessSecurityCode, error, - serializedAdditionalRawData: null, - diskSecrets?.ToList(), + additionalBinaryDataProperties: null, + diskSecrets.ToList(), passkey, isPasskeyUserDefined); } - /// Initializes a new instance of . + /// The secrets related to a databox heavy job. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. /// Contains the list of secret objects for a databox heavy job. /// A new instance for mocking. - public static DataBoxHeavyJobSecrets DataBoxHeavyJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = null, ResponseError error = null, IEnumerable cabinetPodSecrets = null) + public static DataBoxHeavyJobSecrets DataBoxHeavyJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default, ResponseError error = default, IEnumerable cabinetPodSecrets = default) { - cabinetPodSecrets ??= new List(); + cabinetPodSecrets ??= new ChangeTrackingList(); - return new DataBoxHeavyJobSecrets(DataBoxOrderType.DataBoxHeavy, dataCenterAccessSecurityCode, error, serializedAdditionalRawData: null, cabinetPodSecrets?.ToList()); + return new DataBoxHeavyJobSecrets(DataBoxOrderType.DataBoxHeavy, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties: null, cabinetPodSecrets.ToList()); } - /// Initializes a new instance of . + /// The secrets related to a databox heavy. /// Serial number of the assigned device. /// Password for out of the box experience on device. /// Network configuration of the appliance. /// The base 64 encoded public key to authenticate with the device. /// Per account level access credentials. /// A new instance for mocking. - public static DataBoxHeavySecret DataBoxHeavySecret(string deviceSerialNumber = null, string devicePassword = null, IEnumerable networkConfigurations = null, string encodedValidationCertPubKey = null, IEnumerable accountCredentialDetails = null) + public static DataBoxHeavySecret DataBoxHeavySecret(string deviceSerialNumber = default, string devicePassword = default, IEnumerable networkConfigurations = default, string encodedValidationCertPubKey = default, IEnumerable accountCredentialDetails = default) { - networkConfigurations ??= new List(); - accountCredentialDetails ??= new List(); + networkConfigurations ??= new ChangeTrackingList(); + accountCredentialDetails ??= new ChangeTrackingList(); return new DataBoxHeavySecret( deviceSerialNumber, devicePassword, - networkConfigurations?.ToList(), + networkConfigurations.ToList(), encodedValidationCertPubKey, - accountCredentialDetails?.ToList(), - serializedAdditionalRawData: null); + accountCredentialDetails.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The Network Adapter configuration of a DataBox. /// Name of the network. /// Mac Address. /// A new instance for mocking. - public static ApplianceNetworkConfiguration ApplianceNetworkConfiguration(string name = null, string macAddress = null) + public static ApplianceNetworkConfiguration ApplianceNetworkConfiguration(string name = default, string macAddress = default) { - return new ApplianceNetworkConfiguration(name, macAddress, serializedAdditionalRawData: null); + return new ApplianceNetworkConfiguration(name, macAddress, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Credential details of the account. /// Name of the account. /// Type of the account. /// Connection string of the account endpoint to use the account as a storage endpoint on the device. /// Per share level unencrypted access credentials. /// A new instance for mocking. - public static DataBoxAccountCredentialDetails DataBoxAccountCredentialDetails(string accountName = null, DataAccountType? dataAccountType = null, string accountConnectionString = null, IEnumerable shareCredentialDetails = null) + public static DataBoxAccountCredentialDetails DataBoxAccountCredentialDetails(string accountName = default, DataAccountType? dataAccountType = default, string accountConnectionString = default, IEnumerable shareCredentialDetails = default) { - shareCredentialDetails ??= new List(); + shareCredentialDetails ??= new ChangeTrackingList(); - return new DataBoxAccountCredentialDetails(accountName, dataAccountType, accountConnectionString, shareCredentialDetails?.ToList(), serializedAdditionalRawData: null); + return new DataBoxAccountCredentialDetails(accountName, dataAccountType, accountConnectionString, shareCredentialDetails.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Credential details of the shares in account. /// Name of the share. /// Type of the share. /// User name for the share. /// Password for the share. /// Access protocols supported on the device. /// A new instance for mocking. - public static ShareCredentialDetails ShareCredentialDetails(string shareName = null, ShareDestinationFormatType? shareType = null, string userName = null, string password = null, IEnumerable supportedAccessProtocols = null) + public static ShareCredentialDetails ShareCredentialDetails(string shareName = default, ShareDestinationFormatType? shareType = default, string userName = default, string password = default, IEnumerable supportedAccessProtocols = default) { - supportedAccessProtocols ??= new List(); + supportedAccessProtocols ??= new ChangeTrackingList(); return new ShareCredentialDetails( shareName, shareType, userName, password, - supportedAccessProtocols?.ToList(), - serializedAdditionalRawData: null); + supportedAccessProtocols.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The secrets related to a databox job. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. /// Contains the list of secret objects for a job. /// A new instance for mocking. - public static DataBoxJobSecrets DataBoxJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = null, ResponseError error = null, IEnumerable podSecrets = null) + public static DataBoxJobSecrets DataBoxJobSecrets(DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default, ResponseError error = default, IEnumerable podSecrets = default) { - podSecrets ??= new List(); + podSecrets ??= new ChangeTrackingList(); - return new DataBoxJobSecrets(DataBoxOrderType.DataBox, dataCenterAccessSecurityCode, error, serializedAdditionalRawData: null, podSecrets?.ToList()); + return new DataBoxJobSecrets(DataBoxOrderType.DataBox, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties: null, podSecrets.ToList()); } - /// Initializes a new instance of . + /// The secrets related to a DataBox. /// Serial number of the assigned device. /// Password for out of the box experience on device. /// Network configuration of the appliance. /// The base 64 encoded public key to authenticate with the device. /// Per account level access credentials. /// A new instance for mocking. - public static DataBoxSecret DataBoxSecret(string deviceSerialNumber = null, string devicePassword = null, IEnumerable networkConfigurations = null, string encodedValidationCertPubKey = null, IEnumerable accountCredentialDetails = null) + public static DataBoxSecret DataBoxSecret(string deviceSerialNumber = default, string devicePassword = default, IEnumerable networkConfigurations = default, string encodedValidationCertPubKey = default, IEnumerable accountCredentialDetails = default) { - networkConfigurations ??= new List(); - accountCredentialDetails ??= new List(); + networkConfigurations ??= new ChangeTrackingList(); + accountCredentialDetails ??= new ChangeTrackingList(); return new DataBoxSecret( deviceSerialNumber, devicePassword, - networkConfigurations?.ToList(), + networkConfigurations.ToList(), encodedValidationCertPubKey, - accountCredentialDetails?.ToList(), - serializedAdditionalRawData: null); + accountCredentialDetails.ToList(), + additionalBinaryDataProperties: null); + } + + /// The request body to provide the delivery package details of job. + /// Delivery package details. + /// A new instance for mocking. + public static MarkDevicesShippedContent MarkDevicesShippedContent(PackageCarrierInfo deliverToDataCenterPackageDetails = default) + { + return new MarkDevicesShippedContent(deliverToDataCenterPackageDetails, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// + /// Request body to get the availability for scheduling orders. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. + /// Sku Name for which the order is to be scheduled. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static ScheduleAvailabilityContent ScheduleAvailabilityContent(AzureLocation storageLocation = default, string country = null, DeviceModelName? model = null) + public static ScheduleAvailabilityContent ScheduleAvailabilityContent(AzureLocation storageLocation = default, string skuName = default, string country = default, DeviceModelName? model = default) { - return new UnknownScheduleAvailabilityRequest(storageLocation, default, country, model, serializedAdditionalRawData: null); + return new UnknownScheduleAvailabilityContent(storageLocation, skuName.ToDataBoxSkuName(), country, model, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Request body to get the availability for scheduling data box orders orders. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static DataBoxScheduleAvailabilityContent DataBoxScheduleAvailabilityContent(AzureLocation storageLocation = default, string country = null, DeviceModelName? model = null) + public static DataBoxScheduleAvailabilityContent DataBoxScheduleAvailabilityContent(AzureLocation storageLocation = default, string country = default, DeviceModelName? model = default) { - return new DataBoxScheduleAvailabilityContent(storageLocation, DataBoxSkuName.DataBox, country, model, serializedAdditionalRawData: null); + return new DataBoxScheduleAvailabilityContent(storageLocation, DataBoxSkuName.DataBox, country, model, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Request body to get the availability for scheduling disk orders. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// A new instance for mocking. - public static DiskScheduleAvailabilityContent DiskScheduleAvailabilityContent(AzureLocation storageLocation = default, string country = null, DeviceModelName? model = null, int expectedDataSizeInTerabytes = default) + public static DiskScheduleAvailabilityContent DiskScheduleAvailabilityContent(AzureLocation storageLocation = default, string country = default, DeviceModelName? model = default, int expectedDataSizeInTerabytes = default) { return new DiskScheduleAvailabilityContent( storageLocation, DataBoxSkuName.DataBoxDisk, country, model, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, expectedDataSizeInTerabytes); } - /// Initializes a new instance of . + /// Request body to get the availability for scheduling heavy orders. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static HeavyScheduleAvailabilityContent HeavyScheduleAvailabilityContent(AzureLocation storageLocation = default, string country = null, DeviceModelName? model = null) + public static HeavyScheduleAvailabilityContent HeavyScheduleAvailabilityContent(AzureLocation storageLocation = default, string country = default, DeviceModelName? model = default) { - return new HeavyScheduleAvailabilityContent(storageLocation, DataBoxSkuName.DataBoxHeavy, country, model, serializedAdditionalRawData: null); + return new HeavyScheduleAvailabilityContent(storageLocation, DataBoxSkuName.DataBoxHeavy, country, model, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Request body to get the datacenter address. /// Storage location. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Sku Name for which the data center address requested. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static DataCenterAddressContent DataCenterAddressContent(AzureLocation storageLocation = default, DataBoxSkuName skuName = default, DeviceModelName? model = null) + public static DataCenterAddressContent DataCenterAddressContent(AzureLocation storageLocation = default, DataBoxSkuName skuName = default, DeviceModelName? model = default) { - return new DataCenterAddressContent(storageLocation, skuName, model, serializedAdditionalRawData: null); + return new DataCenterAddressContent(storageLocation, skuName, model, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// Schedule availability for given sku in a region. - /// Transport options available for given sku in a region. - /// - /// Datacenter address for given sku in a region. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// - /// Device capabilities available for a given sku in a region. + /// List of dates available to schedule. + /// List of transport availability details for given region. + /// Datacenter address for given sku in a region. + /// List of device capabilities available for a given region and a given sku. /// A new instance for mocking. - public static RegionConfigurationResult RegionConfigurationResult(IEnumerable scheduleAvailabilityResponseAvailableDates = null, IEnumerable transportAvailabilityDetails = null, DataCenterAddressResult dataCenterAddressResponse = null, IEnumerable deviceCapabilityDetails = null) + public static RegionConfigurationResult RegionConfigurationResult(IEnumerable scheduleAvailabilityResponseAvailableDates = default, IEnumerable transportAvailabilityDetails = default, DataCenterAddressResult dataCenterAddressResponse = default, IEnumerable deviceCapabilityDetails = default) { - scheduleAvailabilityResponseAvailableDates ??= new List(); - transportAvailabilityDetails ??= new List(); - deviceCapabilityDetails ??= new List(); - - return new RegionConfigurationResult(scheduleAvailabilityResponseAvailableDates != null ? new ScheduleAvailabilityResponse(scheduleAvailabilityResponseAvailableDates?.ToList(), serializedAdditionalRawData: null) : null, transportAvailabilityDetails != null ? new TransportAvailabilityResponse(transportAvailabilityDetails?.ToList(), serializedAdditionalRawData: null) : null, dataCenterAddressResponse, deviceCapabilityDetails != null ? new DeviceCapabilityResponse(deviceCapabilityDetails?.ToList(), serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); + return new RegionConfigurationResult(scheduleAvailabilityResponseAvailableDates is null ? default : new ScheduleAvailabilityResponse((scheduleAvailabilityResponseAvailableDates ?? new ChangeTrackingList()).ToList(), null), transportAvailabilityDetails is null ? default : new TransportAvailabilityResponse((transportAvailabilityDetails ?? new ChangeTrackingList()).ToList(), null), dataCenterAddressResponse, deviceCapabilityDetails is null ? default : new DeviceCapabilityResponse((deviceCapabilityDetails ?? new ChangeTrackingList()).ToList(), null), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Transport options availability details for given region. /// Transport Shipment Type supported for given region. /// A new instance for mocking. - public static TransportAvailabilityDetails TransportAvailabilityDetails(TransportShipmentType? shipmentType = null) + public static TransportAvailabilityDetails TransportAvailabilityDetails(TransportShipmentType? shipmentType = default) { - return new TransportAvailabilityDetails(shipmentType, serializedAdditionalRawData: null); + return new TransportAvailabilityDetails(shipmentType, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Device capability details for a given sku for a given region. /// Hardware encryption support for a given sku for a given region. /// A new instance for mocking. - public static DeviceCapabilityDetails DeviceCapabilityDetails(HardwareEncryption? hardwareEncryption = null) + public static DeviceCapabilityDetails DeviceCapabilityDetails(HardwareEncryption? hardwareEncryption = default) { - return new DeviceCapabilityDetails(hardwareEncryption, serializedAdditionalRawData: null); + return new DeviceCapabilityDetails(hardwareEncryption, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The requirements to validate customer address where the device needs to be shipped. /// Shipping address of the customer. /// Device type to be used for the job. /// Preferences related to the shipment logistics of the sku. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static DataBoxValidateAddressContent DataBoxValidateAddressContent(DataBoxShippingAddress shippingAddress = null, DataBoxSkuName deviceType = default, TransportPreferences transportPreferences = null, DeviceModelName? model = null) + public static DataBoxValidateAddressContent DataBoxValidateAddressContent(DataBoxShippingAddress shippingAddress = default, DataBoxSkuName deviceType = default, TransportPreferences transportPreferences = default, DeviceModelName? model = default) { return new DataBoxValidateAddressContent( DataBoxValidationInputDiscriminator.ValidateAddress, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, shippingAddress, deviceType, transportPreferences, model); } - /// Initializes a new instance of . + /// Request to validate create order limit for current subscription. /// Device type to be used for the job. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static CreateOrderLimitForSubscriptionValidationContent CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName deviceType = default, DeviceModelName? model = null) + public static CreateOrderLimitForSubscriptionValidationContent CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName deviceType = default, DeviceModelName? model = default) { - return new CreateOrderLimitForSubscriptionValidationContent(DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit, serializedAdditionalRawData: null, deviceType, model); + return new CreateOrderLimitForSubscriptionValidationContent(DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit, additionalBinaryDataProperties: null, deviceType, model); } - /// Initializes a new instance of . + /// Request to validate export and import data details. /// List of DataTransfer details to be used to export data from azure. /// List of DataTransfer details to be used to import data to azure. /// Device type. /// Type of the transfer. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static DataTransferDetailsValidationContent DataTransferDetailsValidationContent(IEnumerable dataExportDetails = null, IEnumerable dataImportDetails = null, DataBoxSkuName deviceType = default, DataBoxJobTransferType transferType = default, DeviceModelName? model = null) + public static DataTransferDetailsValidationContent DataTransferDetailsValidationContent(IEnumerable dataExportDetails = default, IEnumerable dataImportDetails = default, DataBoxSkuName deviceType = default, DataBoxJobTransferType transferType = default, DeviceModelName? model = default) { - dataExportDetails ??= new List(); - dataImportDetails ??= new List(); + dataExportDetails ??= new ChangeTrackingList(); + dataImportDetails ??= new ChangeTrackingList(); return new DataTransferDetailsValidationContent( DataBoxValidationInputDiscriminator.ValidateDataTransferDetails, - serializedAdditionalRawData: null, - dataExportDetails?.ToList(), - dataImportDetails?.ToList(), + additionalBinaryDataProperties: null, + dataExportDetails.ToList(), + dataImportDetails.ToList(), deviceType, transferType, model); } - /// Initializes a new instance of . + /// Request to validate preference of transport and data center. /// Preference of transport and data center. /// Device type to be used for the job. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static PreferencesValidationContent PreferencesValidationContent(DataBoxOrderPreferences preference = null, DataBoxSkuName deviceType = default, DeviceModelName? model = null) + public static PreferencesValidationContent PreferencesValidationContent(DataBoxOrderPreferences preference = default, DataBoxSkuName deviceType = default, DeviceModelName? model = default) { - return new PreferencesValidationContent(DataBoxValidationInputDiscriminator.ValidatePreferences, serializedAdditionalRawData: null, preference, deviceType, model); + return new PreferencesValidationContent(DataBoxValidationInputDiscriminator.ValidatePreferences, additionalBinaryDataProperties: null, preference, deviceType, model); } - /// Initializes a new instance of . + /// Request to validate sku availability. /// Device type to be used for the job. /// Type of the transfer. /// ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. /// A new instance for mocking. - public static SkuAvailabilityValidationContent SkuAvailabilityValidationContent(DataBoxSkuName deviceType = default, DataBoxJobTransferType transferType = default, string country = null, AzureLocation location = default, DeviceModelName? model = null) + public static SkuAvailabilityValidationContent SkuAvailabilityValidationContent(DataBoxSkuName deviceType = default, DataBoxJobTransferType transferType = default, string country = default, AzureLocation location = default, DeviceModelName? model = default) { return new SkuAvailabilityValidationContent( DataBoxValidationInputDiscriminator.ValidateSkuAvailability, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, deviceType, transferType, country, @@ -1252,108 +1349,127 @@ public static SkuAvailabilityValidationContent SkuAvailabilityValidationContent( model); } - /// Initializes a new instance of . + /// Output of the address validation api. /// The address validation properties. /// A new instance for mocking. - public static AddressValidationOutput AddressValidationOutput(AddressValidationResult properties = null) + public static AddressValidationOutput AddressValidationOutput(AddressValidationResult properties = default) { - return new AddressValidationOutput(properties, serializedAdditionalRawData: null); + return new AddressValidationOutput(properties, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The address validation output. /// Error code and message of validation response. /// The address validation status. /// List of alternate addresses. /// A new instance for mocking. - public static AddressValidationResult AddressValidationResult(ResponseError error = null, AddressValidationStatus? validationStatus = null, IEnumerable alternateAddresses = null) + public static AddressValidationResult AddressValidationResult(ResponseError error = default, AddressValidationStatus? validationStatus = default, IEnumerable alternateAddresses = default) { - alternateAddresses ??= new List(); + alternateAddresses ??= new ChangeTrackingList(); - return new AddressValidationResult(DataBoxValidationInputDiscriminator.ValidateAddress, error, serializedAdditionalRawData: null, validationStatus, alternateAddresses?.ToList()); + return new AddressValidationResult(DataBoxValidationInputDiscriminator.ValidateAddress, error, additionalBinaryDataProperties: null, validationStatus, alternateAddresses.ToList()); } - /// Initializes a new instance of . + /// + /// Minimum properties that should be present in each individual validation response. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// + /// Identifies the type of validation response. /// Error code and message of validation response. /// A new instance for mocking. - public static DataBoxValidationInputResult DataBoxValidationInputResult(ResponseError error = null) + public static DataBoxValidationInputResult DataBoxValidationInputResult(string validationType = default, ResponseError error = default) { - return new UnknownValidationInputResponse(default, error, serializedAdditionalRawData: null); + return new UnknownDataBoxValidationInputResult(validationType.ToDataBoxValidationInputDiscriminator(), error, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Properties of create order limit for subscription validation response. /// Error code and message of validation response. /// Create order limit validation status. /// A new instance for mocking. - public static CreateOrderLimitForSubscriptionValidationResult CreateOrderLimitForSubscriptionValidationResult(ResponseError error = null, DataBoxValidationStatus? status = null) + public static CreateOrderLimitForSubscriptionValidationResult CreateOrderLimitForSubscriptionValidationResult(ResponseError error = default, DataBoxValidationStatus? status = default) { - return new CreateOrderLimitForSubscriptionValidationResult(DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit, error, serializedAdditionalRawData: null, status); + return new CreateOrderLimitForSubscriptionValidationResult(DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit, error, additionalBinaryDataProperties: null, status); } - /// Initializes a new instance of . + /// Properties of data transfer details validation response. /// Error code and message of validation response. /// Data transfer details validation status. /// A new instance for mocking. - public static DataTransferDetailsValidationResult DataTransferDetailsValidationResult(ResponseError error = null, DataBoxValidationStatus? status = null) + public static DataTransferDetailsValidationResult DataTransferDetailsValidationResult(ResponseError error = default, DataBoxValidationStatus? status = default) { - return new DataTransferDetailsValidationResult(DataBoxValidationInputDiscriminator.ValidateDataTransferDetails, error, serializedAdditionalRawData: null, status); + return new DataTransferDetailsValidationResult(DataBoxValidationInputDiscriminator.ValidateDataTransferDetails, error, additionalBinaryDataProperties: null, status); } - /// Initializes a new instance of . + /// Properties of data center and transport preference validation response. /// Error code and message of validation response. /// Validation status of requested data center and transport. /// A new instance for mocking. - public static PreferencesValidationResult PreferencesValidationResult(ResponseError error = null, DataBoxValidationStatus? status = null) + public static PreferencesValidationResult PreferencesValidationResult(ResponseError error = default, DataBoxValidationStatus? status = default) { - return new PreferencesValidationResult(DataBoxValidationInputDiscriminator.ValidatePreferences, error, serializedAdditionalRawData: null, status); + return new PreferencesValidationResult(DataBoxValidationInputDiscriminator.ValidatePreferences, error, additionalBinaryDataProperties: null, status); } - /// Initializes a new instance of . + /// Properties of sku availability validation response. /// Error code and message of validation response. /// Sku availability validation status. /// A new instance for mocking. - public static SkuAvailabilityValidationResult SkuAvailabilityValidationResult(ResponseError error = null, DataBoxValidationStatus? status = null) + public static SkuAvailabilityValidationResult SkuAvailabilityValidationResult(ResponseError error = default, DataBoxValidationStatus? status = default) { - return new SkuAvailabilityValidationResult(DataBoxValidationInputDiscriminator.ValidateSkuAvailability, error, serializedAdditionalRawData: null, status); + return new SkuAvailabilityValidationResult(DataBoxValidationInputDiscriminator.ValidateSkuAvailability, error, additionalBinaryDataProperties: null, status); } - /// Initializes a new instance of . + /// Properties of subscription permission to create job validation response. /// Error code and message of validation response. /// Validation status of subscription permission to create job. /// A new instance for mocking. - public static SubscriptionIsAllowedToCreateJobValidationResult SubscriptionIsAllowedToCreateJobValidationResult(ResponseError error = null, DataBoxValidationStatus? status = null) + public static SubscriptionIsAllowedToCreateJobValidationResult SubscriptionIsAllowedToCreateJobValidationResult(ResponseError error = default, DataBoxValidationStatus? status = default) { - return new SubscriptionIsAllowedToCreateJobValidationResult(DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob, error, serializedAdditionalRawData: null, status); + return new SubscriptionIsAllowedToCreateJobValidationResult(DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob, error, additionalBinaryDataProperties: null, status); + } + + /// + /// Minimum request requirement of any validation category. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + /// List of request details contain validationType and its request as key and value respectively. + /// A new instance for mocking. + public static DataBoxValidationContent DataBoxValidationContent(IEnumerable individualRequestDetails = default) + { + individualRequestDetails ??= new ChangeTrackingList(); + + return new UnknownDataBoxValidationContent("JobCreationValidation", individualRequestDetails.ToList(), additionalBinaryDataProperties: null); + } + + /// It does all pre-job creation validations. + /// List of request details contain validationType and its request as key and value respectively. + /// A new instance for mocking. + public static CreateJobValidationContent CreateJobValidationContent(IEnumerable individualRequestDetails = default) + { + individualRequestDetails ??= new ChangeTrackingList(); + + return new CreateJobValidationContent("JobCreationValidation", individualRequestDetails.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . /// Overall validation status. - /// - /// List of response details contain validationType and its response as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// + /// List of response details contain validationType and its response as key and value respectively. /// A new instance for mocking. - public static DataBoxValidationResult DataBoxValidationResult(OverallValidationStatus? status = null, IEnumerable individualResponseDetails = null) + public static DataBoxValidationResult DataBoxValidationResult(OverallValidationStatus? status = default, IEnumerable individualResponseDetails = default) { - individualResponseDetails ??= new List(); - - return new DataBoxValidationResult(status, individualResponseDetails?.ToList(), serializedAdditionalRawData: null); + return new DataBoxValidationResult(status is null && individualResponseDetails is null ? default : new ValidationResponseProperties(status, (individualResponseDetails ?? new ChangeTrackingList()).ToList(), null), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The filters for showing the available skus. /// Type of the transfer. /// ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Sku Names to filter for available skus. /// A new instance for mocking. - public static AvailableSkusContent AvailableSkusContent(DataBoxJobTransferType transferType = default, string country = null, AzureLocation location = default, IEnumerable skuNames = null) + public static AvailableSkusContent AvailableSkusContent(DataBoxJobTransferType transferType = default, string country = default, AzureLocation location = default, IEnumerable skuNames = default) { - skuNames ??= new List(); + skuNames ??= new ChangeTrackingList(); - return new AvailableSkusContent(transferType, country, location, skuNames?.ToList(), serializedAdditionalRawData: null); + return new AvailableSkusContent(transferType, country, location, skuNames.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . /// The Sku. /// The sku is enabled or not. /// The map of data location to service location. @@ -1365,137 +1481,47 @@ public static AvailableSkusContent AvailableSkusContent(DataBoxJobTransferType t /// Required feature to access the sku. /// List of all the Countries in the SKU specific commerce boundary. /// A new instance for mocking. - public static DataBoxSkuInformation DataBoxSkuInformation(DataBoxSku sku = null, bool? isEnabled = null, IEnumerable dataLocationToServiceLocationMap = null, DataBoxSkuCapacity capacity = null, IEnumerable costs = null, IEnumerable apiVersions = null, SkuDisabledReason? disabledReason = null, string disabledReasonMessage = null, string requiredFeature = null, IEnumerable countriesWithinCommerceBoundary = null) + public static DataBoxSkuInformation DataBoxSkuInformation(DataBoxSku sku = default, bool? isEnabled = default, IEnumerable dataLocationToServiceLocationMap = default, DataBoxSkuCapacity capacity = default, IEnumerable costs = default, IEnumerable apiVersions = default, SkuDisabledReason? disabledReason = default, string disabledReasonMessage = default, string requiredFeature = default, IEnumerable countriesWithinCommerceBoundary = default) { - dataLocationToServiceLocationMap ??= new List(); - costs ??= new List(); - apiVersions ??= new List(); - countriesWithinCommerceBoundary ??= new List(); - - return new DataBoxSkuInformation( - sku, - isEnabled, - dataLocationToServiceLocationMap?.ToList(), + return new DataBoxSkuInformation(sku, isEnabled, dataLocationToServiceLocationMap is null && capacity is null && costs is null && apiVersions is null && disabledReason is null && disabledReasonMessage is null && requiredFeature is null && countriesWithinCommerceBoundary is null ? default : new SkuProperties( + (dataLocationToServiceLocationMap ?? new ChangeTrackingList()).ToList(), capacity, - costs?.ToList(), - apiVersions?.ToList(), + (costs ?? new ChangeTrackingList()).ToList(), + (apiVersions ?? new ChangeTrackingList()).ToList(), disabledReason, disabledReasonMessage, requiredFeature, - countriesWithinCommerceBoundary?.ToList(), - serializedAdditionalRawData: null); + (countriesWithinCommerceBoundary ?? new ChangeTrackingList()).ToList(), + null), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Map of data location to service location. /// Location of the data. /// Location of the service. /// A new instance for mocking. - public static DataLocationToServiceLocationMap DataLocationToServiceLocationMap(AzureLocation? dataLocation = null, AzureLocation? serviceLocation = null) + public static DataLocationToServiceLocationMap DataLocationToServiceLocationMap(AzureLocation? dataLocation = default, AzureLocation? serviceLocation = default) { - return new DataLocationToServiceLocationMap(dataLocation, serviceLocation, serializedAdditionalRawData: null); + return new DataLocationToServiceLocationMap(dataLocation, serviceLocation, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Capacity of the sku. /// Usable capacity in TB. /// Maximum capacity in TB. /// Maximum capacity per device in TB. /// A new instance for mocking. - public static DataBoxSkuCapacity DataBoxSkuCapacity(string usable = null, string maximum = null, string individualSkuUsable = null) + public static DataBoxSkuCapacity DataBoxSkuCapacity(string usable = default, string maximum = default, string individualSkuUsable = default) { - return new DataBoxSkuCapacity(usable, maximum, individualSkuUsable, serializedAdditionalRawData: null); + return new DataBoxSkuCapacity(usable, maximum, individualSkuUsable, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Describes metadata for retrieving price info. /// Meter id of the Sku. /// The type of the meter. /// Multiplier specifies the region specific value to be multiplied with 1$ guid. Eg: Our new regions will be using 1$ shipping guid with appropriate multiplier specific to region. /// A new instance for mocking. - public static DataBoxSkuCost DataBoxSkuCost(Guid? meterId = null, string meterType = null, double? multiplier = null) - { - return new DataBoxSkuCost(meterId, meterType, multiplier, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Holds the device erasure completion status. - /// Shared access key to download cleanup or destruction certificate for device. - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static DeviceErasureDetails DeviceErasureDetails(DataBoxStageStatus? deviceErasureStatus, string erasureOrDestructionCertificateSasKey) - { - return DeviceErasureDetails(deviceErasureStatus: deviceErasureStatus, erasureOrDestructionCertificateSasKey: erasureOrDestructionCertificateSasKey, secureErasureCertificateSasKey: default); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Type of the data transfer. - /// Describes whether the job is cancellable or not. - /// Describes whether the job is deletable or not. - /// Describes whether the shipping address is editable or not. - /// The Editable status for Reverse Shipping Address and Contact Info. - /// The Editable status for Reverse Transport preferences. - /// Is Prepare To Ship Enabled on this job. - /// Name of the stage which is in progress. - /// Time at which the job was started in UTC ISO 8601 format. - /// Top level error for the job. - /// - /// Details of a job run. This field will only be sent for expand details filter. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// - /// Reason for cancellation. - /// Delivery type of Job. - /// Delivery Info of Job. - /// Flag to indicate cancellation of scheduled job. - /// The sku type. - /// Msi identity of the resource. - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static DataBoxJobData DataBoxJobData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, DataBoxJobTransferType transferType, bool? isCancellable, bool? isDeletable, bool? isShippingAddressEditable, ReverseShippingDetailsEditStatus? reverseShippingDetailsUpdate, ReverseTransportPreferenceEditStatus? reverseTransportPreferenceUpdate, bool? isPrepareToShipEnabled, DataBoxStageName? status, DateTimeOffset? startOn, ResponseError error, DataBoxBasicJobDetails details, string cancellationReason, JobDeliveryType? deliveryType, DateTimeOffset? deliveryInfoScheduledOn, bool? isCancellableWithoutFee, DataBoxSku sku, ManagedServiceIdentity identity) - { - return DataBoxJobData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, transferType: transferType, isCancellable: isCancellable, isDeletable: isDeletable, isShippingAddressEditable: isShippingAddressEditable, reverseShippingDetailsUpdate: reverseShippingDetailsUpdate, reverseTransportPreferenceUpdate: reverseTransportPreferenceUpdate, isPrepareToShipEnabled: isPrepareToShipEnabled, status: status, delayedStage: default, startOn: startOn, error: error, details: details, cancellationReason: cancellationReason, deliveryType: deliveryType, deliveryInfoScheduledOn: deliveryInfoScheduledOn, isCancellableWithoutFee: isCancellableWithoutFee, areAllDevicesLost: default, sku: sku, identity: identity); - } - - /// Initializes a new instance of . - /// Name of the job stage. - /// Display name of the job stage. - /// Status of the job stage. - /// Time for the job stage in UTC ISO 8601 format. - /// Job Stage Details. - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static DataBoxJobStage DataBoxJobStage(DataBoxStageName? stageName, string displayName, DataBoxStageStatus? stageStatus, DateTimeOffset? stageTime, BinaryData jobStageDetails) - { - return DataBoxJobStage(stageName: stageName, displayName: displayName, stageStatus: stageStatus, stageTime: stageTime, jobStageDetails: jobStageDetails, delayInformation: default); - } - - /// Initializes a new instance of . - /// Usable capacity in TB. - /// Maximum capacity in TB. - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static DataBoxSkuCapacity DataBoxSkuCapacity(string usable, string maximum) - { - return DataBoxSkuCapacity(usable: usable, maximum: maximum, individualSkuUsable: default); - } - - /// Initializes a new instance of . - /// Schedule availability for given sku in a region. - /// Transport options available for given sku in a region. - /// - /// Datacenter address for given sku in a region. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static RegionConfigurationResult RegionConfigurationResult(IEnumerable scheduleAvailabilityResponseAvailableDates, IEnumerable transportAvailabilityDetails, DataCenterAddressResult dataCenterAddressResponse) + public static DataBoxSkuCost DataBoxSkuCost(Guid? meterId = default, string meterType = default, double? multiplier = default) { - return RegionConfigurationResult(scheduleAvailabilityResponseAvailableDates: scheduleAvailabilityResponseAvailableDates, transportAvailabilityDetails: transportAvailabilityDetails, dataCenterAddressResponse: dataCenterAddressResponse, deviceCapabilityDetails: default); + return new DataBoxSkuCost(meterId, meterType, multiplier, additionalBinaryDataProperties: null); } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetAllAsyncCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..41ff31c16dba --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetAllAsyncCollectionResultOfT.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.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class JobResourcesGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly JobResources _client; + private readonly string _subscriptionId; + private readonly string _skipToken; + private readonly RequestContext _context; + + /// Initializes a new instance of JobResourcesGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The JobResources client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public JobResourcesGetAllAsyncCollectionResultOfT(JobResources client, string subscriptionId, string skipToken, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _skipToken = skipToken; + _context = context; + } + + /// Gets the pages of JobResourcesGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of JobResourcesGetAllAsyncCollectionResultOfT 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; + } + DataBoxJobListResult result = DataBoxJobListResult.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _skipToken, _context) : _client.CreateGetAllRequest(_subscriptionId, _skipToken, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.GetDataBoxJobs"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetAllCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..e2eb26478e61 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetAllCollectionResultOfT.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.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class JobResourcesGetAllCollectionResultOfT : Pageable + { + private readonly JobResources _client; + private readonly string _subscriptionId; + private readonly string _skipToken; + private readonly RequestContext _context; + + /// Initializes a new instance of JobResourcesGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The JobResources client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public JobResourcesGetAllCollectionResultOfT(JobResources client, string subscriptionId, string skipToken, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _skipToken = skipToken; + _context = context; + } + + /// Gets the pages of JobResourcesGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of JobResourcesGetAllCollectionResultOfT 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; + } + DataBoxJobListResult result = DataBoxJobListResult.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.CreateNextGetAllRequest(nextLink, _subscriptionId, _skipToken, _context) : _client.CreateGetAllRequest(_subscriptionId, _skipToken, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.GetDataBoxJobs"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..83781bc9f08c --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetByResourceGroupAsyncCollectionResultOfT.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.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class JobResourcesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly JobResources _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _skipToken; + private readonly RequestContext _context; + + /// Initializes a new instance of JobResourcesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The JobResources 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. + /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public JobResourcesGetByResourceGroupAsyncCollectionResultOfT(JobResources client, string subscriptionId, string resourceGroupName, string skipToken, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _skipToken = skipToken; + _context = context; + } + + /// Gets the pages of JobResourcesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of JobResourcesGetByResourceGroupAsyncCollectionResultOfT 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; + } + DataBoxJobListResult result = DataBoxJobListResult.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, _skipToken, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _skipToken, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DataBoxJobCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetByResourceGroupCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..f384ebf22c64 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetByResourceGroupCollectionResultOfT.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.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class JobResourcesGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly JobResources _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _skipToken; + private readonly RequestContext _context; + + /// Initializes a new instance of JobResourcesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The JobResources 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. + /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public JobResourcesGetByResourceGroupCollectionResultOfT(JobResources client, string subscriptionId, string resourceGroupName, string skipToken, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _skipToken = skipToken; + _context = context; + } + + /// Gets the pages of JobResourcesGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of JobResourcesGetByResourceGroupCollectionResultOfT 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; + } + DataBoxJobListResult result = DataBoxJobListResult.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, _skipToken, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _skipToken, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DataBoxJobCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetCredentialsAsyncCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetCredentialsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..df369fb4e220 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetCredentialsAsyncCollectionResultOfT.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.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class JobResourcesGetCredentialsAsyncCollectionResultOfT : AsyncPageable + { + private readonly JobResources _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _jobName; + private readonly RequestContext _context; + + /// Initializes a new instance of JobResourcesGetCredentialsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The JobResources 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 name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public JobResourcesGetCredentialsAsyncCollectionResultOfT(JobResources client, string subscriptionId, string resourceGroupName, string jobName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _jobName = jobName; + _context = context; + } + + /// Gets the pages of JobResourcesGetCredentialsAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of JobResourcesGetCredentialsAsyncCollectionResultOfT 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; + } + UnencryptedCredentialsList result = UnencryptedCredentialsList.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.CreateNextGetCredentialsRequest(nextLink, _subscriptionId, _resourceGroupName, _jobName, _context) : _client.CreateGetCredentialsRequest(_subscriptionId, _resourceGroupName, _jobName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DataBoxJobResource.GetCredentials"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetCredentialsCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetCredentialsCollectionResultOfT.cs new file mode 100644 index 000000000000..bdf9261f9d1e --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/JobResourcesGetCredentialsCollectionResultOfT.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.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class JobResourcesGetCredentialsCollectionResultOfT : Pageable + { + private readonly JobResources _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _jobName; + private readonly RequestContext _context; + + /// Initializes a new instance of JobResourcesGetCredentialsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The JobResources 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 name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public JobResourcesGetCredentialsCollectionResultOfT(JobResources client, string subscriptionId, string resourceGroupName, string jobName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _jobName = jobName; + _context = context; + } + + /// Gets the pages of JobResourcesGetCredentialsCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of JobResourcesGetCredentialsCollectionResultOfT 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; + } + UnencryptedCredentialsList result = UnencryptedCredentialsList.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.CreateNextGetCredentialsRequest(nextLink, _subscriptionId, _resourceGroupName, _jobName, _context) : _client.CreateGetCredentialsRequest(_subscriptionId, _resourceGroupName, _jobName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DataBoxJobResource.GetCredentials"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..0ae52c914a42 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT : AsyncPageable + { + private readonly ServiceOperationGroup _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly AzureLocation _location; + private readonly RequestContent _content; + private readonly RequestContext _context; + + /// Initializes a new instance of ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ServiceOperationGroup 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 name of the Azure region. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT(ServiceOperationGroup client, string subscriptionId, string resourceGroupName, AzureLocation location, RequestContent content, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _location = location; + _content = content; + _context = context; + } + + /// Gets the pages of ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT 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; + } + AvailableSkusResult result = AvailableSkusResult.FromResponse(response); + yield return Page.FromValues(result.Value, nextPage?.AbsoluteUri, response); + string nextPageString = result.NextLink; + if (nextPageString == null) + { + yield break; + } + nextPage = new Uri(nextPageString); + } + } + + /// 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.CreateNextGetAvailableSkusRequest(nextLink, _subscriptionId, _resourceGroupName, _location, _content, _context) : _client.CreateGetAvailableSkusRequest(_subscriptionId, _resourceGroupName, _location, _content, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.GetAvailableSkus"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/ServiceOperationGroupGetAvailableSkusCollectionResultOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/ServiceOperationGroupGetAvailableSkusCollectionResultOfT.cs new file mode 100644 index 000000000000..860219d02164 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/CollectionResults/ServiceOperationGroupGetAvailableSkusCollectionResultOfT.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DataBox.Models; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class ServiceOperationGroupGetAvailableSkusCollectionResultOfT : Pageable + { + private readonly ServiceOperationGroup _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly AzureLocation _location; + private readonly RequestContent _content; + private readonly RequestContext _context; + + /// Initializes a new instance of ServiceOperationGroupGetAvailableSkusCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The ServiceOperationGroup 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 name of the Azure region. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ServiceOperationGroupGetAvailableSkusCollectionResultOfT(ServiceOperationGroup client, string subscriptionId, string resourceGroupName, AzureLocation location, RequestContent content, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _location = location; + _content = content; + _context = context; + } + + /// Gets the pages of ServiceOperationGroupGetAvailableSkusCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ServiceOperationGroupGetAvailableSkusCollectionResultOfT 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; + } + AvailableSkusResult result = AvailableSkusResult.FromResponse(response); + yield return Page.FromValues(result.Value, nextPage?.AbsoluteUri, response); + string nextPageString = result.NextLink; + if (nextPageString == null) + { + yield break; + } + nextPage = new Uri(nextPageString); + } + } + + /// 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.CreateNextGetAvailableSkusRequest(nextLink, _subscriptionId, _resourceGroupName, _location, _content, _context) : _client.CreateGetAvailableSkusRequest(_subscriptionId, _resourceGroupName, _location, _content, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.GetAvailableSkus"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobCollection.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobCollection.cs index 283b66b1fed6..c6dac6f32bdb 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobCollection.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobCollection.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.DataBox @@ -25,51 +26,53 @@ namespace Azure.ResourceManager.DataBox /// public partial class DataBoxJobCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _dataBoxJobJobResourcesClientDiagnostics; - private readonly JobResourcesRestOperations _dataBoxJobJobResourcesRestClient; + private readonly ClientDiagnostics _dataBoxClientClientDiagnostics; + private readonly DataBoxClient _dataBoxClientRestClient; + private readonly ClientDiagnostics _jobResourcesClientDiagnostics; + private readonly JobResources _jobResourcesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DataBoxJobCollection for mocking. protected DataBoxJobCollection() { } - /// 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 DataBoxJobCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _dataBoxJobJobResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataBox", DataBoxJobResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DataBoxJobResource.ResourceType, out string dataBoxJobJobResourcesApiVersion); - _dataBoxJobJobResourcesRestClient = new JobResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataBoxJobJobResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DataBoxJobResource.ResourceType, out string dataBoxJobApiVersion); + _dataBoxClientClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataBox", DataBoxJobResource.ResourceType.Namespace, Diagnostics); + _dataBoxClientRestClient = new DataBoxClient(_dataBoxClientClientDiagnostics, Pipeline, Endpoint, dataBoxJobApiVersion ?? "2025-07-01"); + _jobResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataBox", DataBoxJobResource.ResourceType.Namespace, Diagnostics); + _jobResourcesRestClient = new JobResources(_jobResourcesClientDiagnostics, Pipeline, Endpoint, dataBoxJobApiVersion ?? "2025-07-01"); + 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); + } } /// /// Creates a new job with the specified parameters. Existing job cannot be updated with this API and should instead be updated with the Update job API. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Create + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Default Api Version - /// 2025-07-01 + /// Operation Id. + /// JobResources_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// @@ -77,21 +80,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// Job details from request body. /// 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 jobName, DataBoxJobData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.CreateOrUpdate"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, jobName, data, cancellationToken).ConfigureAwait(false); - var operation = new DataBoxArmOperation(new DataBoxJobOperationSource(Client), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, _dataBoxJobJobResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, DataBoxJobData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DataBoxArmOperation operation = new DataBoxArmOperation( + new DataBoxJobOperationSource(Client), + _jobResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -105,20 +121,16 @@ public virtual async Task> CreateOrUpdateAsync( /// Creates a new job with the specified parameters. Existing job cannot be updated with this API and should instead be updated with the Update job API. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Create + /// Operation Id. + /// JobResources_Create. /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// @@ -126,21 +138,34 @@ public virtual async Task> CreateOrUpdateAsync( /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// Job details from request body. /// 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 jobName, DataBoxJobData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.CreateOrUpdate"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.CreateOrUpdate"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, jobName, data, cancellationToken); - var operation = new DataBoxArmOperation(new DataBoxJobOperationSource(Client), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, _dataBoxJobJobResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, data).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, DataBoxJobData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DataBoxArmOperation operation = new DataBoxArmOperation( + new DataBoxJobOperationSource(Client), + _jobResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -154,39 +179,43 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUnt /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Default Api Version - /// 2025-07-01 + /// Operation Id. + /// JobResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual async Task> GetAsync(string jobName, string expand = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Get"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Get"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -200,39 +229,43 @@ public virtual async Task> GetAsync(string jobName, /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Default Api Version - /// 2025-07-01 + /// Operation Id. + /// JobResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual Response Get(string jobName, string expand = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Get"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Get"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -246,99 +279,109 @@ public virtual Response Get(string jobName, string expand = /// Lists all the jobs available under the given resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs. /// /// - /// Operation Id - /// JobResource_ListByResourceGroup + /// Operation Id. + /// JobResources_ListByResourceGroup. /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(string skipToken = null, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string skipToken = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _dataBoxJobJobResourcesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, skipToken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataBoxJobJobResourcesRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, skipToken); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DataBoxJobResource(Client, DataBoxJobData.DeserializeDataBoxJobData(e)), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, "DataBoxJobCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new JobResourcesGetByResourceGroupAsyncCollectionResultOfT(_jobResourcesRestClient, Id.SubscriptionId, Id.ResourceGroupName, skipToken, context), data => new DataBoxJobResource(Client, data)); } /// /// Lists all the jobs available under the given resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs - /// - /// - /// Operation Id - /// JobResource_ListByResourceGroup + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs. /// /// - /// Default Api Version - /// 2025-07-01 + /// Operation Id. + /// JobResources_ListByResourceGroup. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(string skipToken = null, CancellationToken cancellationToken = default) + public virtual Pageable GetAll(string skipToken = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _dataBoxJobJobResourcesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, skipToken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataBoxJobJobResourcesRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, skipToken); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DataBoxJobResource(Client, DataBoxJobData.DeserializeDataBoxJobData(e)), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, "DataBoxJobCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new JobResourcesGetByResourceGroupCollectionResultOfT(_jobResourcesRestClient, Id.SubscriptionId, Id.ResourceGroupName, skipToken, context), data => new DataBoxJobResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Get + /// Operation Id. + /// JobResources_Get. /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual async Task> ExistsAsync(string jobName, string expand = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Exists"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Exists"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DataBoxJobData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -349,40 +392,54 @@ public virtual async Task> ExistsAsync(string jobName, string exp } /// - /// Checks to see if the resource exists in azure. + /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Default Api Version - /// 2025-07-01 + /// Operation Id. + /// JobResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual Response Exists(string jobName, string expand = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Exists"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.Exists"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DataBoxJobData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -393,42 +450,58 @@ public virtual Response Exists(string jobName, string expand = null, Cance } /// - /// Tries to get details for this resource from the service. + /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Default Api Version - /// 2025-07-01 + /// Operation Id. + /// JobResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual async Task> GetIfExistsAsync(string jobName, string expand = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.GetIfExists"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.GetIfExists"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DataBoxJobData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -439,42 +512,58 @@ public virtual async Task> GetIfExistsAsync } /// - /// Tries to get details for this resource from the service. + /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Get + /// Operation Id. + /// JobResources_Get. /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - public virtual NullableResponse GetIfExists(string jobName, string expand = null, CancellationToken cancellationToken = default) + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.GetIfExists"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobCollection.GetIfExists"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, jobName, expand, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DataBoxJobData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -494,6 +583,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/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.Serialization.cs index f281e5d580e9..bc3d7be8edeb 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.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.DataBox.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DataBox { - public partial class DataBoxJobData : IUtf8JsonSerializable, IJsonModel + /// Job Resource. + public partial class DataBoxJobData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxJobData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,409 +38,162 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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(DataBoxJobData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - ((IJsonModel)Identity).Write(writer, options); - } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - writer.WritePropertyName("transferType"u8); - writer.WriteStringValue(TransferType.ToSerialString()); - if (options.Format != "W" && Optional.IsDefined(IsCancellable)) - { - writer.WritePropertyName("isCancellable"u8); - writer.WriteBooleanValue(IsCancellable.Value); - } - if (options.Format != "W" && Optional.IsDefined(IsDeletable)) - { - writer.WritePropertyName("isDeletable"u8); - writer.WriteBooleanValue(IsDeletable.Value); - } - if (options.Format != "W" && Optional.IsDefined(IsShippingAddressEditable)) - { - writer.WritePropertyName("isShippingAddressEditable"u8); - writer.WriteBooleanValue(IsShippingAddressEditable.Value); - } - if (options.Format != "W" && Optional.IsDefined(ReverseShippingDetailsUpdate)) - { - writer.WritePropertyName("reverseShippingDetailsUpdate"u8); - writer.WriteStringValue(ReverseShippingDetailsUpdate.Value.ToSerialString()); - } - if (options.Format != "W" && Optional.IsDefined(ReverseTransportPreferenceUpdate)) - { - writer.WritePropertyName("reverseTransportPreferenceUpdate"u8); - writer.WriteStringValue(ReverseTransportPreferenceUpdate.Value.ToSerialString()); - } - if (options.Format != "W" && Optional.IsDefined(IsPrepareToShipEnabled)) - { - writer.WritePropertyName("isPrepareToShipEnabled"u8); - writer.WriteBooleanValue(IsPrepareToShipEnabled.Value); - } - if (options.Format != "W" && Optional.IsDefined(Status)) - { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(DelayedStage)) - { - writer.WritePropertyName("delayedStage"u8); - writer.WriteStringValue(DelayedStage.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(StartOn)) - { - writer.WritePropertyName("startTime"u8); - writer.WriteStringValue(StartOn.Value, "O"); - } - if (options.Format != "W" && Optional.IsDefined(Error)) - { - writer.WritePropertyName("error"u8); - ((IJsonModel)Error).Write(writer, options); - } - if (Optional.IsDefined(Details)) - { - writer.WritePropertyName("details"u8); - writer.WriteObjectValue(Details, options); - } - if (options.Format != "W" && Optional.IsDefined(CancellationReason)) - { - writer.WritePropertyName("cancellationReason"u8); - writer.WriteStringValue(CancellationReason); - } - if (Optional.IsDefined(DeliveryType)) - { - writer.WritePropertyName("deliveryType"u8); - writer.WriteStringValue(DeliveryType.Value.ToSerialString()); - } - if (Optional.IsDefined(DeliveryInfo)) - { - writer.WritePropertyName("deliveryInfo"u8); - writer.WriteObjectValue(DeliveryInfo, options); - } - if (options.Format != "W" && Optional.IsDefined(IsCancellableWithoutFee)) - { - writer.WritePropertyName("isCancellableWithoutFee"u8); - writer.WriteBooleanValue(IsCancellableWithoutFee.Value); + writer.WriteObjectValue(Identity, options); } - if (options.Format != "W" && Optional.IsDefined(AreAllDevicesLost)) - { - writer.WritePropertyName("allDevicesLost"u8); - writer.WriteBooleanValue(AreAllDevicesLost.Value); - } - writer.WriteEndObject(); } - DataBoxJobData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxJobData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxJobData)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(DataBoxJobData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxJobData(document.RootElement, options); } - internal static DataBoxJobData DeserializeDataBoxJobData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxJobData DeserializeDataBoxJobData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DataBoxSku 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; - DataBoxJobTransferType transferType = default; - bool? isCancellable = default; - bool? isDeletable = default; - bool? isShippingAddressEditable = default; - ReverseShippingDetailsEditStatus? reverseShippingDetailsUpdate = default; - ReverseTransportPreferenceEditStatus? reverseTransportPreferenceUpdate = default; - bool? isPrepareToShipEnabled = default; - DataBoxStageName? status = default; - DataBoxStageName? delayedStage = default; - DateTimeOffset? startTime = default; - ResponseError error = default; - DataBoxBasicJobDetails details = default; - string cancellationReason = default; - JobDeliveryType? deliveryType = default; - JobDeliveryInfo deliveryInfo = default; - bool? isCancellableWithoutFee = default; - bool? allDevicesLost = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + JobProperties properties = default; + DataBoxSku sku = default; + ResourceIdentity identity = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sku"u8)) + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) { - sku = DataBoxSku.DeserializeDataBoxSku(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())), options, AzureResourceManagerDataBoxContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.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(property.Value.GetString()); + location = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("properties"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + properties = JobProperties.DeserializeJobProperties(prop.Value, options); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("sku"u8)) { - name = property.Value.GetString(); + sku = DataBoxSku.DeserializeDataBoxSku(prop.Value, options); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("identity"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, AzureResourceManagerDataBoxContext.Default); - continue; - } - if (property.NameEquals("properties"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("transferType"u8)) - { - transferType = property0.Value.GetString().ToDataBoxJobTransferType(); - continue; - } - if (property0.NameEquals("isCancellable"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - isCancellable = property0.Value.GetBoolean(); - continue; - } - if (property0.NameEquals("isDeletable"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - isDeletable = property0.Value.GetBoolean(); - continue; - } - if (property0.NameEquals("isShippingAddressEditable"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - isShippingAddressEditable = property0.Value.GetBoolean(); - continue; - } - if (property0.NameEquals("reverseShippingDetailsUpdate"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - reverseShippingDetailsUpdate = property0.Value.GetString().ToReverseShippingDetailsEditStatus(); - continue; - } - if (property0.NameEquals("reverseTransportPreferenceUpdate"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - reverseTransportPreferenceUpdate = property0.Value.GetString().ToReverseTransportPreferenceEditStatus(); - continue; - } - if (property0.NameEquals("isPrepareToShipEnabled"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - isPrepareToShipEnabled = property0.Value.GetBoolean(); - continue; - } - if (property0.NameEquals("status"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = new DataBoxStageName(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("delayedStage"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - delayedStage = new DataBoxStageName(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("startTime"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startTime = property0.Value.GetDateTimeOffset("O"); - continue; - } - if (property0.NameEquals("error"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); - continue; - } - if (property0.NameEquals("details"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - details = DataBoxBasicJobDetails.DeserializeDataBoxBasicJobDetails(property0.Value, options); - continue; - } - if (property0.NameEquals("cancellationReason"u8)) - { - cancellationReason = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("deliveryType"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - deliveryType = property0.Value.GetString().ToJobDeliveryType(); - continue; - } - if (property0.NameEquals("deliveryInfo"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - deliveryInfo = JobDeliveryInfo.DeserializeJobDeliveryInfo(property0.Value, options); - continue; - } - if (property0.NameEquals("isCancellableWithoutFee"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - isCancellableWithoutFee = property0.Value.GetBoolean(); - continue; - } - if (property0.NameEquals("allDevicesLost"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - allDevicesLost = property0.Value.GetBoolean(); - continue; - } - } + identity = ResourceIdentity.DeserializeResourceIdentity(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 DataBoxJobData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - transferType, - isCancellable, - isDeletable, - isShippingAddressEditable, - reverseShippingDetailsUpdate, - reverseTransportPreferenceUpdate, - isPrepareToShipEnabled, - status, - delayedStage, - startTime, - error, - details, - cancellationReason, - deliveryType, - deliveryInfo, - isCancellableWithoutFee, - allDevicesLost, + 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": @@ -443,15 +203,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - DataBoxJobData 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. + DataBoxJobData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxJobData)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 DeserializeDataBoxJobData(document.RootElement, options); } default: @@ -459,6 +224,26 @@ DataBoxJobData IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DataBoxJobData dataBoxJobData) + { + if (dataBoxJobData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(dataBoxJobData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DataBoxJobData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDataBoxJobData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.cs index 9d87ddb9fcea..c88ea1796662 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobData.cs @@ -7,176 +7,242 @@ using System; using System.Collections.Generic; +using Azure; using Azure.Core; using Azure.ResourceManager.DataBox.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DataBox { - /// - /// A class representing the DataBoxJob data model. - /// Job Resource. - /// + /// Job Resource. public partial class DataBoxJobData : 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. /// Type of the data transfer. /// The sku type. /// is null. public DataBoxJobData(AzureLocation location, DataBoxJobTransferType transferType, DataBoxSku sku) : base(location) { - Argument.AssertNotNull(sku, nameof(sku)); - TransferType = transferType; + Properties = new JobProperties(transferType); Sku = sku; } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Type of the data transfer. - /// Describes whether the job is cancellable or not. - /// Describes whether the job is deletable or not. - /// Describes whether the shipping address is editable or not. - /// The Editable status for Reverse Shipping Address and Contact Info. - /// The Editable status for Reverse Transport preferences. - /// Is Prepare To Ship Enabled on this job. - /// Name of the stage which is in progress. - /// Name of the stage where delay might be present. - /// Time at which the job was started in UTC ISO 8601 format. - /// Top level error for the job. - /// - /// Details of a job run. This field will only be sent for expand details filter. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// - /// Reason for cancellation. - /// Delivery type of Job. - /// Delivery Info of Job. - /// Flag to indicate cancellation of scheduled job. - /// Flag to indicate if all devices associated with the job are lost. + /// 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. + /// Properties of a job. /// The sku type. /// Msi identity of the resource. - /// Keeps track of any properties unknown to the library. - internal DataBoxJobData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, DataBoxJobTransferType transferType, bool? isCancellable, bool? isDeletable, bool? isShippingAddressEditable, ReverseShippingDetailsEditStatus? reverseShippingDetailsUpdate, ReverseTransportPreferenceEditStatus? reverseTransportPreferenceUpdate, bool? isPrepareToShipEnabled, DataBoxStageName? status, DataBoxStageName? delayedStage, DateTimeOffset? startOn, ResponseError error, DataBoxBasicJobDetails details, string cancellationReason, JobDeliveryType? deliveryType, JobDeliveryInfo deliveryInfo, bool? isCancellableWithoutFee, bool? areAllDevicesLost, DataBoxSku sku, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) - { - TransferType = transferType; - IsCancellable = isCancellable; - IsDeletable = isDeletable; - IsShippingAddressEditable = isShippingAddressEditable; - ReverseShippingDetailsUpdate = reverseShippingDetailsUpdate; - ReverseTransportPreferenceUpdate = reverseTransportPreferenceUpdate; - IsPrepareToShipEnabled = isPrepareToShipEnabled; - Status = status; - DelayedStage = delayedStage; - StartOn = startOn; - Error = error; - Details = details; - CancellationReason = cancellationReason; - DeliveryType = deliveryType; - DeliveryInfo = deliveryInfo; - IsCancellableWithoutFee = isCancellableWithoutFee; - AreAllDevicesLost = areAllDevicesLost; + internal DataBoxJobData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, JobProperties properties, DataBoxSku sku, ResourceIdentity identity) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; Sku = sku; Identity = identity; - _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal DataBoxJobData() + /// Properties of a job. + internal JobProperties Properties { get; set; } + + /// The sku type. + public DataBoxSku Sku { get; set; } + + /// Msi identity of the resource. + public ResourceIdentity Identity { get; set; } + + /// Type of the data transfer. + public DataBoxJobTransferType TransferType { + get + { + return Properties is null ? default : Properties.TransferType; + } + set + { + if (Properties is null) + { + Properties = new JobProperties(); + } + Properties.TransferType = value; + } } - /// Type of the data transfer. - public DataBoxJobTransferType TransferType { get; set; } /// Describes whether the job is cancellable or not. - public bool? IsCancellable { get; } + public bool? IsCancellable + { + get + { + return Properties is null ? default : Properties.IsCancellable; + } + } + /// Describes whether the job is deletable or not. - public bool? IsDeletable { get; } + public bool? IsDeletable + { + get + { + return Properties is null ? default : Properties.IsDeletable; + } + } + /// Describes whether the shipping address is editable or not. - public bool? IsShippingAddressEditable { get; } + public bool? IsShippingAddressEditable + { + get + { + return Properties is null ? default : Properties.IsShippingAddressEditable; + } + } + /// The Editable status for Reverse Shipping Address and Contact Info. - public ReverseShippingDetailsEditStatus? ReverseShippingDetailsUpdate { get; } + public ReverseShippingDetailsEditStatus? ReverseShippingDetailsUpdate + { + get + { + return Properties is null ? default : Properties.ReverseShippingDetailsUpdate; + } + } + /// The Editable status for Reverse Transport preferences. - public ReverseTransportPreferenceEditStatus? ReverseTransportPreferenceUpdate { get; } + public ReverseTransportPreferenceEditStatus? ReverseTransportPreferenceUpdate + { + get + { + return Properties is null ? default : Properties.ReverseTransportPreferenceUpdate; + } + } + /// Is Prepare To Ship Enabled on this job. - public bool? IsPrepareToShipEnabled { get; } + public bool? IsPrepareToShipEnabled + { + get + { + return Properties is null ? default : Properties.IsPrepareToShipEnabled; + } + } + /// Name of the stage which is in progress. - public DataBoxStageName? Status { get; } + public DataBoxStageName? Status + { + get + { + return Properties is null ? default : Properties.Status; + } + } + /// Name of the stage where delay might be present. - public DataBoxStageName? DelayedStage { get; } + public DataBoxStageName? DelayedStage + { + get + { + return Properties is null ? default : Properties.DelayedStage; + } + } + /// Time at which the job was started in UTC ISO 8601 format. - public DateTimeOffset? StartOn { get; } + public DateTimeOffset? StartOn + { + get + { + return Properties is null ? default : Properties.StartOn; + } + } + /// Top level error for the job. - public ResponseError Error { get; } - /// - /// Details of a job run. This field will only be sent for expand details filter. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// - public DataBoxBasicJobDetails Details { get; set; } + public ResponseError Error + { + get + { + return Properties is null ? default : Properties.Error; + } + } + + /// Details of a job run. This field will only be sent for expand details filter. + public DataBoxBasicJobDetails Details + { + get + { + return Properties is null ? default : Properties.Details; + } + set + { + if (Properties is null) + { + Properties = new JobProperties(); + } + Properties.Details = value; + } + } + /// Reason for cancellation. - public string CancellationReason { get; } + public string CancellationReason + { + get + { + return Properties is null ? default : Properties.CancellationReason; + } + } + /// Delivery type of Job. - public JobDeliveryType? DeliveryType { get; set; } - /// Delivery Info of Job. - internal JobDeliveryInfo DeliveryInfo { get; set; } - /// Scheduled date time. - public DateTimeOffset? DeliveryInfoScheduledOn + public JobDeliveryType? DeliveryType { - get => DeliveryInfo is null ? default : DeliveryInfo.ScheduledOn; + get + { + return Properties is null ? default : Properties.DeliveryType; + } set { - if (DeliveryInfo is null) - DeliveryInfo = new JobDeliveryInfo(); - DeliveryInfo.ScheduledOn = value; + if (Properties is null) + { + Properties = new JobProperties(); + } + Properties.DeliveryType = value.Value; } } /// Flag to indicate cancellation of scheduled job. - public bool? IsCancellableWithoutFee { get; } + public bool? IsCancellableWithoutFee + { + get + { + return Properties is null ? default : Properties.IsCancellableWithoutFee; + } + } + /// Flag to indicate if all devices associated with the job are lost. - public bool? AreAllDevicesLost { get; } - /// The sku type. - public DataBoxSku Sku { get; set; } - /// Msi identity of the resource. - public ManagedServiceIdentity Identity { get; set; } + public bool? AreAllDevicesLost + { + get + { + return Properties is null ? default : Properties.AreAllDevicesLost; + } + } + + /// Scheduled date time. + public DateTimeOffset? DeliveryInfoScheduledOn + { + get + { + return Properties is null ? default : Properties.DeliveryInfoScheduledOn; + } + set + { + if (Properties is null) + { + Properties = new JobProperties(); + } + Properties.DeliveryInfoScheduledOn = value.Value; + } + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.Serialization.cs index b7570bab2bca..8dbb2dfaff09 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DataBox { + /// public partial class DataBoxJobResource : IJsonModel { - private static DataBoxJobData s_dataDeserializationInstance; - private static DataBoxJobData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DataBoxJobData(); + + /// 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); - DataBoxJobData 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. + DataBoxJobData 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, AzureResourceManagerDataBoxContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DataBoxJobData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDataBoxContext.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/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.cs index 8cb507ecd23d..99dcb3702132 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/DataBoxJobResource.cs @@ -7,50 +7,39 @@ 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.DataBox.Models; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DataBox { /// - /// A Class representing a DataBoxJob 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 GetDataBoxJobResource method. - /// Otherwise you can get one from its parent resource using the GetDataBoxJob method. + /// A class representing a DataBoxJob 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 GetDataBoxJobs method. /// public partial class DataBoxJobResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The jobName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string jobName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _dataBoxJobJobResourcesClientDiagnostics; - private readonly JobResourcesRestOperations _dataBoxJobJobResourcesRestClient; private readonly ClientDiagnostics _dataBoxClientClientDiagnostics; - private readonly DataBoxRestOperations _dataBoxClientRestClient; + private readonly DataBoxClient _dataBoxClientRestClient; + private readonly ClientDiagnostics _jobResourcesClientDiagnostics; + private readonly JobResources _jobResourcesRestClient; private readonly DataBoxJobData _data; - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.DataBox/jobs"; + public static readonly ResourceType ResourceType = "Microsoft.DataBox/jobs/mitigate"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DataBoxJobResource for mocking. protected DataBoxJobResource() { } - /// 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 DataBoxJobResource(ArmClient client, DataBoxJobData data) : this(client, data.Id) @@ -59,75 +48,94 @@ internal DataBoxJobResource(ArmClient client, DataBoxJobData data) : this(client _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 DataBoxJobResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _dataBoxJobJobResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataBox", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string dataBoxJobJobResourcesApiVersion); - _dataBoxJobJobResourcesRestClient = new JobResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, dataBoxJobJobResourcesApiVersion); - _dataBoxClientClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataBox", ProviderConstants.DefaultProviderNamespace, Diagnostics); - _dataBoxClientRestClient = new DataBoxRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string dataBoxJobApiVersion); + _dataBoxClientClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataBox", ResourceType.Namespace, Diagnostics); + _dataBoxClientRestClient = new DataBoxClient(_dataBoxClientClientDiagnostics, Pipeline, Endpoint, dataBoxJobApiVersion ?? "2025-07-01"); + _jobResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataBox", ResourceType.Namespace, Diagnostics); + _jobResourcesRestClient = new JobResources(_jobResourcesClientDiagnostics, Pipeline, Endpoint, dataBoxJobApiVersion ?? "2025-07-01"); + 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 DataBoxJobData 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 jobName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string jobName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}"; + 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); + } } /// - /// Gets information about the specified job. + /// Request to mitigate for a given job /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/mitigate. /// /// - /// Operation Id - /// JobResource_Get + /// Operation Id. + /// DataBox_Mitigate. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// $expand is supported on details parameter for job, which provides details on the job stages. + /// Mitigation Request. /// The cancellation token to use. - public virtual async Task> GetAsync(string expand = null, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task MitigateAsync(MitigateJobContent content, CancellationToken cancellationToken = default) { - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Get"); + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _dataBoxClientClientDiagnostics.CreateScope("DataBoxJobResource.Mitigate"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dataBoxClientRestClient.CreateMitigateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, MitigateJobContent.ToRequestContent(content), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return response; } catch (Exception e) { @@ -137,38 +145,44 @@ public virtual async Task> GetAsync(string expand = } /// - /// Gets information about the specified job. + /// Request to mitigate for a given job /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/mitigate. /// /// - /// Operation Id - /// JobResource_Get + /// Operation Id. + /// DataBox_Mitigate. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// $expand is supported on details parameter for job, which provides details on the job stages. + /// Mitigation Request. /// The cancellation token to use. - public virtual Response Get(string expand = null, CancellationToken cancellationToken = default) + /// is null. + public virtual Response Mitigate(MitigateJobContent content, CancellationToken cancellationToken = default) { - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Get"); + Argument.AssertNotNull(content, nameof(content)); + + using DiagnosticScope scope = _dataBoxClientClientDiagnostics.CreateScope("DataBoxJobResource.Mitigate"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _dataBoxClientRestClient.CreateMitigateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, MitigateJobContent.ToRequestContent(content), context); + Response response = Pipeline.ProcessMessage(message, context); + return response; } catch (Exception e) { @@ -178,39 +192,46 @@ public virtual Response Get(string expand = null, Cancellati } /// - /// Deletes a job. + /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Delete + /// Operation Id. + /// JobResources_Get. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// 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. + /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + public virtual async Task> GetAsync(string expand = default, CancellationToken cancellationToken = default) { - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Delete"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Get"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DataBoxArmOperation(_dataBoxJobJobResourcesClientDiagnostics, Pipeline, _dataBoxJobJobResourcesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -220,39 +241,46 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Deletes a job. + /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Delete + /// Operation Id. + /// JobResources_Get. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// 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. + /// $expand is supported on details parameter for job, which provides details on the job stages. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + public virtual Response Get(string expand = default, CancellationToken cancellationToken = default) { - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Delete"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Get"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new DataBoxArmOperation(_dataBoxJobJobResourcesClientDiagnostics, Pipeline, _dataBoxJobJobResourcesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -265,20 +293,20 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// Updates the properties of an existing job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Update + /// Operation Id. + /// JobResources_Update. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -287,18 +315,31 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// Defines the If-Match condition. The patch will be performed only if the ETag of the job on the server matches this value. /// The cancellation token to use. /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, DataBoxJobPatch patch, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DataBoxJobPatch patch, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Update"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Update"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, ifMatch, cancellationToken).ConfigureAwait(false); - var operation = new DataBoxArmOperation(new DataBoxJobOperationSource(Client), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, _dataBoxJobJobResourcesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, ifMatch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, DataBoxJobPatch.ToRequestContent(patch), ifMatch, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DataBoxArmOperation operation = new DataBoxArmOperation( + new DataBoxJobOperationSource(Client), + _jobResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -312,20 +353,20 @@ public virtual async Task> UpdateAsync(WaitUnti /// Updates the properties of an existing job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Update + /// Operation Id. + /// JobResources_Update. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -334,18 +375,31 @@ public virtual async Task> UpdateAsync(WaitUnti /// Defines the If-Match condition. The patch will be performed only if the ETag of the job on the server matches this value. /// The cancellation token to use. /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, DataBoxJobPatch patch, string ifMatch = null, CancellationToken cancellationToken = default) + public virtual ArmOperation Update(WaitUntil waitUntil, DataBoxJobPatch patch, ETag? ifMatch = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Update"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Update"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, ifMatch, cancellationToken); - var operation = new DataBoxArmOperation(new DataBoxJobOperationSource(Client), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, _dataBoxJobJobResourcesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, ifMatch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, DataBoxJobPatch.ToRequestContent(patch), ifMatch, context); + Response response = Pipeline.ProcessMessage(message, context); + DataBoxArmOperation operation = new DataBoxArmOperation( + new DataBoxJobOperationSource(Client), + _jobResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -356,35 +410,46 @@ public virtual ArmOperation Update(WaitUntil waitUntil, Data } /// - /// Request to mitigate for a given job + /// Deletes a job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/mitigate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// DataBox_Mitigate + /// Operation Id. + /// JobResources_Delete. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. + /// + /// + /// Resource. + /// . /// /// /// - /// Mitigation Request. + /// 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. - /// is null. - public virtual async Task MitigateAsync(MitigateJobContent content, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _dataBoxClientClientDiagnostics.CreateScope("DataBoxJobResource.Mitigate"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Delete"); scope.Start(); try { - var response = await _dataBoxClientRestClient.MitigateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); - return response; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DataBoxArmOperation operation = new DataBoxArmOperation(_jobResourcesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -394,35 +459,46 @@ public virtual async Task MitigateAsync(MitigateJobContent content, Ca } /// - /// Request to mitigate for a given job + /// Deletes a job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/mitigate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. + /// + /// + /// Operation Id. + /// JobResources_Delete. /// /// - /// Operation Id - /// DataBox_Mitigate + /// Default Api Version. + /// 2025-07-01. /// /// - /// Default Api Version - /// 2025-07-01 + /// Resource. + /// . /// /// /// - /// Mitigation Request. + /// 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. - /// is null. - public virtual Response Mitigate(MitigateJobContent content, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = _dataBoxClientClientDiagnostics.CreateScope("DataBoxJobResource.Mitigate"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Delete"); scope.Start(); try { - var response = _dataBoxClientRestClient.Mitigate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); - return response; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DataBoxArmOperation operation = new DataBoxArmOperation(_jobResourcesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; } catch (Exception e) { @@ -435,20 +511,20 @@ public virtual Response Mitigate(MitigateJobContent content, CancellationToken c /// Book shipment pick up. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/bookShipmentPickUp + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/bookShipmentPickUp. /// /// - /// Operation Id - /// JobResources_BookShipmentPickUp + /// Operation Id. + /// JobResources_BookShipmentPickUp. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -459,11 +535,21 @@ public virtual async Task> BookShipmentPic { Argument.AssertNotNull(content, nameof(content)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.BookShipmentPickUp"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.BookShipmentPickUp"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.BookShipmentPickUpAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateBookShipmentPickUpRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ShipmentPickUpContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxShipmentPickUpResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -477,20 +563,20 @@ public virtual async Task> BookShipmentPic /// Book shipment pick up. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/bookShipmentPickUp + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/bookShipmentPickUp. /// /// - /// Operation Id - /// JobResources_BookShipmentPickUp + /// Operation Id. + /// JobResources_BookShipmentPickUp. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -501,11 +587,21 @@ public virtual Response BookShipmentPickUp(Shipment { Argument.AssertNotNull(content, nameof(content)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.BookShipmentPickUp"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.BookShipmentPickUp"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.BookShipmentPickUp(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateBookShipmentPickUpRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ShipmentPickUpContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxShipmentPickUpResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -519,20 +615,20 @@ public virtual Response BookShipmentPickUp(Shipment /// CancelJob. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/cancel + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/cancel. /// /// - /// Operation Id - /// JobResources_Cancel + /// Operation Id. + /// JobResources_Cancel. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -543,11 +639,16 @@ public virtual async Task CancelAsync(DataBoxJobCancellationReason can { Argument.AssertNotNull(cancellationReason, nameof(cancellationReason)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Cancel"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Cancel"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.CancelAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationReason, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateCancelRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, DataBoxJobCancellationReason.ToRequestContent(cancellationReason), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); return response; } catch (Exception e) @@ -561,20 +662,20 @@ public virtual async Task CancelAsync(DataBoxJobCancellationReason can /// CancelJob. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/cancel + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/cancel. /// /// - /// Operation Id - /// JobResources_Cancel + /// Operation Id. + /// JobResources_Cancel. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -585,11 +686,16 @@ public virtual Response Cancel(DataBoxJobCancellationReason cancellationReason, { Argument.AssertNotNull(cancellationReason, nameof(cancellationReason)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Cancel"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.Cancel"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.Cancel(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationReason, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateCancelRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, DataBoxJobCancellationReason.ToRequestContent(cancellationReason), context); + Response response = Pipeline.ProcessMessage(message, context); return response; } catch (Exception e) @@ -603,50 +709,52 @@ public virtual Response Cancel(DataBoxJobCancellationReason cancellationReason, /// This method gets the unencrypted secrets related to the job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/listCredentials + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/listCredentials. /// /// - /// Operation Id - /// JobResources_ListCredentials + /// Operation Id. + /// JobResources_ListCredentials. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// 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 GetCredentialsAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _dataBoxJobJobResourcesRestClient.CreateListCredentialsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataBoxJobJobResourcesRestClient.CreateListCredentialsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => UnencryptedCredentials.DeserializeUnencryptedCredentials(e), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, "DataBoxJobResource.GetCredentials", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new JobResourcesGetCredentialsAsyncCollectionResultOfT(_jobResourcesRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); } /// /// This method gets the unencrypted secrets related to the job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/listCredentials + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/listCredentials. /// /// - /// Operation Id - /// JobResources_ListCredentials + /// Operation Id. + /// JobResources_ListCredentials. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -654,29 +762,31 @@ public virtual AsyncPageable GetCredentialsAsync(Cancell /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetCredentials(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _dataBoxJobJobResourcesRestClient.CreateListCredentialsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _dataBoxJobJobResourcesRestClient.CreateListCredentialsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => UnencryptedCredentials.DeserializeUnencryptedCredentials(e), _dataBoxJobJobResourcesClientDiagnostics, Pipeline, "DataBoxJobResource.GetCredentials", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new JobResourcesGetCredentialsCollectionResultOfT(_jobResourcesRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); } /// /// Request to mark devices for a given job as shipped /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/markDevicesShipped + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/markDevicesShipped. /// /// - /// Operation Id - /// JobResources_MarkDevicesShipped + /// Operation Id. + /// JobResources_MarkDevicesShipped. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -687,11 +797,16 @@ public virtual async Task MarkDevicesShippedAsync(MarkDevicesShippedCo { Argument.AssertNotNull(content, nameof(content)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.MarkDevicesShipped"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.MarkDevicesShipped"); scope.Start(); try { - var response = await _dataBoxJobJobResourcesRestClient.MarkDevicesShippedAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateMarkDevicesShippedRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, MarkDevicesShippedContent.ToRequestContent(content), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); return response; } catch (Exception e) @@ -705,20 +820,20 @@ public virtual async Task MarkDevicesShippedAsync(MarkDevicesShippedCo /// Request to mark devices for a given job as shipped /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/markDevicesShipped + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}/markDevicesShipped. /// /// - /// Operation Id - /// JobResources_MarkDevicesShipped + /// Operation Id. + /// JobResources_MarkDevicesShipped. /// /// - /// Default Api Version - /// 2025-07-01 + /// Default Api Version. + /// 2025-07-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -729,11 +844,16 @@ public virtual Response MarkDevicesShipped(MarkDevicesShippedContent content, Ca { Argument.AssertNotNull(content, nameof(content)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.MarkDevicesShipped"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.MarkDevicesShipped"); scope.Start(); try { - var response = _dataBoxJobJobResourcesRestClient.MarkDevicesShipped(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateMarkDevicesShippedRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, MarkDevicesShippedContent.ToRequestContent(content), context); + Response response = Pipeline.ProcessMessage(message, context); return response; } catch (Exception e) @@ -743,27 +863,7 @@ public virtual Response MarkDevicesShipped(MarkDevicesShippedContent content, Ca } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -773,28 +873,34 @@ public virtual async Task> AddTagAsync(string key, Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.AddTag"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.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 _dataBoxJobJobResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DataBoxJobResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DataBoxJobPatch(); - foreach (var tag in current.Tags) + DataBoxJobData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DataBoxJobPatch patch = new DataBoxJobPatch(); + 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()); } } @@ -805,27 +911,7 @@ public virtual async Task> AddTagAsync(string key, } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -835,28 +921,34 @@ public virtual Response AddTag(string key, string value, Can Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.AddTag"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.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 = _dataBoxJobJobResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, cancellationToken); - return Response.FromValue(new DataBoxJobResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DataBoxJobPatch(); - foreach (var tag in current.Tags) + DataBoxJobData current = Get(cancellationToken: cancellationToken).Value.Data; + DataBoxJobPatch patch = new DataBoxJobPatch(); + 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()); } } @@ -867,53 +959,39 @@ public virtual Response AddTag(string key, string value, Can } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// 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 = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.SetTags"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.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 _dataBoxJobJobResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DataBoxJobResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DataBoxJobPatch(); + DataBoxJobData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DataBoxJobPatch patch = new DataBoxJobPatch(); 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()); } } @@ -924,53 +1002,39 @@ public virtual async Task> SetTagsAsync(IDictionary } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// 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 = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.SetTags"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.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 = _dataBoxJobJobResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, cancellationToken); - return Response.FromValue(new DataBoxJobResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DataBoxJobPatch(); + DataBoxJobData current = Get(cancellationToken: cancellationToken).Value.Data; + DataBoxJobPatch patch = new DataBoxJobPatch(); 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()); } } @@ -981,27 +1045,7 @@ public virtual Response SetTags(IDictionary } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1009,28 +1053,34 @@ public virtual async Task> RemoveTagAsync(string ke { Argument.AssertNotNull(key, nameof(key)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.RemoveTag"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.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 _dataBoxJobJobResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DataBoxJobResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DataBoxJobPatch(); - foreach (var tag in current.Tags) + DataBoxJobData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DataBoxJobPatch patch = new DataBoxJobPatch(); + 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()); } } @@ -1041,27 +1091,7 @@ public virtual async Task> RemoveTagAsync(string ke } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1069,28 +1099,34 @@ public virtual Response RemoveTag(string key, CancellationTo { Argument.AssertNotNull(key, nameof(key)); - using var scope = _dataBoxJobJobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.RemoveTag"); + using DiagnosticScope scope = _jobResourcesClientDiagnostics.CreateScope("DataBoxJobResource.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 = _dataBoxJobJobResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, cancellationToken); - return Response.FromValue(new DataBoxJobResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _jobResourcesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, null, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxJobData.FromResponse(result), result); + return Response.FromValue(new DataBoxJobResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DataBoxJobPatch(); - foreach (var tag in current.Tags) + DataBoxJobData current = Get(cancellationToken: cancellationToken).Value.Data; + DataBoxJobPatch patch = new DataBoxJobPatch(); + 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()); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/DataBoxExtensions.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/DataBoxExtensions.cs index 22ff5c89b9e8..a89f043778c9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/DataBoxExtensions.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/DataBoxExtensions.cs @@ -8,7 +8,9 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.DataBox.Mocking; using Azure.ResourceManager.DataBox.Models; using Azure.ResourceManager.Resources; @@ -18,30 +20,32 @@ namespace Azure.ResourceManager.DataBox /// A class to add extension methods to Azure.ResourceManager.DataBox. public static partial class DataBoxExtensions { + /// private static MockableDataBoxArmClient GetMockableDataBoxArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableDataBoxArmClient(client0)); + return client.GetCachedClient(client0 => new MockableDataBoxArmClient(client0, ResourceIdentifier.Root)); } - private static MockableDataBoxResourceGroupResource GetMockableDataBoxResourceGroupResource(ArmResource resource) + /// + private static MockableDataBoxResourceGroupResource GetMockableDataBoxResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableDataBoxResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableDataBoxResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableDataBoxSubscriptionResource GetMockableDataBoxSubscriptionResource(ArmResource resource) + /// + private static MockableDataBoxSubscriptionResource GetMockableDataBoxSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableDataBoxSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableDataBoxSubscriptionResource(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,15 +57,15 @@ public static DataBoxJobResource GetDataBoxJobResource(this ArmClient client, Re } /// - /// Gets a collection of DataBoxJobResources in the ResourceGroupResource. + /// Gets a collection of DataBoxJobs 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 DataBoxJobResources and their operations over a DataBoxJobResource. + /// An object representing collection of DataBoxJobs and their operations over a DataBoxJobResource. public static DataBoxJobCollection GetDataBoxJobs(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -71,37 +75,18 @@ public static DataBoxJobCollection GetDataBoxJobs(this ResourceGroupResource res /// /// Gets information about the specified job. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// 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 name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// 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> GetDataBoxJobAsync(this ResourceGroupResource resourceGroupResource, string jobName, string expand = null, CancellationToken cancellationToken = default) + public static async Task> GetDataBoxJobAsync(this ResourceGroupResource resourceGroupResource, string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -110,37 +95,18 @@ public static async Task> GetDataBoxJobAsync(this R /// /// Gets information about the specified job. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} - /// - /// - /// Operation Id - /// JobResource_Get - /// - /// - /// Default Api Version - /// 2025-07-01 - /// /// - /// 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 name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. /// $expand is supported on details parameter for job, which provides details on the job stages. /// 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 GetDataBoxJob(this ResourceGroupResource resourceGroupResource, string jobName, string expand = null, CancellationToken cancellationToken = default) + public static Response GetDataBoxJob(this ResourceGroupResource resourceGroupResource, string jobName, string expand = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -149,31 +115,17 @@ public static Response GetDataBoxJob(this ResourceGroupResou /// /// This method provides the list of available skus for the given subscription, resource group and location. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/availableSkus - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetAvailableSkus - /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// - /// 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 name of the Azure region. /// Filters for showing the available skus. /// The cancellation token to use. - /// or is null. - /// An async collection of that may take multiple service requests to iterate over. + /// is null. + /// A collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAvailableSkusAsync(this ResourceGroupResource resourceGroupResource, AzureLocation location, AvailableSkusContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -183,30 +135,16 @@ public static AsyncPageable GetAvailableSkusAsync(this Re /// /// This method provides the list of available skus for the given subscription, resource group and location. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/availableSkus - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetAvailableSkus - /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// - /// 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 name of the Azure region. /// Filters for showing the available skus. /// The cancellation token to use. - /// or is null. + /// is null. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAvailableSkus(this ResourceGroupResource resourceGroupResource, AzureLocation location, AvailableSkusContent content, CancellationToken cancellationToken = default) { @@ -217,30 +155,16 @@ public static Pageable GetAvailableSkus(this ResourceGrou /// /// This API provides configuration details specific to given region/location at Resource group level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// - /// 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 name of the Azure region. /// Request body to get the configuration for the region at resource group level. /// The cancellation token to use. - /// or is null. + /// is null. public static async Task> GetRegionConfigurationAsync(this ResourceGroupResource resourceGroupResource, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -250,30 +174,16 @@ public static async Task> GetRegionConfigura /// /// This API provides configuration details specific to given region/location at Resource group level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// /// - /// 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 name of the Azure region. /// Request body to get the configuration for the region at resource group level. /// The cancellation token to use. - /// or is null. + /// is null. public static Response GetRegionConfiguration(this ResourceGroupResource resourceGroupResource, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -283,30 +193,16 @@ public static Response GetRegionConfiguration(this Re /// /// This method does all necessary pre-job creation validation under resource group. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// /// - /// 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 name of the Azure region. /// Inputs of the customer. /// The cancellation token to use. - /// or is null. + /// is null. public static async Task> ValidateInputsAsync(this ResourceGroupResource resourceGroupResource, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -316,30 +212,16 @@ public static async Task> ValidateInputsAsync( /// /// This method does all necessary pre-job creation validation under resource group. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// /// - /// 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 name of the Azure region. /// Inputs of the customer. /// The cancellation token to use. - /// or is null. + /// is null. public static Response ValidateInputs(this ResourceGroupResource resourceGroupResource, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -349,35 +231,17 @@ public static Response ValidateInputs(this ResourceGrou /// /// Lists all the jobs available under the subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/jobs - /// - /// - /// Operation Id - /// JobResource_List - /// - /// - /// Default Api Version - /// 2025-07-01 - /// /// - /// 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. /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. /// The cancellation token to use. /// is null. - /// An async collection of that may take multiple service requests to iterate over. - public static AsyncPageable GetDataBoxJobsAsync(this SubscriptionResource subscriptionResource, string skipToken = null, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetDataBoxJobsAsync(this SubscriptionResource subscriptionResource, string skipToken = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -386,35 +250,17 @@ public static AsyncPageable GetDataBoxJobsAsync(this Subscri /// /// Lists all the jobs available under the subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/jobs - /// - /// - /// Operation Id - /// JobResource_List - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// 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. /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. /// The cancellation token to use. /// is null. /// A collection of that may take multiple service requests to iterate over. - public static Pageable GetDataBoxJobs(this SubscriptionResource subscriptionResource, string skipToken = null, CancellationToken cancellationToken = default) + public static Pageable GetDataBoxJobs(this SubscriptionResource subscriptionResource, string skipToken = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -423,30 +269,16 @@ public static Pageable GetDataBoxJobs(this SubscriptionResou /// /// This API provides configuration details specific to given region/location at Subscription level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// - /// 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 name of the Azure region. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static async Task> GetRegionConfigurationAsync(this SubscriptionResource subscriptionResource, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -456,30 +288,16 @@ public static async Task> GetRegionConfigura /// /// This API provides configuration details specific to given region/location at Subscription level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// /// - /// 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 name of the Azure region. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static Response GetRegionConfiguration(this SubscriptionResource subscriptionResource, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -489,30 +307,16 @@ public static Response GetRegionConfiguration(this Su /// /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateAddress - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateAddress - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// /// - /// 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 name of the Azure region. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static async Task> ValidateAddressAsync(this SubscriptionResource subscriptionResource, AzureLocation location, DataBoxValidateAddressContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -522,30 +326,16 @@ public static async Task> ValidateAddressAsync /// /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateAddress - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateAddress - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// /// - /// 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 name of the Azure region. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static Response ValidateAddress(this SubscriptionResource subscriptionResource, AzureLocation location, DataBoxValidateAddressContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -555,30 +345,16 @@ public static Response ValidateAddress(this Subscriptio /// /// This method does all necessary pre-job creation validation under subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// /// - /// 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 name of the Azure region. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static async Task> ValidateInputsAsync(this SubscriptionResource subscriptionResource, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -588,30 +364,16 @@ public static async Task> ValidateInputsAsync( /// /// This method does all necessary pre-job creation validation under subscription. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// - /// 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 name of the Azure region. /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static Response ValidateInputs(this SubscriptionResource subscriptionResource, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxArmClient.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxArmClient.cs index 2b8381e093d7..6b9dbb129387 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxArmClient.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxArmClient.cs @@ -6,38 +6,27 @@ #nullable disable using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableDataBoxArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDataBoxArmClient for mocking. protected MockableDataBoxArmClient() { } - /// 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 MockableDataBoxArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableDataBoxArmClient(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 DataBoxJobResource GetDataBoxJobResource(ResourceIdentifier id) diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxResourceGroupResource.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxResourceGroupResource.cs index f2b074a9c013..76017d5beba6 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxResourceGroupResource.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxResourceGroupResource.cs @@ -8,42 +8,40 @@ 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.DataBox; using Azure.ResourceManager.DataBox.Models; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DataBox.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableDataBoxResourceGroupResource : ArmResource { private ClientDiagnostics _serviceOperationGroupClientDiagnostics; - private ServiceOperationGroupRestOperations _serviceOperationGroupRestClient; + private ServiceOperationGroup _serviceOperationGroupRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDataBoxResourceGroupResource for mocking. protected MockableDataBoxResourceGroupResource() { } - /// 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 MockableDataBoxResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics ServiceOperationGroupClientDiagnostics => _serviceOperationGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DataBox", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private ServiceOperationGroupRestOperations ServiceOperationGroupRestClient => _serviceOperationGroupRestClient ??= new ServiceOperationGroupRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics ServiceOperationGroupClientDiagnostics => _serviceOperationGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DataBox.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private ServiceOperationGroup ServiceOperationGroupRestClient => _serviceOperationGroupRestClient ??= new ServiceOperationGroup(ServiceOperationGroupClientDiagnostics, Pipeline, Endpoint, "2025-07-01"); - /// Gets a collection of DataBoxJobResources in the ResourceGroupResource. - /// An object representing collection of DataBoxJobResources and their operations over a DataBoxJobResource. + /// Gets a collection of DataBoxJobs in the . + /// An object representing collection of DataBoxJobs and their operations over a DataBoxJobResource. public virtual DataBoxJobCollection GetDataBoxJobs() { return GetCachedClient(client => new DataBoxJobCollection(client, Id)); @@ -53,20 +51,16 @@ public virtual DataBoxJobCollection GetDataBoxJobs() /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Get + /// Operation Id. + /// JobResources_Get. /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// @@ -76,8 +70,10 @@ public virtual DataBoxJobCollection GetDataBoxJobs() /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual async Task> GetDataBoxJobAsync(string jobName, string expand = null, CancellationToken cancellationToken = default) + public virtual async Task> GetDataBoxJobAsync(string jobName, string expand = default, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); + return await GetDataBoxJobs().GetAsync(jobName, expand, cancellationToken).ConfigureAwait(false); } @@ -85,20 +81,16 @@ public virtual async Task> GetDataBoxJobAsync(strin /// Gets information about the specified job. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}. /// /// - /// Operation Id - /// JobResource_Get + /// Operation Id. + /// JobResources_Get. /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// @@ -108,59 +100,37 @@ public virtual async Task> GetDataBoxJobAsync(strin /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual Response GetDataBoxJob(string jobName, string expand = null, CancellationToken cancellationToken = default) + public virtual Response GetDataBoxJob(string jobName, string expand = default, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); + return GetDataBoxJobs().Get(jobName, expand, cancellationToken); } - /// - /// This method provides the list of available skus for the given subscription, resource group and location. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/availableSkus - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetAvailableSkus - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This method provides the list of available skus for the given subscription, resource group and location. /// The name of the Azure region. /// Filters for showing the available skus. /// 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 virtual AsyncPageable GetAvailableSkusAsync(AzureLocation location, AvailableSkusContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); - HttpMessage FirstPageRequest(int? pageSizeHint) => ServiceOperationGroupRestClient.CreateGetAvailableSkusRequest(Id.SubscriptionId, Id.ResourceGroupName, location, content); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ServiceOperationGroupRestClient.CreateGetAvailableSkusNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, location, content); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DataBoxSkuInformation.DeserializeDataBoxSkuInformation(e), ServiceOperationGroupClientDiagnostics, Pipeline, "MockableDataBoxResourceGroupResource.GetAvailableSkus", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new ServiceOperationGroupGetAvailableSkusAsyncCollectionResultOfT( + ServiceOperationGroupRestClient, + Id.SubscriptionId, + Id.ResourceGroupName, + location, + AvailableSkusContent.ToRequestContent(content), + context); } - /// - /// This method provides the list of available skus for the given subscription, resource group and location. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/availableSkus - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetAvailableSkus - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This method provides the list of available skus for the given subscription, resource group and location. /// The name of the Azure region. /// Filters for showing the available skus. /// The cancellation token to use. @@ -170,28 +140,20 @@ public virtual Pageable GetAvailableSkus(AzureLocation lo { Argument.AssertNotNull(content, nameof(content)); - HttpMessage FirstPageRequest(int? pageSizeHint) => ServiceOperationGroupRestClient.CreateGetAvailableSkusRequest(Id.SubscriptionId, Id.ResourceGroupName, location, content); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ServiceOperationGroupRestClient.CreateGetAvailableSkusNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, location, content); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DataBoxSkuInformation.DeserializeDataBoxSkuInformation(e), ServiceOperationGroupClientDiagnostics, Pipeline, "MockableDataBoxResourceGroupResource.GetAvailableSkus", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new ServiceOperationGroupGetAvailableSkusCollectionResultOfT( + ServiceOperationGroupRestClient, + Id.SubscriptionId, + Id.ResourceGroupName, + location, + AvailableSkusContent.ToRequestContent(content), + context); } - /// - /// This API provides configuration details specific to given region/location at Resource group level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This API provides configuration details specific to given region/location at Resource group level. /// The name of the Azure region. /// Request body to get the configuration for the region at resource group level. /// The cancellation token to use. @@ -200,11 +162,21 @@ public virtual async Task> GetRegionConfigur { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.GetRegionConfiguration"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.GetRegionConfiguration"); scope.Start(); try { - var response = await ServiceOperationGroupRestClient.GetRegionConfigurationAsync(Id.SubscriptionId, Id.ResourceGroupName, location, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateGetRegionConfigurationRequest(Id.SubscriptionId, Id.ResourceGroupName, location, RegionConfigurationContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RegionConfigurationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -214,23 +186,7 @@ public virtual async Task> GetRegionConfigur } } - /// - /// This API provides configuration details specific to given region/location at Resource group level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This API provides configuration details specific to given region/location at Resource group level. /// The name of the Azure region. /// Request body to get the configuration for the region at resource group level. /// The cancellation token to use. @@ -239,11 +195,21 @@ public virtual Response GetRegionConfiguration(AzureL { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.GetRegionConfiguration"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.GetRegionConfiguration"); scope.Start(); try { - var response = ServiceOperationGroupRestClient.GetRegionConfiguration(Id.SubscriptionId, Id.ResourceGroupName, location, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateGetRegionConfigurationRequest(Id.SubscriptionId, Id.ResourceGroupName, location, RegionConfigurationContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RegionConfigurationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -253,23 +219,7 @@ public virtual Response GetRegionConfiguration(AzureL } } - /// - /// This method does all necessary pre-job creation validation under resource group. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This method does all necessary pre-job creation validation under resource group. /// The name of the Azure region. /// Inputs of the customer. /// The cancellation token to use. @@ -278,11 +228,21 @@ public virtual async Task> ValidateInputsAsync { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.ValidateInputs"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.ValidateInputs"); scope.Start(); try { - var response = await ServiceOperationGroupRestClient.ValidateInputsAsync(Id.SubscriptionId, Id.ResourceGroupName, location, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateValidateInputsRequest(Id.SubscriptionId, Id.ResourceGroupName, location, DataBoxValidationContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxValidationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -292,23 +252,7 @@ public virtual async Task> ValidateInputsAsync } } - /// - /// This method does all necessary pre-job creation validation under resource group. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This method does all necessary pre-job creation validation under resource group. /// The name of the Azure region. /// Inputs of the customer. /// The cancellation token to use. @@ -317,11 +261,21 @@ public virtual Response ValidateInputs(AzureLocation lo { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.ValidateInputs"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxResourceGroupResource.ValidateInputs"); scope.Start(); try { - var response = ServiceOperationGroupRestClient.ValidateInputs(Id.SubscriptionId, Id.ResourceGroupName, location, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateValidateInputsRequest(Id.SubscriptionId, Id.ResourceGroupName, location, DataBoxValidationContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxValidationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxSubscriptionResource.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxSubscriptionResource.cs index 5b27ccc86301..7521e0376a47 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxSubscriptionResource.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Extensions/MockableDataBoxSubscriptionResource.cs @@ -8,123 +8,103 @@ 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.DataBox; using Azure.ResourceManager.DataBox.Models; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DataBox.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableDataBoxSubscriptionResource : ArmResource { - private ClientDiagnostics _dataBoxJobJobResourcesClientDiagnostics; - private JobResourcesRestOperations _dataBoxJobJobResourcesRestClient; + private ClientDiagnostics _jobResourcesClientDiagnostics; + private JobResources _jobResourcesRestClient; private ClientDiagnostics _serviceOperationGroupClientDiagnostics; - private ServiceOperationGroupRestOperations _serviceOperationGroupRestClient; + private ServiceOperationGroup _serviceOperationGroupRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDataBoxSubscriptionResource for mocking. protected MockableDataBoxSubscriptionResource() { } - /// 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 MockableDataBoxSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics DataBoxJobJobResourcesClientDiagnostics => _dataBoxJobJobResourcesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DataBox", DataBoxJobResource.ResourceType.Namespace, Diagnostics); - private JobResourcesRestOperations DataBoxJobJobResourcesRestClient => _dataBoxJobJobResourcesRestClient ??= new JobResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(DataBoxJobResource.ResourceType)); - private ClientDiagnostics ServiceOperationGroupClientDiagnostics => _serviceOperationGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DataBox", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private ServiceOperationGroupRestOperations ServiceOperationGroupRestClient => _serviceOperationGroupRestClient ??= new ServiceOperationGroupRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics JobResourcesClientDiagnostics => _jobResourcesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DataBox.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private JobResources JobResourcesRestClient => _jobResourcesRestClient ??= new JobResources(JobResourcesClientDiagnostics, Pipeline, Endpoint, "2025-07-01"); + + private ClientDiagnostics ServiceOperationGroupClientDiagnostics => _serviceOperationGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DataBox.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private ServiceOperationGroup ServiceOperationGroupRestClient => _serviceOperationGroupRestClient ??= new ServiceOperationGroup(ServiceOperationGroupClientDiagnostics, Pipeline, Endpoint, "2025-07-01"); /// /// Lists all the jobs available under the subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/jobs + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/jobs. /// /// - /// Operation Id - /// JobResource_List + /// Operation Id. + /// JobResources_List. /// /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetDataBoxJobsAsync(string skipToken = null, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetDataBoxJobsAsync(string skipToken = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DataBoxJobJobResourcesRestClient.CreateListRequest(Id.SubscriptionId, skipToken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DataBoxJobJobResourcesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, skipToken); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DataBoxJobResource(Client, DataBoxJobData.DeserializeDataBoxJobData(e)), DataBoxJobJobResourcesClientDiagnostics, Pipeline, "MockableDataBoxSubscriptionResource.GetDataBoxJobs", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new JobResourcesGetAllAsyncCollectionResultOfT(JobResourcesRestClient, Id.SubscriptionId, skipToken, context), data => new DataBoxJobResource(Client, data)); } /// /// Lists all the jobs available under the subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/jobs - /// - /// - /// Operation Id - /// JobResource_List + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/jobs. /// /// - /// Default Api Version - /// 2025-07-01 + /// Operation Id. + /// JobResources_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-07-01. /// /// /// /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetDataBoxJobs(string skipToken = null, CancellationToken cancellationToken = default) + public virtual Pageable GetDataBoxJobs(string skipToken = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DataBoxJobJobResourcesRestClient.CreateListRequest(Id.SubscriptionId, skipToken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DataBoxJobJobResourcesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, skipToken); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DataBoxJobResource(Client, DataBoxJobData.DeserializeDataBoxJobData(e)), DataBoxJobJobResourcesClientDiagnostics, Pipeline, "MockableDataBoxSubscriptionResource.GetDataBoxJobs", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new JobResourcesGetAllCollectionResultOfT(JobResourcesRestClient, Id.SubscriptionId, skipToken, context), data => new DataBoxJobResource(Client, data)); } - /// - /// This API provides configuration details specific to given region/location at Subscription level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This API provides configuration details specific to given region/location at Subscription level. /// The name of the Azure region. /// The request body. /// The cancellation token to use. @@ -133,11 +113,21 @@ public virtual async Task> GetRegionConfigur { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.GetRegionConfiguration"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.GetRegionConfiguration"); scope.Start(); try { - var response = await ServiceOperationGroupRestClient.GetRegionConfigurationAsync(Id.SubscriptionId, location, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateGetRegionConfigurationRequest(Id.SubscriptionId, location, RegionConfigurationContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RegionConfigurationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -147,23 +137,7 @@ public virtual async Task> GetRegionConfigur } } - /// - /// This API provides configuration details specific to given region/location at Subscription level. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/regionConfiguration - /// - /// - /// Operation Id - /// ServiceOperationGroup_GetRegionConfiguration - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This API provides configuration details specific to given region/location at Subscription level. /// The name of the Azure region. /// The request body. /// The cancellation token to use. @@ -172,11 +146,21 @@ public virtual Response GetRegionConfiguration(AzureL { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.GetRegionConfiguration"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.GetRegionConfiguration"); scope.Start(); try { - var response = ServiceOperationGroupRestClient.GetRegionConfiguration(Id.SubscriptionId, location, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateGetRegionConfigurationRequest(Id.SubscriptionId, location, RegionConfigurationContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RegionConfigurationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -186,23 +170,7 @@ public virtual Response GetRegionConfiguration(AzureL } } - /// - /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateAddress - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateAddress - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. /// The name of the Azure region. /// The request body. /// The cancellation token to use. @@ -211,11 +179,21 @@ public virtual async Task> ValidateAddressAsyn { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateAddress"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateAddress"); scope.Start(); try { - var response = await ServiceOperationGroupRestClient.ValidateAddressAsync(Id.SubscriptionId, location, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateValidateAddressRequest(Id.SubscriptionId, location, DataBoxValidateAddressContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AddressValidationOutput.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -225,23 +203,7 @@ public virtual async Task> ValidateAddressAsyn } } - /// - /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateAddress - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateAddress - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. /// The name of the Azure region. /// The request body. /// The cancellation token to use. @@ -250,11 +212,21 @@ public virtual Response ValidateAddress(AzureLocation l { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateAddress"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateAddress"); scope.Start(); try { - var response = ServiceOperationGroupRestClient.ValidateAddress(Id.SubscriptionId, location, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateValidateAddressRequest(Id.SubscriptionId, location, DataBoxValidateAddressContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AddressValidationOutput.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -264,23 +236,7 @@ public virtual Response ValidateAddress(AzureLocation l } } - /// - /// This method does all necessary pre-job creation validation under subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This method does all necessary pre-job creation validation under subscription. /// The name of the Azure region. /// The request body. /// The cancellation token to use. @@ -289,11 +245,21 @@ public virtual async Task> ValidateInputsAsync { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateInputs"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateInputs"); scope.Start(); try { - var response = await ServiceOperationGroupRestClient.ValidateInputsAsync(Id.SubscriptionId, location, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateValidateInputsRequest(Id.SubscriptionId, location, DataBoxValidationContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DataBoxValidationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -303,23 +269,7 @@ public virtual async Task> ValidateInputsAsync } } - /// - /// This method does all necessary pre-job creation validation under subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DataBox/locations/{location}/validateInputs - /// - /// - /// Operation Id - /// ServiceOperationGroup_ValidateInputs - /// - /// - /// Default Api Version - /// 2025-07-01 - /// - /// - /// + /// This method does all necessary pre-job creation validation under subscription. /// The name of the Azure region. /// The request body. /// The cancellation token to use. @@ -328,11 +278,21 @@ public virtual Response ValidateInputs(AzureLocation lo { Argument.AssertNotNull(content, nameof(content)); - using var scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateInputs"); + using DiagnosticScope scope = ServiceOperationGroupClientDiagnostics.CreateScope("MockableDataBoxSubscriptionResource.ValidateInputs"); scope.Start(); try { - var response = ServiceOperationGroupRestClient.ValidateInputs(Id.SubscriptionId, location, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ServiceOperationGroupRestClient.CreateValidateInputsRequest(Id.SubscriptionId, location, DataBoxValidationContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DataBoxValidationResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Argument.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Argument.cs index 6cbc2b5e2d7c..c0251c0113b4 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Argument.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.DataBox { - 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..4722cba3e74a --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingDictionary.cs index 880fd585e4d2..d4cd827acd00 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.DataBox { - 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingList.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingList.cs index 52e1475d219e..70f775396114 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.DataBox { - 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..7a25e11ec827 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..34a45be7f60f --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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 Azure.ResourceManager.DataBox +{ + [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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..4f09b1e287d6 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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 Azure.ResourceManager.DataBox +{ + [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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..f85b21bac9c0 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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 Azure.ResourceManager.DataBox +{ + [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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..46ae386a0396 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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 Azure.ResourceManager.DataBox +{ + [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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ErrorResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..e0d07b7f602d --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ModelSerializationExtensions.cs index 4c5f5c8d2c9a..96f01bff48fa 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox { - 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Optional.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Optional.cs index 0863ec50b745..c7910925d5ec 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Optional.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.DataBox { - 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/PageableWrapper.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..ad034692e252 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..57295d5957bd --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/RequestContextExtensions.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..edbe78f9f781 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/SerializationFormat.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..36c895225747 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/TypeFormatters.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..ef465ea08b83 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/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.DataBox +{ + 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/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Utf8JsonRequestContent.cs index 23ff4138bc73..5f626bb1f997 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.DataBox { - 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/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperation.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperation.cs index 647bd53cd2d2..051c15a26209 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperation.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperation.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.DataBox { -#pragma warning disable SA1649 // File name should match first type name - internal class DataBoxArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class DataBoxArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected DataBoxArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal DataBoxArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response); @@ -36,12 +37,20 @@ internal DataBoxArmOperation(Response response, RehydrationToken? rehydrationTok _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 DataBoxArmOperation(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 DataBoxArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline p _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "DataBoxArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "DataBoxArmOperation", + 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, AzureResourceManagerDataBoxContext.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/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperationOfT.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperationOfT.cs index 148260d9e12c..ad1a21c50cf8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperationOfT.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxArmOperationOfT.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.DataBox { -#pragma warning disable SA1649 // File name should match first type name - internal class DataBoxArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class DataBoxArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected DataBoxArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal DataBoxArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal DataBoxArmOperation(Response response, RehydrationToken? rehydration _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 DataBoxArmOperation(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 DataBoxArmOperation(IOperationSource source, ClientDiagnostics clien _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "DataBoxArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "DataBoxArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerDataBoxContext.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/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxJobOperationSource.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxJobOperationSource.cs index e1f1eb338c98..c5ee380208f7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxJobOperationSource.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/LongRunningOperation/DataBoxJobOperationSource.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.DataBox { - internal class DataBoxJobOperationSource : IOperationSource + /// + internal partial class DataBoxJobOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal DataBoxJobOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// DataBoxJobResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDataBoxContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + DataBoxJobData data = DataBoxJobData.DeserializeDataBoxJobData(document.RootElement, ModelSerializationExtensions.WireOptions); return new DataBoxJobResource(_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, AzureResourceManagerDataBoxContext.Default); - return await Task.FromResult(new DataBoxJobResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + DataBoxJobData data = DataBoxJobData.DeserializeDataBoxJobData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new DataBoxJobResource(_client, data); } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.Serialization.cs index a4dbde4b07a0..74cefdca242e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.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.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class AddressValidationOutput : IUtf8JsonSerializable, IJsonModel + /// Output of the address validation api. + public partial class AddressValidationOutput : 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, ModelReade /// 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(AddressValidationOutput)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, 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); } @@ -56,53 +57,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AddressValidationOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AddressValidationOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AddressValidationOutput 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(AddressValidationOutput)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAddressValidationOutput(document.RootElement, options); } - internal static AddressValidationOutput DeserializeAddressValidationOutput(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AddressValidationOutput DeserializeAddressValidationOutput(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } AddressValidationResult properties = 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("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = AddressValidationResult.DeserializeAddressValidationResult(property.Value, options); + properties = AddressValidationResult.DeserializeAddressValidationResult(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 AddressValidationOutput(properties, serializedAdditionalRawData); + return new AddressValidationOutput(properties, 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 +119,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - AddressValidationOutput 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. + AddressValidationOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AddressValidationOutput 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 DeserializeAddressValidationOutput(document.RootElement, options); } default: @@ -128,6 +140,14 @@ AddressValidationOutput IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AddressValidationOutput FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAddressValidationOutput(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.cs index 465c5cf431a9..7a6e96f4e49d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationOutput.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Output of the address validation api. public partial class AddressValidationOutput { - /// - /// 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 AddressValidationOutput() @@ -52,11 +23,11 @@ internal AddressValidationOutput() /// Initializes a new instance of . /// The address validation properties. - /// Keeps track of any properties unknown to the library. - internal AddressValidationOutput(AddressValidationResult properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AddressValidationOutput(AddressValidationResult properties, IDictionary additionalBinaryDataProperties) { Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The address validation properties. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.Serialization.cs index 9b28e243469e..e563241b5147 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class AddressValidationResult : IUtf8JsonSerializable, IJsonModel + /// The address validation output. + public partial class AddressValidationResult : DataBoxValidationInputResult, 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(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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(AddressValidationResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(ValidationStatus)) { @@ -45,7 +46,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("alternateAddresses"u8); writer.WriteStartArray(); - foreach (var item in AlternateAddresses) + foreach (DataBoxShippingAddress item in AlternateAddresses) { writer.WriteObjectValue(item, options); } @@ -53,84 +54,90 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - AddressValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AddressValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AddressValidationResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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(AddressValidationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAddressValidationResult(document.RootElement, options); } - internal static AddressValidationResult DeserializeAddressValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AddressValidationResult DeserializeAddressValidationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - AddressValidationStatus? validationStatus = default; - IReadOnlyList alternateAddresses = default; DataBoxValidationInputDiscriminator validationType = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + AddressValidationStatus? validationStatus = default; + IReadOnlyList alternateAddresses = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("validationStatus"u8)) + if (prop.NameEquals("validationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - validationStatus = property.Value.GetString().ToAddressValidationStatus(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("alternateAddresses"u8)) + if (prop.NameEquals("error"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()) - { - array.Add(DataBoxShippingAddress.DeserializeDataBoxShippingAddress(item, options)); - } - alternateAddresses = array; + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("validationStatus"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + validationStatus = prop.Value.GetString().ToAddressValidationStatus(); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("alternateAddresses"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxShippingAddress.DeserializeDataBoxShippingAddress(item, options)); + } + alternateAddresses = 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 AddressValidationResult(validationType, error, serializedAdditionalRawData, validationStatus, alternateAddresses ?? new ChangeTrackingList()); + return new AddressValidationResult(validationType, error, additionalBinaryDataProperties, validationStatus, alternateAddresses ?? new ChangeTrackingList()); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -140,15 +147,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - AddressValidationResult 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. + AddressValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AddressValidationResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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 DeserializeAddressValidationResult(document.RootElement, options); } default: @@ -156,6 +168,7 @@ AddressValidationResult IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.cs index 673c29e9e3b9..10fe502b9b5a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationResult.cs @@ -7,6 +7,8 @@ using System; using System.Collections.Generic; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,27 +16,26 @@ namespace Azure.ResourceManager.DataBox.Models public partial class AddressValidationResult : DataBoxValidationInputResult { /// Initializes a new instance of . - internal AddressValidationResult() + internal AddressValidationResult() : base(DataBoxValidationInputDiscriminator.ValidateAddress) { AlternateAddresses = new ChangeTrackingList(); - ValidationType = DataBoxValidationInputDiscriminator.ValidateAddress; } /// Initializes a new instance of . /// Identifies the type of validation response. /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The address validation status. /// List of alternate addresses. - internal AddressValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData, AddressValidationStatus? validationStatus, IReadOnlyList alternateAddresses) : base(validationType, error, serializedAdditionalRawData) + internal AddressValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties, AddressValidationStatus? validationStatus, IReadOnlyList alternateAddresses) : base(validationType, error, additionalBinaryDataProperties) { ValidationStatus = validationStatus; AlternateAddresses = alternateAddresses; - ValidationType = validationType; } /// The address validation status. public AddressValidationStatus? ValidationStatus { get; } + /// List of alternate addresses. public IReadOnlyList AlternateAddresses { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationStatus.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationStatus.Serialization.cs index d644b61fe2be..357b8e5d7d65 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationStatus.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AddressValidationStatus.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class AddressValidationStatusExtensions { + /// The value to serialize. public static string ToSerialString(this AddressValidationStatus value) => value switch { AddressValidationStatus.Valid => "Valid", @@ -19,11 +20,21 @@ internal static partial class AddressValidationStatusExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AddressValidationStatus value.") }; + /// The value to deserialize. public static AddressValidationStatus ToAddressValidationStatus(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Valid")) return AddressValidationStatus.Valid; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Invalid")) return AddressValidationStatus.Invalid; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Ambiguous")) return AddressValidationStatus.Ambiguous; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Valid")) + { + return AddressValidationStatus.Valid; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Invalid")) + { + return AddressValidationStatus.Invalid; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Ambiguous")) + { + return AddressValidationStatus.Ambiguous; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AddressValidationStatus value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.Serialization.cs index dc537bd6af98..ca0f0ff99c04 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ApplianceNetworkConfiguration : IUtf8JsonSerializable, IJsonModel + /// The Network Adapter configuration of a DataBox. + public partial class ApplianceNetworkConfiguration : 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, 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(ApplianceNetworkConfiguration)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("macAddress"u8); writer.WriteStringValue(MacAddress); } - 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,55 +61,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ApplianceNetworkConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ApplianceNetworkConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ApplianceNetworkConfiguration 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(ApplianceNetworkConfiguration)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeApplianceNetworkConfiguration(document.RootElement, options); } - internal static ApplianceNetworkConfiguration DeserializeApplianceNetworkConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ApplianceNetworkConfiguration DeserializeApplianceNetworkConfiguration(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; string macAddress = 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 (property.NameEquals("macAddress"u8)) + if (prop.NameEquals("macAddress"u8)) { - macAddress = property.Value.GetString(); + macAddress = 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 ApplianceNetworkConfiguration(name, macAddress, serializedAdditionalRawData); + return new ApplianceNetworkConfiguration(name, macAddress, 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": @@ -119,15 +125,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - ApplianceNetworkConfiguration 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. + ApplianceNetworkConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ApplianceNetworkConfiguration 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 DeserializeApplianceNetworkConfiguration(document.RootElement, options); } default: @@ -135,6 +146,7 @@ ApplianceNetworkConfiguration IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.cs index ae4362705067..90dc590c47c5 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ApplianceNetworkConfiguration.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// The Network Adapter configuration of a DataBox. public partial class ApplianceNetworkConfiguration { - /// - /// 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 ApplianceNetworkConfiguration() @@ -53,16 +24,17 @@ internal ApplianceNetworkConfiguration() /// Initializes a new instance of . /// Name of the network. /// Mac Address. - /// Keeps track of any properties unknown to the library. - internal ApplianceNetworkConfiguration(string name, string macAddress, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ApplianceNetworkConfiguration(string name, string macAddress, IDictionary additionalBinaryDataProperties) { Name = name; MacAddress = macAddress; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the network. public string Name { get; } + /// Mac Address. public string MacAddress { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.Serialization.cs index 793dbd7ead2e..0488799efdff 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class AvailableSkusContent : IUtf8JsonSerializable, IJsonModel + /// The filters for showing the available skus. + public partial class AvailableSkusContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal AvailableSkusContent() + { + } + /// 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, 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(AvailableSkusContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("transferType"u8); writer.WriteStringValue(TransferType.ToSerialString()); writer.WritePropertyName("country"u8); @@ -44,21 +50,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("skuNames"u8); writer.WriteStartArray(); - foreach (var item in SkuNames) + foreach (DataBoxSkuName item in SkuNames) { writer.WriteStringValue(item.ToSerialString()); } 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); } @@ -67,22 +73,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AvailableSkusContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AvailableSkusContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AvailableSkusContent 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(AvailableSkusContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAvailableSkusContent(document.RootElement, options); } - internal static AvailableSkusContent DeserializeAvailableSkusContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableSkusContent DeserializeAvailableSkusContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -91,33 +102,32 @@ internal static AvailableSkusContent DeserializeAvailableSkusContent(JsonElement string country = default; AzureLocation location = default; IList skuNames = 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("transferType"u8)) + if (prop.NameEquals("transferType"u8)) { - transferType = property.Value.GetString().ToDataBoxJobTransferType(); + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("country"u8)) { - country = property.Value.GetString(); + country = 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 (property.NameEquals("skuNames"u8)) + if (prop.NameEquals("skuNames"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().ToDataBoxSkuName()); } @@ -126,17 +136,19 @@ internal static AvailableSkusContent DeserializeAvailableSkusContent(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 AvailableSkusContent(transferType, country, location, skuNames ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new AvailableSkusContent(transferType, country, location, skuNames ?? 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": @@ -146,15 +158,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - AvailableSkusContent 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. + AvailableSkusContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AvailableSkusContent 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 DeserializeAvailableSkusContent(document.RootElement, options); } default: @@ -162,6 +179,19 @@ AvailableSkusContent IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(AvailableSkusContent availableSkusContent) + { + if (availableSkusContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(availableSkusContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.cs index 8fbf020d588a..35148d2b2f9f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusContent.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// The filters for showing the available skus. public partial class AvailableSkusContent { - /// - /// 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 . /// Type of the transfer. @@ -66,27 +38,25 @@ public AvailableSkusContent(DataBoxJobTransferType transferType, string country, /// ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Sku Names to filter for available skus. - /// Keeps track of any properties unknown to the library. - internal AvailableSkusContent(DataBoxJobTransferType transferType, string country, AzureLocation location, IList skuNames, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AvailableSkusContent(DataBoxJobTransferType transferType, string country, AzureLocation location, IList skuNames, IDictionary additionalBinaryDataProperties) { TransferType = transferType; Country = country; Location = location; SkuNames = skuNames; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AvailableSkusContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of the transfer. public DataBoxJobTransferType TransferType { get; } + /// ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements. public string Country { get; } + /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. public AzureLocation Location { get; } + /// Sku Names to filter for available skus. public IList SkuNames { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.Serialization.cs index d72bc01e4118..c64a114ecd27 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.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.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class AvailableSkusResult : IUtf8JsonSerializable, IJsonModel + /// The available skus operation response. + internal partial class AvailableSkusResult : 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,17 +30,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// 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(AvailableSkusResult)} does not support writing '{format}' format."); } - if (options.Format != "W") { writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DataBoxSkuInformation item in Value) { writer.WriteObjectValue(item, options); } @@ -49,15 +50,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink); } - 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,60 +67,66 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AvailableSkusResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AvailableSkusResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AvailableSkusResult 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(AvailableSkusResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAvailableSkusResult(document.RootElement, options); } - internal static AvailableSkusResult DeserializeAvailableSkusResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableSkusResult DeserializeAvailableSkusResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList value = default; string 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(DataBoxSkuInformation.DeserializeDataBoxSkuInformation(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - nextLink = property.Value.GetString(); + nextLink = 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 AvailableSkusResult(value, nextLink, serializedAdditionalRawData); + return new AvailableSkusResult(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": @@ -129,15 +136,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - AvailableSkusResult 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. + AvailableSkusResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AvailableSkusResult 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 DeserializeAvailableSkusResult(document.RootElement, options); } default: @@ -145,6 +157,14 @@ AvailableSkusResult IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AvailableSkusResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAvailableSkusResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.cs index 03e62fa0a04a..7db97f3075e3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AvailableSkusResult.cs @@ -7,70 +7,36 @@ using System; using System.Collections.Generic; -using System.Linq; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// The available skus operation response. internal partial class AvailableSkusResult { - /// - /// 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 . - /// [Placeholder] Description for page model. - internal AvailableSkusResult(IEnumerable value) + internal AvailableSkusResult() { - Value = value.ToList(); + Value = new ChangeTrackingList(); } /// Initializes a new instance of . /// [Placeholder] Description for page model. /// [Placeholder] Description for nextLink property. - /// Keeps track of any properties unknown to the library. - internal AvailableSkusResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AvailableSkusResult(IReadOnlyList value, string nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AvailableSkusResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// [Placeholder] Description for page model. public IReadOnlyList Value { get; } + /// [Placeholder] Description for nextLink property. public string NextLink { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.Serialization.cs index 4ade6ced4d74..52d361099aad 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class AzureFileFilterDetails : IUtf8JsonSerializable, IJsonModel + /// Filter details to transfer Azure files. + public partial class AzureFileFilterDetails : 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,18 +29,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(AzureFileFilterDetails)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(FilePrefixList)) { writer.WritePropertyName("filePrefixList"u8); writer.WriteStartArray(); - foreach (var item in FilePrefixList) + foreach (string item in FilePrefixList) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -48,8 +53,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("filePathList"u8); writer.WriteStartArray(); - foreach (var item in FilePathList) + foreach (string item in FilePathList) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -58,21 +68,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("fileShareList"u8); writer.WriteStartArray(); - foreach (var item in FileShareList) + foreach (string item in FileShareList) { + 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); } @@ -81,22 +96,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AzureFileFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AzureFileFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFileFilterDetails 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(AzureFileFilterDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAzureFileFilterDetails(document.RootElement, options); } - internal static AzureFileFilterDetails DeserializeAzureFileFilterDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFileFilterDetails DeserializeAzureFileFilterDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -104,65 +124,87 @@ internal static AzureFileFilterDetails DeserializeAzureFileFilterDetails(JsonEle IList filePrefixList = default; IList filePathList = default; IList fileShareList = 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("filePrefixList"u8)) + if (prop.NameEquals("filePrefixList"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()); + } } filePrefixList = array; continue; } - if (property.NameEquals("filePathList"u8)) + if (prop.NameEquals("filePathList"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()); + } } filePathList = array; continue; } - if (property.NameEquals("fileShareList"u8)) + if (prop.NameEquals("fileShareList"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()); + } } fileShareList = 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 AzureFileFilterDetails(filePrefixList ?? new ChangeTrackingList(), filePathList ?? new ChangeTrackingList(), fileShareList ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new AzureFileFilterDetails(filePrefixList ?? new ChangeTrackingList(), filePathList ?? new ChangeTrackingList(), fileShareList ?? 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": @@ -172,15 +214,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - AzureFileFilterDetails 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. + AzureFileFilterDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFileFilterDetails 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 DeserializeAzureFileFilterDetails(document.RootElement, options); } default: @@ -188,6 +235,7 @@ AzureFileFilterDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.cs index 1ac59b88451a..3654b26c4dad 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureFileFilterDetails.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Filter details to transfer Azure files. public partial class AzureFileFilterDetails { - /// - /// 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 AzureFileFilterDetails() @@ -57,19 +29,21 @@ public AzureFileFilterDetails() /// Prefix list of the Azure files to be transferred. /// List of full path of the files to be transferred. /// List of file shares to be transferred. - /// Keeps track of any properties unknown to the library. - internal AzureFileFilterDetails(IList filePrefixList, IList filePathList, IList fileShareList, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AzureFileFilterDetails(IList filePrefixList, IList filePathList, IList fileShareList, IDictionary additionalBinaryDataProperties) { FilePrefixList = filePrefixList; FilePathList = filePathList; FileShareList = fileShareList; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Prefix list of the Azure files to be transferred. public IList FilePrefixList { get; } + /// List of full path of the files to be transferred. public IList FilePathList { get; } + /// List of file shares to be transferred. public IList FileShareList { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureResourceManagerDataBoxContext.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureResourceManagerDataBoxContext.cs index d7cea45ce7e4..fa5182629d2b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureResourceManagerDataBoxContext.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/AzureResourceManagerDataBoxContext.cs @@ -6,6 +6,7 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.DataBox.Models; using Azure.ResourceManager.Models; @@ -13,7 +14,7 @@ namespace Azure.ResourceManager.DataBox { /// /// 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(AddressValidationOutput))] [ModelReaderWriterBuildable(typeof(AddressValidationResult))] @@ -98,10 +99,10 @@ namespace Azure.ResourceManager.DataBox [ModelReaderWriterBuildable(typeof(ImportDiskDetails))] [ModelReaderWriterBuildable(typeof(JobDelayDetails))] [ModelReaderWriterBuildable(typeof(JobDeliveryInfo))] + [ModelReaderWriterBuildable(typeof(JobProperties))] [ModelReaderWriterBuildable(typeof(JobSecrets))] [ModelReaderWriterBuildable(typeof(LastMitigationActionOnJob))] [ModelReaderWriterBuildable(typeof(ManagedDiskDetails))] - [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] [ModelReaderWriterBuildable(typeof(MarkDevicesShippedContent))] [ModelReaderWriterBuildable(typeof(MitigateJobContent))] [ModelReaderWriterBuildable(typeof(NotificationPreference))] @@ -112,6 +113,7 @@ namespace Azure.ResourceManager.DataBox [ModelReaderWriterBuildable(typeof(PreferencesValidationResult))] [ModelReaderWriterBuildable(typeof(RegionConfigurationContent))] [ModelReaderWriterBuildable(typeof(RegionConfigurationResult))] + [ModelReaderWriterBuildable(typeof(ResourceIdentity))] [ModelReaderWriterBuildable(typeof(ResponseError))] [ModelReaderWriterBuildable(typeof(ReverseShippingDetails))] [ModelReaderWriterBuildable(typeof(ScheduleAvailabilityContent))] @@ -120,6 +122,7 @@ namespace Azure.ResourceManager.DataBox [ModelReaderWriterBuildable(typeof(ShipmentPickUpContent))] [ModelReaderWriterBuildable(typeof(SkuAvailabilityValidationContent))] [ModelReaderWriterBuildable(typeof(SkuAvailabilityValidationResult))] + [ModelReaderWriterBuildable(typeof(SkuProperties))] [ModelReaderWriterBuildable(typeof(SubscriptionIsAllowedToCreateJobValidationContent))] [ModelReaderWriterBuildable(typeof(SubscriptionIsAllowedToCreateJobValidationResult))] [ModelReaderWriterBuildable(typeof(SystemData))] @@ -136,16 +139,18 @@ namespace Azure.ResourceManager.DataBox [ModelReaderWriterBuildable(typeof(UnencryptedCredentialsList))] [ModelReaderWriterBuildable(typeof(UnknownCopyLogDetails))] [ModelReaderWriterBuildable(typeof(UnknownDataAccountDetails))] - [ModelReaderWriterBuildable(typeof(UnknownDataCenterAddressResponse))] + [ModelReaderWriterBuildable(typeof(UnknownDataBoxBasicJobDetails))] + [ModelReaderWriterBuildable(typeof(UnknownDataBoxValidationContent))] + [ModelReaderWriterBuildable(typeof(UnknownDataBoxValidationInputContent))] + [ModelReaderWriterBuildable(typeof(UnknownDataBoxValidationInputResult))] + [ModelReaderWriterBuildable(typeof(UnknownDataCenterAddressResult))] [ModelReaderWriterBuildable(typeof(UnknownGranularCopyLogDetails))] - [ModelReaderWriterBuildable(typeof(UnknownJobDetails))] [ModelReaderWriterBuildable(typeof(UnknownJobSecrets))] - [ModelReaderWriterBuildable(typeof(UnknownScheduleAvailabilityRequest))] - [ModelReaderWriterBuildable(typeof(UnknownValidationInputRequest))] - [ModelReaderWriterBuildable(typeof(UnknownValidationInputResponse))] - [ModelReaderWriterBuildable(typeof(UnknownValidationRequest))] + [ModelReaderWriterBuildable(typeof(UnknownScheduleAvailabilityContent))] [ModelReaderWriterBuildable(typeof(UpdateJobDetails))] + [ModelReaderWriterBuildable(typeof(UpdateJobProperties))] [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] + [ModelReaderWriterBuildable(typeof(ValidationResponseProperties))] public partial class AzureResourceManagerDataBoxContext : ModelReaderWriterContext { } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.Serialization.cs index b8aafb9daed0..34dfd7da8ae3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class BlobFilterDetails : IUtf8JsonSerializable, IJsonModel + /// Filter details to transfer Azure Blobs. + public partial class BlobFilterDetails : 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,18 +29,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(BlobFilterDetails)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(BlobPrefixList)) { writer.WritePropertyName("blobPrefixList"u8); writer.WriteStartArray(); - foreach (var item in BlobPrefixList) + foreach (string item in BlobPrefixList) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -48,8 +53,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("blobPathList"u8); writer.WriteStartArray(); - foreach (var item in BlobPathList) + foreach (string item in BlobPathList) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -58,21 +68,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("containerList"u8); writer.WriteStartArray(); - foreach (var item in ContainerList) + foreach (string item in ContainerList) { + 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); } @@ -81,22 +96,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - BlobFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + BlobFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BlobFilterDetails 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(BlobFilterDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeBlobFilterDetails(document.RootElement, options); } - internal static BlobFilterDetails DeserializeBlobFilterDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BlobFilterDetails DeserializeBlobFilterDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -104,65 +124,87 @@ internal static BlobFilterDetails DeserializeBlobFilterDetails(JsonElement eleme IList blobPrefixList = default; IList blobPathList = default; IList containerList = 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("blobPrefixList"u8)) + if (prop.NameEquals("blobPrefixList"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()); + } } blobPrefixList = array; continue; } - if (property.NameEquals("blobPathList"u8)) + if (prop.NameEquals("blobPathList"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()); + } } blobPathList = array; continue; } - if (property.NameEquals("containerList"u8)) + if (prop.NameEquals("containerList"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()); + } } containerList = 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 BlobFilterDetails(blobPrefixList ?? new ChangeTrackingList(), blobPathList ?? new ChangeTrackingList(), containerList ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new BlobFilterDetails(blobPrefixList ?? new ChangeTrackingList(), blobPathList ?? new ChangeTrackingList(), containerList ?? 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": @@ -172,15 +214,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - BlobFilterDetails 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. + BlobFilterDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BlobFilterDetails 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 DeserializeBlobFilterDetails(document.RootElement, options); } default: @@ -188,6 +235,7 @@ BlobFilterDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.cs index 5edba0f4635b..3fc5ce16623b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/BlobFilterDetails.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Filter details to transfer Azure Blobs. public partial class BlobFilterDetails { - /// - /// 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 BlobFilterDetails() @@ -57,19 +29,21 @@ public BlobFilterDetails() /// Prefix list of the Azure blobs to be transferred. /// List of full path of the blobs to be transferred. /// List of blob containers to be transferred. - /// Keeps track of any properties unknown to the library. - internal BlobFilterDetails(IList blobPrefixList, IList blobPathList, IList containerList, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal BlobFilterDetails(IList blobPrefixList, IList blobPathList, IList containerList, IDictionary additionalBinaryDataProperties) { BlobPrefixList = blobPrefixList; BlobPathList = blobPathList; ContainerList = containerList; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Prefix list of the Azure blobs to be transferred. public IList BlobPrefixList { get; } + /// List of full path of the blobs to be transferred. public IList BlobPathList { get; } + /// List of blob containers to be transferred. public IList ContainerList { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.Serialization.cs index 86945e09a03e..2543670e9b92 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ContactInfo : IUtf8JsonSerializable, IJsonModel + /// Contact Info. + public partial class ContactInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ContactInfo() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderWriterOptio /// 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(ContactInfo)} does not support writing '{format}' format."); } - writer.WritePropertyName("contactName"u8); writer.WriteStringValue(ContactName); writer.WritePropertyName("phone"u8); @@ -48,15 +53,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("mobile"u8); writer.WriteStringValue(Mobile); } - 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 +70,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContactInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ContactInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContactInfo 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(ContactInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContactInfo(document.RootElement, options); } - internal static ContactInfo DeserializeContactInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContactInfo DeserializeContactInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,43 +99,44 @@ internal static ContactInfo DeserializeContactInfo(JsonElement element, ModelRea string phone = default; string phoneExtension = default; string mobile = 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("contactName"u8)) + if (prop.NameEquals("contactName"u8)) { - contactName = property.Value.GetString(); + contactName = prop.Value.GetString(); continue; } - if (property.NameEquals("phone"u8)) + if (prop.NameEquals("phone"u8)) { - phone = property.Value.GetString(); + phone = prop.Value.GetString(); continue; } - if (property.NameEquals("phoneExtension"u8)) + if (prop.NameEquals("phoneExtension"u8)) { - phoneExtension = property.Value.GetString(); + phoneExtension = prop.Value.GetString(); continue; } - if (property.NameEquals("mobile"u8)) + if (prop.NameEquals("mobile"u8)) { - mobile = property.Value.GetString(); + mobile = 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 ContactInfo(contactName, phone, phoneExtension, mobile, serializedAdditionalRawData); + return new ContactInfo(contactName, phone, phoneExtension, mobile, 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 +146,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options } } - ContactInfo 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. + ContactInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContactInfo 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 DeserializeContactInfo(document.RootElement, options); } default: @@ -151,6 +167,7 @@ ContactInfo IPersistableModel.Create(BinaryData data, ModelReaderWr } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.cs index bc4807d2aed1..2520bf15de36 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ContactInfo.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Contact Info. public partial class ContactInfo { - /// - /// 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 . /// Contact name of the person. @@ -63,27 +35,25 @@ public ContactInfo(string contactName, string phone) /// Phone number of the contact person. /// Phone extension number of the contact person. /// Mobile number of the contact person. - /// Keeps track of any properties unknown to the library. - internal ContactInfo(string contactName, string phone, string phoneExtension, string mobile, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ContactInfo(string contactName, string phone, string phoneExtension, string mobile, IDictionary additionalBinaryDataProperties) { ContactName = contactName; Phone = phone; PhoneExtension = phoneExtension; Mobile = mobile; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ContactInfo() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Contact name of the person. public string ContactName { get; set; } + /// Phone number of the contact person. public string Phone { get; set; } + /// Phone extension number of the contact person. public string PhoneExtension { get; set; } + /// Mobile number of the contact person. public string Mobile { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.Serialization.cs index d31ac16cced2..2ea047528757 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { + /// + /// Details for log generated during copy. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// [PersistableModelProxy(typeof(UnknownCopyLogDetails))] - public partial class CopyLogDetails : IUtf8JsonSerializable, IJsonModel + public abstract partial class CopyLogDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal CopyLogDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,23 +37,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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(CopyLogDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("copyLogDetailsType"u8); writer.WriteStringValue(CopyLogDetailsType.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); } @@ -53,43 +61,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - CopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CopyLogDetails 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(CopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCopyLogDetails(document.RootElement, options); } - internal static CopyLogDetails DeserializeCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CopyLogDetails DeserializeCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("copyLogDetailsType", out JsonElement discriminator)) + if (element.TryGetProperty("copyLogDetailsType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "DataBox": return DataBoxAccountCopyLogDetails.DeserializeDataBoxAccountCopyLogDetails(element, options); - case "DataBoxCustomerDisk": return DataBoxCustomerDiskCopyLogDetails.DeserializeDataBoxCustomerDiskCopyLogDetails(element, options); - case "DataBoxDisk": return DataBoxDiskCopyLogDetails.DeserializeDataBoxDiskCopyLogDetails(element, options); - case "DataBoxHeavy": return DataBoxHeavyAccountCopyLogDetails.DeserializeDataBoxHeavyAccountCopyLogDetails(element, options); + case "DataBox": + return DataBoxAccountCopyLogDetails.DeserializeDataBoxAccountCopyLogDetails(element, options); + case "DataBoxCustomerDisk": + return DataBoxCustomerDiskCopyLogDetails.DeserializeDataBoxCustomerDiskCopyLogDetails(element, options); + case "DataBoxDisk": + return DataBoxDiskCopyLogDetails.DeserializeDataBoxDiskCopyLogDetails(element, options); + case "DataBoxHeavy": + return DataBoxHeavyAccountCopyLogDetails.DeserializeDataBoxHeavyAccountCopyLogDetails(element, options); } } return UnknownCopyLogDetails.DeserializeUnknownCopyLogDetails(element, options); } - 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": @@ -99,15 +119,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - CopyLogDetails 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. + CopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CopyLogDetails 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 DeserializeCopyLogDetails(document.RootElement, options); } default: @@ -115,6 +140,7 @@ CopyLogDetails IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.cs index b2d1054daa88..0748a08ca9be 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CopyLogDetails.cs @@ -12,55 +12,27 @@ namespace Azure.ResourceManager.DataBox.Models { /// /// Details for log generated during copy. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . /// public abstract partial class CopyLogDetails { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected CopyLogDetails() + /// Indicates the type of job details. + private protected CopyLogDetails(DataBoxOrderType copyLogDetailsType) { + CopyLogDetailsType = copyLogDetailsType; } /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. - internal CopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal CopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties) { CopyLogDetailsType = copyLogDetailsType; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Indicates the type of job details. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.Serialization.cs index dd8527cd493c..76f6994c0279 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class CreateJobValidationContent : IUtf8JsonSerializable, IJsonModel + /// It does all pre-job creation validations. + public partial class CreateJobValidationContent : DataBoxValidationContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal CreateJobValidationContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,50 +34,53 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// 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(CreateJobValidationContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - CreateJobValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CreateJobValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CreateJobValidationContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationContent 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(CreateJobValidationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCreateJobValidationContent(document.RootElement, options); } - internal static CreateJobValidationContent DeserializeCreateJobValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CreateJobValidationContent DeserializeCreateJobValidationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string validationCategory = default; + string validationCategory = "JobCreationValidation"; IList individualRequestDetails = 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("validationCategory"u8)) + if (prop.NameEquals("validationCategory"u8)) { - validationCategory = property.Value.GetString(); + validationCategory = prop.Value.GetString(); continue; } - if (property.NameEquals("individualRequestDetails"u8)) + if (prop.NameEquals("individualRequestDetails"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DataBoxValidationInputContent.DeserializeDataBoxValidationInputContent(item, options)); } @@ -80,17 +89,19 @@ internal static CreateJobValidationContent DeserializeCreateJobValidationContent } 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 CreateJobValidationContent(validationCategory, individualRequestDetails, serializedAdditionalRawData); + return new CreateJobValidationContent(validationCategory, individualRequestDetails, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -100,15 +111,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - CreateJobValidationContent 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. + CreateJobValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CreateJobValidationContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationContent 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 DeserializeCreateJobValidationContent(document.RootElement, options); } default: @@ -116,6 +132,7 @@ CreateJobValidationContent IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.cs index 4f6012baef93..f710e201eac3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateJobValidationContent.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,34 +15,19 @@ namespace Azure.ResourceManager.DataBox.Models public partial class CreateJobValidationContent : DataBoxValidationContent { /// Initializes a new instance of . - /// - /// List of request details contain validationType and its request as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// + /// List of request details contain validationType and its request as key and value respectively. /// is null. public CreateJobValidationContent(IEnumerable individualRequestDetails) : base(individualRequestDetails) { Argument.AssertNotNull(individualRequestDetails, nameof(individualRequestDetails)); - ValidationCategory = "JobCreationValidation"; } /// Initializes a new instance of . /// Identify the nature of validation. - /// - /// List of request details contain validationType and its request as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// - /// Keeps track of any properties unknown to the library. - internal CreateJobValidationContent(string validationCategory, IList individualRequestDetails, IDictionary serializedAdditionalRawData) : base(validationCategory, individualRequestDetails, serializedAdditionalRawData) - { - ValidationCategory = validationCategory ?? "JobCreationValidation"; - } - - /// Initializes a new instance of for deserialization. - internal CreateJobValidationContent() + /// List of request details contain validationType and its request as key and value respectively. + /// Keeps track of any properties unknown to the library. + internal CreateJobValidationContent(string validationCategory, IList individualRequestDetails, IDictionary additionalBinaryDataProperties) : base(validationCategory, individualRequestDetails, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.Serialization.cs index 3fbeb5a40580..a8eeb505a5cd 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class CreateOrderLimitForSubscriptionValidationContent : IUtf8JsonSerializable, IJsonModel + /// Request to validate create order limit for current subscription. + public partial class CreateOrderLimitForSubscriptionValidationContent : DataBoxValidationInputContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal CreateOrderLimitForSubscriptionValidationContent() + { + } + /// 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.Write(Utf8Json /// 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(CreateOrderLimitForSubscriptionValidationContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("deviceType"u8); writer.WriteStringValue(DeviceType.ToSerialString()); @@ -44,65 +49,71 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - CreateOrderLimitForSubscriptionValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CreateOrderLimitForSubscriptionValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CreateOrderLimitForSubscriptionValidationContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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(CreateOrderLimitForSubscriptionValidationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCreateOrderLimitForSubscriptionValidationContent(document.RootElement, options); } - internal static CreateOrderLimitForSubscriptionValidationContent DeserializeCreateOrderLimitForSubscriptionValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CreateOrderLimitForSubscriptionValidationContent DeserializeCreateOrderLimitForSubscriptionValidationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxValidationInputDiscriminator validationType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); DataBoxSkuName deviceType = default; DeviceModelName? model = default; - DataBoxValidationInputDiscriminator validationType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("deviceType"u8)) + if (prop.NameEquals("validationType"u8)) { - deviceType = property.Value.GetString().ToDataBoxSkuName(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("deviceType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - model = property.Value.GetString().ToDeviceModelName(); + deviceType = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("model"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = prop.Value.GetString().ToDeviceModelName(); 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 CreateOrderLimitForSubscriptionValidationContent(validationType, serializedAdditionalRawData, deviceType, model); + return new CreateOrderLimitForSubscriptionValidationContent(validationType, additionalBinaryDataProperties, deviceType, model); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -112,15 +123,20 @@ BinaryData IPersistableModel.W } } - CreateOrderLimitForSubscriptionValidationContent 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. + CreateOrderLimitForSubscriptionValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CreateOrderLimitForSubscriptionValidationContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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 DeserializeCreateOrderLimitForSubscriptionValidationContent(document.RootElement, options); } default: @@ -128,6 +144,7 @@ CreateOrderLimitForSubscriptionValidationContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.cs index 1b4ccedd4b8d..6854931824b4 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationContent.cs @@ -15,31 +15,25 @@ public partial class CreateOrderLimitForSubscriptionValidationContent : DataBoxV { /// Initializes a new instance of . /// Device type to be used for the job. - public CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName deviceType) + public CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName deviceType) : base(DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit) { DeviceType = deviceType; - ValidationType = DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit; } /// Initializes a new instance of . /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Device type to be used for the job. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - internal CreateOrderLimitForSubscriptionValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData, DataBoxSkuName deviceType, DeviceModelName? model) : base(validationType, serializedAdditionalRawData) + internal CreateOrderLimitForSubscriptionValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties, DataBoxSkuName deviceType, DeviceModelName? model) : base(validationType, additionalBinaryDataProperties) { DeviceType = deviceType; Model = model; - ValidationType = validationType; - } - - /// Initializes a new instance of for deserialization. - internal CreateOrderLimitForSubscriptionValidationContent() - { } /// Device type to be used for the job. public DataBoxSkuName DeviceType { get; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.Serialization.cs index 67b772f94707..0751b491b27f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class CreateOrderLimitForSubscriptionValidationResult : IUtf8JsonSerializable, IJsonModel + /// Properties of create order limit for subscription validation response. + public partial class CreateOrderLimitForSubscriptionValidationResult : DataBoxValidationInputResult, 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(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8JsonW /// 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(CreateOrderLimitForSubscriptionValidationResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(Status)) { @@ -43,69 +44,75 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - CreateOrderLimitForSubscriptionValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CreateOrderLimitForSubscriptionValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CreateOrderLimitForSubscriptionValidationResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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(CreateOrderLimitForSubscriptionValidationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCreateOrderLimitForSubscriptionValidationResult(document.RootElement, options); } - internal static CreateOrderLimitForSubscriptionValidationResult DeserializeCreateOrderLimitForSubscriptionValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CreateOrderLimitForSubscriptionValidationResult DeserializeCreateOrderLimitForSubscriptionValidationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DataBoxValidationStatus? status = default; DataBoxValidationInputDiscriminator validationType = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DataBoxValidationStatus? status = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("validationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = property.Value.GetString().ToDataBoxValidationStatus(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("error"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + status = prop.Value.GetString().ToDataBoxValidationStatus(); 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 CreateOrderLimitForSubscriptionValidationResult(validationType, error, serializedAdditionalRawData, status); + return new CreateOrderLimitForSubscriptionValidationResult(validationType, error, additionalBinaryDataProperties, status); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +122,20 @@ BinaryData IPersistableModel.Wr } } - CreateOrderLimitForSubscriptionValidationResult 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. + CreateOrderLimitForSubscriptionValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CreateOrderLimitForSubscriptionValidationResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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 DeserializeCreateOrderLimitForSubscriptionValidationResult(document.RootElement, options); } default: @@ -131,6 +143,7 @@ CreateOrderLimitForSubscriptionValidationResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.cs index bcdbcf3298fa..8d2e0784355d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CreateOrderLimitForSubscriptionValidationResult.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { @@ -14,20 +15,18 @@ namespace Azure.ResourceManager.DataBox.Models public partial class CreateOrderLimitForSubscriptionValidationResult : DataBoxValidationInputResult { /// Initializes a new instance of . - internal CreateOrderLimitForSubscriptionValidationResult() + internal CreateOrderLimitForSubscriptionValidationResult() : base(DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit) { - ValidationType = DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit; } /// Initializes a new instance of . /// Identifies the type of validation response. /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Create order limit validation status. - internal CreateOrderLimitForSubscriptionValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData, DataBoxValidationStatus? status) : base(validationType, error, serializedAdditionalRawData) + internal CreateOrderLimitForSubscriptionValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties, DataBoxValidationStatus? status) : base(validationType, error, additionalBinaryDataProperties) { Status = status; - ValidationType = validationType; } /// Create order limit validation status. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.Serialization.cs index 311160817151..1495a256f287 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class CustomerDiskJobSecrets : IUtf8JsonSerializable, IJsonModel + /// The secrets related to customer disk job. + public partial class CustomerDiskJobSecrets : JobSecrets, 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(); @@ -29,18 +31,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(CustomerDiskJobSecrets)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsCollectionDefined(DiskSecrets)) { writer.WritePropertyName("diskSecrets"u8); writer.WriteStartArray(); - foreach (var item in DiskSecrets) + foreach (DataBoxDiskSecret item in DiskSecrets) { writer.WriteObjectValue(item, options); } @@ -53,96 +54,102 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - CustomerDiskJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CustomerDiskJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CustomerDiskJobSecrets)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override JobSecrets 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(CustomerDiskJobSecrets)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCustomerDiskJobSecrets(document.RootElement, options); } - internal static CustomerDiskJobSecrets DeserializeCustomerDiskJobSecrets(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CustomerDiskJobSecrets DeserializeCustomerDiskJobSecrets(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList diskSecrets = default; - string carrierAccountNumber = default; DataBoxOrderType jobSecretsType = default; - DataCenterAccessSecurityCode dcAccessSecurityCode = default; + DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IReadOnlyList diskSecrets = default; + string carrierAccountNumber = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("diskSecrets"u8)) + if (prop.NameEquals("jobSecretsType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DataBoxDiskSecret.DeserializeDataBoxDiskSecret(item, options)); - } - diskSecrets = array; + jobSecretsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("carrierAccountNumber"u8)) + if (prop.NameEquals("dcAccessSecurityCode"u8)) { - carrierAccountNumber = property.Value.GetString(); - continue; - } - if (property.NameEquals("jobSecretsType"u8)) - { - jobSecretsType = property.Value.GetString().ToDataBoxOrderType(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataCenterAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(prop.Value, options); continue; } - if (property.NameEquals("dcAccessSecurityCode"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dcAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(property.Value, options); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("diskSecrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxDiskSecret.DeserializeDataBoxDiskSecret(item, options)); + } + diskSecrets = array; + continue; + } + if (prop.NameEquals("carrierAccountNumber"u8)) + { + carrierAccountNumber = 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 CustomerDiskJobSecrets( jobSecretsType, - dcAccessSecurityCode, + dataCenterAccessSecurityCode, error, - serializedAdditionalRawData, + additionalBinaryDataProperties, diskSecrets ?? new ChangeTrackingList(), carrierAccountNumber); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -152,15 +159,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - CustomerDiskJobSecrets 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. + CustomerDiskJobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CustomerDiskJobSecrets)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override JobSecrets 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 DeserializeCustomerDiskJobSecrets(document.RootElement, options); } default: @@ -168,6 +180,7 @@ CustomerDiskJobSecrets IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.cs index d2b8fff48bc8..706cafa780f0 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerDiskJobSecrets.cs @@ -7,6 +7,8 @@ using System; using System.Collections.Generic; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,28 +16,27 @@ namespace Azure.ResourceManager.DataBox.Models public partial class CustomerDiskJobSecrets : JobSecrets { /// Initializes a new instance of . - internal CustomerDiskJobSecrets() + internal CustomerDiskJobSecrets() : base(DataBoxOrderType.DataBoxCustomerDisk) { DiskSecrets = new ChangeTrackingList(); - JobSecretsType = DataBoxOrderType.DataBoxCustomerDisk; } /// Initializes a new instance of . /// Used to indicate what type of job secrets object. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Contains the list of secrets object for that device. /// Carrier Account Number of the customer. - internal CustomerDiskJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary serializedAdditionalRawData, IReadOnlyList diskSecrets, string carrierAccountNumber) : base(jobSecretsType, dataCenterAccessSecurityCode, error, serializedAdditionalRawData) + internal CustomerDiskJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary additionalBinaryDataProperties, IReadOnlyList diskSecrets, string carrierAccountNumber) : base(jobSecretsType, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties) { DiskSecrets = diskSecrets; CarrierAccountNumber = carrierAccountNumber; - JobSecretsType = jobSecretsType; } /// Contains the list of secrets object for that device. public IReadOnlyList DiskSecrets { get; } + /// Carrier Account Number of the customer. public string CarrierAccountNumber { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerResolutionCode.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerResolutionCode.Serialization.cs index 921c19fbda80..1332aa9562f1 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerResolutionCode.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/CustomerResolutionCode.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class CustomerResolutionCodeExtensions { + /// The value to serialize. public static string ToSerialString(this CustomerResolutionCode value) => value switch { CustomerResolutionCode.None => "None", @@ -21,13 +22,29 @@ internal static partial class CustomerResolutionCodeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CustomerResolutionCode value.") }; + /// The value to deserialize. public static CustomerResolutionCode ToCustomerResolutionCode(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) return CustomerResolutionCode.None; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "MoveToCleanUpDevice")) return CustomerResolutionCode.MoveToCleanUpDevice; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Resume")) return CustomerResolutionCode.Resume; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Restart")) return CustomerResolutionCode.Restart; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ReachOutToOperation")) return CustomerResolutionCode.ReachOutToOperation; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) + { + return CustomerResolutionCode.None; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "MoveToCleanUpDevice")) + { + return CustomerResolutionCode.MoveToCleanUpDevice; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Resume")) + { + return CustomerResolutionCode.Resume; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Restart")) + { + return CustomerResolutionCode.Restart; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ReachOutToOperation")) + { + return CustomerResolutionCode.ReachOutToOperation; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CustomerResolutionCode value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.Serialization.cs index 5c30a590cf4b..b3792b01053d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { + /// + /// Account details of the data to be transferred + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// [PersistableModelProxy(typeof(UnknownDataAccountDetails))] - public partial class DataAccountDetails : IUtf8JsonSerializable, IJsonModel + public abstract partial class DataAccountDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataAccountDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +37,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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(DataAccountDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("dataAccountType"u8); writer.WriteStringValue(DataAccountType.ToSerialString()); if (Optional.IsDefined(SharePassword)) @@ -41,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("sharePassword"u8); writer.WriteStringValue(SharePassword); } - 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); } @@ -58,41 +66,51 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataAccountDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataAccountDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataAccountDetails 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(DataAccountDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataAccountDetails(document.RootElement, options); } - internal static DataAccountDetails DeserializeDataAccountDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataAccountDetails DeserializeDataAccountDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("dataAccountType", out JsonElement discriminator)) + if (element.TryGetProperty("dataAccountType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "ManagedDisk": return ManagedDiskDetails.DeserializeManagedDiskDetails(element, options); - case "StorageAccount": return DataBoxStorageAccountDetails.DeserializeDataBoxStorageAccountDetails(element, options); + case "ManagedDisk": + return ManagedDiskDetails.DeserializeManagedDiskDetails(element, options); + case "StorageAccount": + return DataBoxStorageAccountDetails.DeserializeDataBoxStorageAccountDetails(element, options); } } return UnknownDataAccountDetails.DeserializeUnknownDataAccountDetails(element, options); } - 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": @@ -102,15 +120,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DataAccountDetails 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. + DataAccountDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataAccountDetails 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 DeserializeDataAccountDetails(document.RootElement, options); } default: @@ -118,6 +141,7 @@ DataAccountDetails IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.cs index f727ce6deb15..041f913715a0 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountDetails.cs @@ -12,61 +12,34 @@ namespace Azure.ResourceManager.DataBox.Models { /// /// Account details of the data to be transferred - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . /// public abstract partial class DataAccountDetails { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected DataAccountDetails() + /// Account Type of the data to be transferred. + private protected DataAccountDetails(DataAccountType dataAccountType) { + DataAccountType = dataAccountType; } /// Initializes a new instance of . /// Account Type of the data to be transferred. /// Password for all the shares to be created on the device. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. - /// Keeps track of any properties unknown to the library. - internal DataAccountDetails(DataAccountType dataAccountType, string sharePassword, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataAccountDetails(DataAccountType dataAccountType, string sharePassword, IDictionary additionalBinaryDataProperties) { DataAccountType = dataAccountType; SharePassword = sharePassword; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Account Type of the data to be transferred. internal DataAccountType DataAccountType { get; set; } + /// Password for all the shares to be created on the device. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. public string SharePassword { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountType.Serialization.cs index e109d3addc71..51ba79baadd3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataAccountType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataAccountTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DataAccountType value) => value switch { DataAccountType.StorageAccount => "StorageAccount", @@ -18,10 +19,17 @@ internal static partial class DataAccountTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataAccountType value.") }; + /// The value to deserialize. public static DataAccountType ToDataAccountType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "StorageAccount")) return DataAccountType.StorageAccount; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ManagedDisk")) return DataAccountType.ManagedDisk; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "StorageAccount")) + { + return DataAccountType.StorageAccount; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ManagedDisk")) + { + return DataAccountType.ManagedDisk; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataAccountType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccessProtocol.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccessProtocol.Serialization.cs index 0f0cce28f27c..12c2a1fbccba 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccessProtocol.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccessProtocol.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxAccessProtocolExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxAccessProtocol value) => value switch { DataBoxAccessProtocol.Smb => "SMB", @@ -18,10 +19,17 @@ internal static partial class DataBoxAccessProtocolExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxAccessProtocol value.") }; + /// The value to deserialize. public static DataBoxAccessProtocol ToDataBoxAccessProtocol(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "SMB")) return DataBoxAccessProtocol.Smb; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "NFS")) return DataBoxAccessProtocol.Nfs; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "SMB")) + { + return DataBoxAccessProtocol.Smb; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "NFS")) + { + return DataBoxAccessProtocol.Nfs; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxAccessProtocol value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.Serialization.cs index 1f8902d1119a..1106db56adf6 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxAccountCopyLogDetails : IUtf8JsonSerializable, IJsonModel + /// Copy log details for a storage account of a DataBox job. + public partial class DataBoxAccountCopyLogDetails : CopyLogDetails, 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, Model /// 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(DataBoxAccountCopyLogDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(AccountName)) { @@ -52,67 +52,73 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxAccountCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxAccountCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxAccountCopyLogDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override CopyLogDetails 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(DataBoxAccountCopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxAccountCopyLogDetails(document.RootElement, options); } - internal static DataBoxAccountCopyLogDetails DeserializeDataBoxAccountCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxAccountCopyLogDetails DeserializeDataBoxAccountCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxOrderType copyLogDetailsType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string accountName = default; string copyLogLink = default; string copyVerboseLogLink = default; - DataBoxOrderType copyLogDetailsType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("accountName"u8)) + if (prop.NameEquals("copyLogDetailsType"u8)) { - accountName = property.Value.GetString(); + copyLogDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("copyLogLink"u8)) + if (prop.NameEquals("accountName"u8)) { - copyLogLink = property.Value.GetString(); + accountName = prop.Value.GetString(); continue; } - if (property.NameEquals("copyVerboseLogLink"u8)) + if (prop.NameEquals("copyLogLink"u8)) { - copyVerboseLogLink = property.Value.GetString(); + copyLogLink = prop.Value.GetString(); continue; } - if (property.NameEquals("copyLogDetailsType"u8)) + if (prop.NameEquals("copyVerboseLogLink"u8)) { - copyLogDetailsType = property.Value.GetString().ToDataBoxOrderType(); + copyVerboseLogLink = 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 DataBoxAccountCopyLogDetails(copyLogDetailsType, serializedAdditionalRawData, accountName, copyLogLink, copyVerboseLogLink); + return new DataBoxAccountCopyLogDetails(copyLogDetailsType, additionalBinaryDataProperties, accountName, copyLogLink, copyVerboseLogLink); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - DataBoxAccountCopyLogDetails 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. + DataBoxAccountCopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxAccountCopyLogDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override CopyLogDetails 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 DeserializeDataBoxAccountCopyLogDetails(document.RootElement, options); } default: @@ -138,6 +149,7 @@ DataBoxAccountCopyLogDetails IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.cs index 033fb2973327..55f3d863fe3e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCopyLogDetails.cs @@ -14,29 +14,29 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxAccountCopyLogDetails : CopyLogDetails { /// Initializes a new instance of . - internal DataBoxAccountCopyLogDetails() + internal DataBoxAccountCopyLogDetails() : base(DataBoxOrderType.DataBox) { - CopyLogDetailsType = DataBoxOrderType.DataBox; } /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Account name. /// Link for copy logs. /// Link for copy verbose logs. This will be set only when LogCollectionLevel is set to Verbose. - internal DataBoxAccountCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData, string accountName, string copyLogLink, string copyVerboseLogLink) : base(copyLogDetailsType, serializedAdditionalRawData) + internal DataBoxAccountCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties, string accountName, string copyLogLink, string copyVerboseLogLink) : base(copyLogDetailsType, additionalBinaryDataProperties) { AccountName = accountName; CopyLogLink = copyLogLink; CopyVerboseLogLink = copyVerboseLogLink; - CopyLogDetailsType = copyLogDetailsType; } /// Account name. public string AccountName { get; } + /// Link for copy logs. public string CopyLogLink { get; } + /// Link for copy verbose logs. This will be set only when LogCollectionLevel is set to Verbose. public string CopyVerboseLogLink { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.Serialization.cs index 718c8e2d49ac..4a1173b99d09 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxAccountCredentialDetails : IUtf8JsonSerializable, IJsonModel + /// Credential details of the account. + public partial class DataBoxAccountCredentialDetails : 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, Mo /// 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(DataBoxAccountCredentialDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(AccountName)) { writer.WritePropertyName("accountName"u8); @@ -53,21 +53,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("shareCredentialDetails"u8); writer.WriteStartArray(); - foreach (var item in ShareCredentialDetails) + foreach (ShareCredentialDetails item in ShareCredentialDetails) { 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); } @@ -76,22 +76,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxAccountCredentialDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxAccountCredentialDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxAccountCredentialDetails 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(DataBoxAccountCredentialDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxAccountCredentialDetails(document.RootElement, options); } - internal static DataBoxAccountCredentialDetails DeserializeDataBoxAccountCredentialDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxAccountCredentialDetails DeserializeDataBoxAccountCredentialDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -100,37 +105,36 @@ internal static DataBoxAccountCredentialDetails DeserializeDataBoxAccountCredent DataAccountType? dataAccountType = default; string accountConnectionString = default; IReadOnlyList shareCredentialDetails = 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("accountName"u8)) + if (prop.NameEquals("accountName"u8)) { - accountName = property.Value.GetString(); + accountName = prop.Value.GetString(); continue; } - if (property.NameEquals("dataAccountType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataAccountType = property.Value.GetString().ToDataAccountType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("accountConnectionString"u8)) + if (prop.NameEquals("accountConnectionString"u8)) { - accountConnectionString = property.Value.GetString(); + accountConnectionString = prop.Value.GetString(); continue; } - if (property.NameEquals("shareCredentialDetails"u8)) + if (prop.NameEquals("shareCredentialDetails"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(Models.ShareCredentialDetails.DeserializeShareCredentialDetails(item, options)); } @@ -139,17 +143,19 @@ internal static DataBoxAccountCredentialDetails DeserializeDataBoxAccountCredent } 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 DataBoxAccountCredentialDetails(accountName, dataAccountType, accountConnectionString, shareCredentialDetails ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new DataBoxAccountCredentialDetails(accountName, dataAccountType, accountConnectionString, shareCredentialDetails ?? 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": @@ -159,15 +165,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DataBoxAccountCredentialDetails 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. + DataBoxAccountCredentialDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxAccountCredentialDetails 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 DeserializeDataBoxAccountCredentialDetails(document.RootElement, options); } default: @@ -175,6 +186,7 @@ DataBoxAccountCredentialDetails IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.cs index 5af1a58698c6..98922a3d9c37 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxAccountCredentialDetails.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Credential details of the account. public partial class DataBoxAccountCredentialDetails { - /// - /// 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 DataBoxAccountCredentialDetails() @@ -56,22 +28,25 @@ internal DataBoxAccountCredentialDetails() /// Type of the account. /// Connection string of the account endpoint to use the account as a storage endpoint on the device. /// Per share level unencrypted access credentials. - /// Keeps track of any properties unknown to the library. - internal DataBoxAccountCredentialDetails(string accountName, DataAccountType? dataAccountType, string accountConnectionString, IReadOnlyList shareCredentialDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxAccountCredentialDetails(string accountName, DataAccountType? dataAccountType, string accountConnectionString, IReadOnlyList shareCredentialDetails, IDictionary additionalBinaryDataProperties) { AccountName = accountName; DataAccountType = dataAccountType; AccountConnectionString = accountConnectionString; ShareCredentialDetails = shareCredentialDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the account. public string AccountName { get; } + /// Type of the account. public DataAccountType? DataAccountType { get; } + /// Connection string of the account endpoint to use the account as a storage endpoint on the device. public string AccountConnectionString { get; } + /// Per share level unencrypted access credentials. public IReadOnlyList ShareCredentialDetails { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.Serialization.cs index 09591003f432..cff32a313a22 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - [PersistableModelProxy(typeof(UnknownJobDetails))] - public partial class DataBoxBasicJobDetails : IUtf8JsonSerializable, IJsonModel + /// + /// Job details. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + [PersistableModelProxy(typeof(UnknownDataBoxBasicJobDetails))] + public abstract partial class DataBoxBasicJobDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxBasicJobDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +37,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(DataBoxBasicJobDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsCollectionDefined(JobStages)) { writer.WritePropertyName("jobStages"u8); writer.WriteStartArray(); - foreach (var item in JobStages) + foreach (DataBoxJobStage item in JobStages) { writer.WriteObjectValue(item, options); } @@ -65,7 +73,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("dataImportDetails"u8); writer.WriteStartArray(); - foreach (var item in DataImportDetails) + foreach (DataImportDetails item in DataImportDetails) { writer.WriteObjectValue(item, options); } @@ -75,7 +83,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("dataExportDetails"u8); writer.WriteStartArray(); - foreach (var item in DataExportDetails) + foreach (DataExportDetails item in DataExportDetails) { writer.WriteObjectValue(item, options); } @@ -97,7 +105,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("copyLogDetails"u8); writer.WriteStartArray(); - foreach (var item in CopyLogDetails) + foreach (CopyLogDetails item in CopyLogDetails) { writer.WriteObjectValue(item, options); } @@ -132,7 +140,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("actions"u8); writer.WriteStartArray(); - foreach (var item in Actions) + foreach (CustomerResolutionCode item in Actions) { writer.WriteStringValue(item.ToSerialString()); } @@ -153,15 +161,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("dataCenterCode"u8); writer.WriteStringValue(DataCenterCode.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); } @@ -170,43 +178,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxBasicJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxBasicJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxBasicJobDetails 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(DataBoxBasicJobDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxBasicJobDetails(document.RootElement, options); } - internal static DataBoxBasicJobDetails DeserializeDataBoxBasicJobDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxBasicJobDetails DeserializeDataBoxBasicJobDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("jobDetailsType", out JsonElement discriminator)) + if (element.TryGetProperty("jobDetailsType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "DataBox": return DataBoxJobDetails.DeserializeDataBoxJobDetails(element, options); - case "DataBoxCustomerDisk": return DataBoxCustomerDiskJobDetails.DeserializeDataBoxCustomerDiskJobDetails(element, options); - case "DataBoxDisk": return DataBoxDiskJobDetails.DeserializeDataBoxDiskJobDetails(element, options); - case "DataBoxHeavy": return DataBoxHeavyJobDetails.DeserializeDataBoxHeavyJobDetails(element, options); + case "DataBoxCustomerDisk": + return DataBoxCustomerDiskJobDetails.DeserializeDataBoxCustomerDiskJobDetails(element, options); + case "DataBoxDisk": + return DataBoxDiskJobDetails.DeserializeDataBoxDiskJobDetails(element, options); + case "DataBoxHeavy": + return DataBoxHeavyJobDetails.DeserializeDataBoxHeavyJobDetails(element, options); + case "DataBox": + return DataBoxJobDetails.DeserializeDataBoxJobDetails(element, options); } } - return UnknownJobDetails.DeserializeUnknownJobDetails(element, options); + return UnknownDataBoxBasicJobDetails.DeserializeUnknownDataBoxBasicJobDetails(element, options); } - 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 +236,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - DataBoxBasicJobDetails 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. + DataBoxBasicJobDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxBasicJobDetails 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 DeserializeDataBoxBasicJobDetails(document.RootElement, options); } default: @@ -232,6 +257,7 @@ DataBoxBasicJobDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.cs index fc03872a9219..8ffd30469589 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxBasicJobDetails.cs @@ -7,59 +7,29 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// /// Job details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . /// public abstract partial class DataBoxBasicJobDetails { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Contact details for notification and shipping. - /// is null. - protected DataBoxBasicJobDetails(DataBoxContactDetails contactDetails) + /// Indicates the type of job details. + private protected DataBoxBasicJobDetails(DataBoxContactDetails contactDetails, DataBoxOrderType jobDetailsType) { - Argument.AssertNotNull(contactDetails, nameof(contactDetails)); - JobStages = new ChangeTrackingList(); ContactDetails = contactDetails; DataImportDetails = new ChangeTrackingList(); DataExportDetails = new ChangeTrackingList(); + JobDetailsType = jobDetailsType; CopyLogDetails = new ChangeTrackingList(); Actions = new ChangeTrackingList(); } @@ -75,11 +45,7 @@ protected DataBoxBasicJobDetails(DataBoxContactDetails contactDetails) /// Indicates the type of job details. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -87,14 +53,10 @@ protected DataBoxBasicJobDetails(DataBoxContactDetails contactDetails) /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. - /// Keeps track of any properties unknown to the library. - internal DataBoxBasicJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxBasicJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary additionalBinaryDataProperties) { JobStages = jobStages; ContactDetails = contactDetails; @@ -116,60 +78,66 @@ internal DataBoxBasicJobDetails(IReadOnlyList jobStages, DataBo LastMitigationActionOnJob = lastMitigationActionOnJob; DataCenterAddress = dataCenterAddress; DataCenterCode = dataCenterCode; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxBasicJobDetails() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// List of stages that run in the job. public IReadOnlyList JobStages { get; } + /// Contact details for notification and shipping. public DataBoxContactDetails ContactDetails { get; set; } + /// Shipping address of the customer. public DataBoxShippingAddress ShippingAddress { get; set; } + /// Delivery package shipping details. public PackageShippingDetails DeliveryPackage { get; } + /// Return package shipping details. public PackageShippingDetails ReturnPackage { get; } + /// Details of the data to be imported into azure. public IList DataImportDetails { get; } + /// Details of the data to be exported from azure. public IList DataExportDetails { get; } + /// Indicates the type of job details. internal DataBoxOrderType JobDetailsType { get; set; } + /// Preferences for the order. public DataBoxOrderPreferences Preferences { get; set; } + /// Optional Reverse Shipping details for order. public ReverseShippingDetails ReverseShippingDetails { get; set; } - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + + /// List of copy log details. public IReadOnlyList CopyLogDetails { get; } + /// Shared access key to download the return shipment label. public string ReverseShipmentLabelSasKey { get; } + /// Shared access key to download the chain of custody logs. public string ChainOfCustodySasKey { get; } + /// Holds device data erasure details. public DeviceErasureDetails DeviceErasureDetails { get; } + /// Details about which key encryption type is being used. public DataBoxKeyEncryptionKey KeyEncryptionKey { get; set; } + /// The expected size of the data, which needs to be transferred in this job, in terabytes. public int? ExpectedDataSizeInTerabytes { get; set; } + /// Available actions on the job. public IReadOnlyList Actions { get; } + /// Last mitigation action performed on the job. public LastMitigationActionOnJob LastMitigationActionOnJob { get; } - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + + /// Datacenter address to ship to, for the given sku and storage location. public DataCenterAddressResult DataCenterAddress { get; } + /// DataCenter code. public DataCenterCode? DataCenterCode { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.Serialization.cs index 3d73bf355118..206fa36e71a2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxContactDetails : IUtf8JsonSerializable, IJsonModel + /// Contact Details. + public partial class DataBoxContactDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxContactDetails() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderW /// 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(DataBoxContactDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("contactName"u8); writer.WriteStringValue(ContactName); writer.WritePropertyName("phone"u8); @@ -50,8 +55,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName("emailList"u8); writer.WriteStartArray(); - foreach (var item in EmailList) + foreach (string item in EmailList) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -59,21 +69,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("notificationPreference"u8); writer.WriteStartArray(); - foreach (var item in NotificationPreference) + foreach (NotificationPreference item in NotificationPreference) { 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); } @@ -82,22 +92,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxContactDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxContactDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxContactDetails 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(DataBoxContactDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxContactDetails(document.RootElement, options); } - internal static DataBoxContactDetails DeserializeDataBoxContactDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxContactDetails DeserializeDataBoxContactDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -108,48 +123,54 @@ internal static DataBoxContactDetails DeserializeDataBoxContactDetails(JsonEleme string mobile = default; IList emailList = default; IList notificationPreference = 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("contactName"u8)) + if (prop.NameEquals("contactName"u8)) { - contactName = property.Value.GetString(); + contactName = prop.Value.GetString(); continue; } - if (property.NameEquals("phone"u8)) + if (prop.NameEquals("phone"u8)) { - phone = property.Value.GetString(); + phone = prop.Value.GetString(); continue; } - if (property.NameEquals("phoneExtension"u8)) + if (prop.NameEquals("phoneExtension"u8)) { - phoneExtension = property.Value.GetString(); + phoneExtension = prop.Value.GetString(); continue; } - if (property.NameEquals("mobile"u8)) + if (prop.NameEquals("mobile"u8)) { - mobile = property.Value.GetString(); + mobile = prop.Value.GetString(); continue; } - if (property.NameEquals("emailList"u8)) + if (prop.NameEquals("emailList"u8)) { 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()); + } } emailList = array; continue; } - if (property.NameEquals("notificationPreference"u8)) + if (prop.NameEquals("notificationPreference"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(Models.NotificationPreference.DeserializeNotificationPreference(item, options)); } @@ -158,10 +179,9 @@ internal static DataBoxContactDetails DeserializeDataBoxContactDetails(JsonEleme } 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 DataBoxContactDetails( contactName, phone, @@ -169,13 +189,16 @@ internal static DataBoxContactDetails DeserializeDataBoxContactDetails(JsonEleme mobile, emailList, notificationPreference ?? new ChangeTrackingList(), - 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": @@ -185,15 +208,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - DataBoxContactDetails 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. + DataBoxContactDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxContactDetails 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 DeserializeDataBoxContactDetails(document.RootElement, options); } default: @@ -201,6 +229,7 @@ DataBoxContactDetails IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.cs index a436f2c88849..f32cc50b452d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxContactDetails.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Contact Details. public partial class DataBoxContactDetails { - /// - /// 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 . /// Contact name of the person. @@ -70,8 +42,8 @@ public DataBoxContactDetails(string contactName, string phone, IEnumerable Mobile number of the contact person. /// List of Email-ids to be notified about job progress. /// Notification preference for a job stage. - /// Keeps track of any properties unknown to the library. - internal DataBoxContactDetails(string contactName, string phone, string phoneExtension, string mobile, IList emailList, IList notificationPreference, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxContactDetails(string contactName, string phone, string phoneExtension, string mobile, IList emailList, IList notificationPreference, IDictionary additionalBinaryDataProperties) { ContactName = contactName; Phone = phone; @@ -79,24 +51,24 @@ internal DataBoxContactDetails(string contactName, string phone, string phoneExt Mobile = mobile; EmailList = emailList; NotificationPreference = notificationPreference; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxContactDetails() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Contact name of the person. public string ContactName { get; set; } + /// Phone number of the contact person. public string Phone { get; set; } + /// Phone extension number of the contact person. public string PhoneExtension { get; set; } + /// Mobile number of the contact person. public string Mobile { get; set; } + /// List of Email-ids to be notified about job progress. public IList EmailList { get; } + /// Notification preference for a job stage. public IList NotificationPreference { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.Serialization.cs index 7475ad61ce59..618b138e49e6 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.Serialization.cs @@ -10,14 +10,17 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxCopyProgress : IUtf8JsonSerializable, IJsonModel + /// Copy progress. + public partial class DataBoxCopyProgress : 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(); @@ -29,12 +32,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// 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(DataBoxCopyProgress)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(StorageAccountName)) { writer.WritePropertyName("storageAccountName"u8); @@ -119,21 +121,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("actions"u8); writer.WriteStartArray(); - foreach (var item in Actions) + foreach (CustomerResolutionCode item in Actions) { writer.WriteStringValue(item.ToSerialString()); } 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); } @@ -142,22 +144,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxCopyProgress 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(DataBoxCopyProgress)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxCopyProgress(document.RootElement, options); } - internal static DataBoxCopyProgress DeserializeDataBoxCopyProgress(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxCopyProgress DeserializeDataBoxCopyProgress(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -179,158 +186,157 @@ internal static DataBoxCopyProgress DeserializeDataBoxCopyProgress(JsonElement e bool? isEnumerationInProgress = default; ResponseError error = default; IReadOnlyList actions = 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("storageAccountName"u8)) + if (prop.NameEquals("storageAccountName"u8)) { - storageAccountName = property.Value.GetString(); + storageAccountName = prop.Value.GetString(); continue; } - if (property.NameEquals("transferType"u8)) + if (prop.NameEquals("transferType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferType = property.Value.GetString().ToDataBoxJobTransferType(); + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); continue; } - if (property.NameEquals("dataAccountType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataAccountType = property.Value.GetString().ToDataAccountType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("accountId"u8)) + if (prop.NameEquals("accountId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - accountId = new ResourceIdentifier(property.Value.GetString()); + accountId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("bytesProcessed"u8)) + if (prop.NameEquals("bytesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - bytesProcessed = property.Value.GetInt64(); + bytesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalBytesToProcess"u8)) + if (prop.NameEquals("totalBytesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalBytesToProcess = property.Value.GetInt64(); + totalBytesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesProcessed"u8)) + if (prop.NameEquals("filesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesProcessed = property.Value.GetInt64(); + filesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalFilesToProcess"u8)) + if (prop.NameEquals("totalFilesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalFilesToProcess = property.Value.GetInt64(); + totalFilesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFilesProcessed"u8)) + if (prop.NameEquals("invalidFilesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFilesProcessed = property.Value.GetInt64(); + invalidFilesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFileBytesUploaded"u8)) + if (prop.NameEquals("invalidFileBytesUploaded"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFileBytesUploaded = property.Value.GetInt64(); + invalidFileBytesUploaded = prop.Value.GetInt64(); continue; } - if (property.NameEquals("renamedContainerCount"u8)) + if (prop.NameEquals("renamedContainerCount"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - renamedContainerCount = property.Value.GetInt64(); + renamedContainerCount = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesErroredOut"u8)) + if (prop.NameEquals("filesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesErroredOut = property.Value.GetInt64(); + filesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("directoriesErroredOut"u8)) + if (prop.NameEquals("directoriesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - directoriesErroredOut = property.Value.GetInt64(); + directoriesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidDirectoriesProcessed"u8)) + if (prop.NameEquals("invalidDirectoriesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidDirectoriesProcessed = property.Value.GetInt64(); + invalidDirectoriesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("isEnumerationInProgress"u8)) + if (prop.NameEquals("isEnumerationInProgress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isEnumerationInProgress = property.Value.GetBoolean(); + isEnumerationInProgress = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("actions"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().ToCustomerResolutionCode()); } @@ -339,10 +345,9 @@ internal static DataBoxCopyProgress DeserializeDataBoxCopyProgress(JsonElement e } 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 DataBoxCopyProgress( storageAccountName, transferType, @@ -361,13 +366,16 @@ internal static DataBoxCopyProgress DeserializeDataBoxCopyProgress(JsonElement e isEnumerationInProgress, error, actions ?? new ChangeTrackingList(), - 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": @@ -377,15 +385,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DataBoxCopyProgress 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. + DataBoxCopyProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxCopyProgress 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 DeserializeDataBoxCopyProgress(document.RootElement, options); } default: @@ -393,6 +406,7 @@ DataBoxCopyProgress IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.cs index fa4b2fe5b83e..63e2876a3453 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyProgress.cs @@ -7,44 +7,17 @@ using System; using System.Collections.Generic; +using Azure; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Copy progress. public partial class DataBoxCopyProgress { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal DataBoxCopyProgress() @@ -73,8 +46,8 @@ internal DataBoxCopyProgress() /// /// Error, if any, in the stage. /// Available actions on the job. - /// Keeps track of any properties unknown to the library. - internal DataBoxCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary additionalBinaryDataProperties) { StorageAccountName = storageAccountName; TransferType = transferType; @@ -93,44 +66,60 @@ internal DataBoxCopyProgress(string storageAccountName, DataBoxJobTransferType? IsEnumerationInProgress = isEnumerationInProgress; Error = error; Actions = actions; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the storage account. This will be empty for data account types other than storage account. public string StorageAccountName { get; } + /// Transfer type of data. public DataBoxJobTransferType? TransferType { get; } + /// Data Account Type. public DataAccountType? DataAccountType { get; } + /// Id of the account where the data needs to be uploaded. public ResourceIdentifier AccountId { get; } + /// To indicate bytes transferred. public long? BytesProcessed { get; } + /// Total amount of data to be processed by the job. public long? TotalBytesToProcess { get; } + /// Number of files processed. public long? FilesProcessed { get; } + /// Total files to process. public long? TotalFilesToProcess { get; } + /// Number of files not adhering to azure naming conventions which were processed by automatic renaming. public long? InvalidFilesProcessed { get; } + /// Total amount of data not adhering to azure naming conventions which were processed by automatic renaming. public long? InvalidFileBytesUploaded { get; } + /// Number of folders not adhering to azure naming conventions which were processed by automatic renaming. public long? RenamedContainerCount { get; } + /// Number of files which could not be copied. public long? FilesErroredOut { get; } + /// To indicate directories errored out in the job. public long? DirectoriesErroredOut { get; } + /// To indicate directories renamed. public long? InvalidDirectoriesProcessed { get; } + /// /// To indicate if enumeration of data is in progress. /// Until this is true, the TotalBytesToProcess may not be valid. /// public bool? IsEnumerationInProgress { get; } + /// Error, if any, in the stage. public ResponseError Error { get; } + /// Available actions on the job. public IReadOnlyList Actions { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyStatus.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyStatus.cs index ea8ab6446e64..32284220878d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyStatus.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCopyStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,86 +15,137 @@ namespace Azure.ResourceManager.DataBox.Models public readonly partial struct DataBoxCopyStatus : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DataBoxCopyStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - + /// Data copy hasn't started yet. private const string NotStartedValue = "NotStarted"; + /// Data copy is in progress. private const string InProgressValue = "InProgress"; + /// Data copy completed. private const string CompletedValue = "Completed"; + /// Data copy completed with errors. private const string CompletedWithErrorsValue = "CompletedWithErrors"; + /// Data copy failed. No data was copied. private const string FailedValue = "Failed"; + /// No copy triggered as device was not returned. private const string NotReturnedValue = "NotReturned"; + /// The Device has hit hardware issues. private const string HardwareErrorValue = "HardwareError"; + /// Data copy failed. The Device was formatted by user. private const string DeviceFormattedValue = "DeviceFormatted"; + /// Data copy failed. Device metadata was modified by user. private const string DeviceMetadataModifiedValue = "DeviceMetadataModified"; + /// Data copy failed. Storage Account was not accessible during copy. private const string StorageAccountNotAccessibleValue = "StorageAccountNotAccessible"; + /// Data copy failed. The Device data content is not supported. private const string UnsupportedDataValue = "UnsupportedData"; + /// No copy triggered as device was not received. private const string DriveNotReceivedValue = "DriveNotReceived"; + /// No copy triggered as device type is not supported. private const string UnsupportedDriveValue = "UnsupportedDrive"; + /// Copy failed due to service error. private const string OtherServiceErrorValue = "OtherServiceError"; + /// Copy failed due to user error. private const string OtherUserErrorValue = "OtherUserError"; + /// Copy failed due to disk detection error. private const string DriveNotDetectedValue = "DriveNotDetected"; + /// Copy failed due to corrupted drive. private const string DriveCorruptedValue = "DriveCorrupted"; + /// Copy failed due to modified or removed metadata files. private const string MetadataFilesModifiedOrRemovedValue = "MetadataFilesModifiedOrRemoved"; + /// Initializes a new instance of . + /// The value. + /// is null. + public DataBoxCopyStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// Data copy hasn't started yet. public static DataBoxCopyStatus NotStarted { get; } = new DataBoxCopyStatus(NotStartedValue); + /// Data copy is in progress. public static DataBoxCopyStatus InProgress { get; } = new DataBoxCopyStatus(InProgressValue); + /// Data copy completed. public static DataBoxCopyStatus Completed { get; } = new DataBoxCopyStatus(CompletedValue); + /// Data copy completed with errors. public static DataBoxCopyStatus CompletedWithErrors { get; } = new DataBoxCopyStatus(CompletedWithErrorsValue); + /// Data copy failed. No data was copied. public static DataBoxCopyStatus Failed { get; } = new DataBoxCopyStatus(FailedValue); + /// No copy triggered as device was not returned. public static DataBoxCopyStatus NotReturned { get; } = new DataBoxCopyStatus(NotReturnedValue); + /// The Device has hit hardware issues. public static DataBoxCopyStatus HardwareError { get; } = new DataBoxCopyStatus(HardwareErrorValue); + /// Data copy failed. The Device was formatted by user. public static DataBoxCopyStatus DeviceFormatted { get; } = new DataBoxCopyStatus(DeviceFormattedValue); + /// Data copy failed. Device metadata was modified by user. public static DataBoxCopyStatus DeviceMetadataModified { get; } = new DataBoxCopyStatus(DeviceMetadataModifiedValue); + /// Data copy failed. Storage Account was not accessible during copy. public static DataBoxCopyStatus StorageAccountNotAccessible { get; } = new DataBoxCopyStatus(StorageAccountNotAccessibleValue); + /// Data copy failed. The Device data content is not supported. public static DataBoxCopyStatus UnsupportedData { get; } = new DataBoxCopyStatus(UnsupportedDataValue); + /// No copy triggered as device was not received. public static DataBoxCopyStatus DriveNotReceived { get; } = new DataBoxCopyStatus(DriveNotReceivedValue); + /// No copy triggered as device type is not supported. public static DataBoxCopyStatus UnsupportedDrive { get; } = new DataBoxCopyStatus(UnsupportedDriveValue); + /// Copy failed due to service error. public static DataBoxCopyStatus OtherServiceError { get; } = new DataBoxCopyStatus(OtherServiceErrorValue); + /// Copy failed due to user error. public static DataBoxCopyStatus OtherUserError { get; } = new DataBoxCopyStatus(OtherUserErrorValue); + /// Copy failed due to disk detection error. public static DataBoxCopyStatus DriveNotDetected { get; } = new DataBoxCopyStatus(DriveNotDetectedValue); + /// Copy failed due to corrupted drive. public static DataBoxCopyStatus DriveCorrupted { get; } = new DataBoxCopyStatus(DriveCorruptedValue); + /// Copy failed due to modified or removed metadata files. public static DataBoxCopyStatus MetadataFilesModifiedOrRemoved { get; } = new DataBoxCopyStatus(MetadataFilesModifiedOrRemovedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DataBoxCopyStatus left, DataBoxCopyStatus 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 !=(DataBoxCopyStatus left, DataBoxCopyStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DataBoxCopyStatus(string value) => new DataBoxCopyStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DataBoxCopyStatus?(string value) => value == null ? null : new DataBoxCopyStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DataBoxCopyStatus other && Equals(other); - /// + + /// public bool Equals(DataBoxCopyStatus 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.Serialization.cs index 5b3118407171..25c8e3791af6 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxCustomerDiskCopyLogDetails : IUtf8JsonSerializable, IJsonModel + /// Copy Log Details for customer disk. + public partial class DataBoxCustomerDiskCopyLogDetails : CopyLogDetails, 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 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(DataBoxCustomerDiskCopyLogDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(SerialNumber)) { @@ -52,67 +52,73 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxCustomerDiskCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxCustomerDiskCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxCustomerDiskCopyLogDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override CopyLogDetails 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(DataBoxCustomerDiskCopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxCustomerDiskCopyLogDetails(document.RootElement, options); } - internal static DataBoxCustomerDiskCopyLogDetails DeserializeDataBoxCustomerDiskCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxCustomerDiskCopyLogDetails DeserializeDataBoxCustomerDiskCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxOrderType copyLogDetailsType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string serialNumber = default; string errorLogLink = default; string verboseLogLink = default; - DataBoxOrderType copyLogDetailsType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("serialNumber"u8)) + if (prop.NameEquals("copyLogDetailsType"u8)) { - serialNumber = property.Value.GetString(); + copyLogDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("errorLogLink"u8)) + if (prop.NameEquals("serialNumber"u8)) { - errorLogLink = property.Value.GetString(); + serialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("verboseLogLink"u8)) + if (prop.NameEquals("errorLogLink"u8)) { - verboseLogLink = property.Value.GetString(); + errorLogLink = prop.Value.GetString(); continue; } - if (property.NameEquals("copyLogDetailsType"u8)) + if (prop.NameEquals("verboseLogLink"u8)) { - copyLogDetailsType = property.Value.GetString().ToDataBoxOrderType(); + verboseLogLink = 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 DataBoxCustomerDiskCopyLogDetails(copyLogDetailsType, serializedAdditionalRawData, serialNumber, errorLogLink, verboseLogLink); + return new DataBoxCustomerDiskCopyLogDetails(copyLogDetailsType, additionalBinaryDataProperties, serialNumber, errorLogLink, verboseLogLink); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +128,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - DataBoxCustomerDiskCopyLogDetails 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. + DataBoxCustomerDiskCopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxCustomerDiskCopyLogDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override CopyLogDetails 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 DeserializeDataBoxCustomerDiskCopyLogDetails(document.RootElement, options); } default: @@ -138,6 +149,7 @@ DataBoxCustomerDiskCopyLogDetails IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.cs index ba15bdad9a3c..57be18bfc941 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyLogDetails.cs @@ -14,29 +14,29 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxCustomerDiskCopyLogDetails : CopyLogDetails { /// Initializes a new instance of . - internal DataBoxCustomerDiskCopyLogDetails() + internal DataBoxCustomerDiskCopyLogDetails() : base(DataBoxOrderType.DataBoxCustomerDisk) { - CopyLogDetailsType = DataBoxOrderType.DataBoxCustomerDisk; } /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Disk Serial Number. /// Link for copy error logs. /// Link for copy verbose logs. - internal DataBoxCustomerDiskCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData, string serialNumber, string errorLogLink, string verboseLogLink) : base(copyLogDetailsType, serializedAdditionalRawData) + internal DataBoxCustomerDiskCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties, string serialNumber, string errorLogLink, string verboseLogLink) : base(copyLogDetailsType, additionalBinaryDataProperties) { SerialNumber = serialNumber; ErrorLogLink = errorLogLink; VerboseLogLink = verboseLogLink; - CopyLogDetailsType = copyLogDetailsType; } /// Disk Serial Number. public string SerialNumber { get; } + /// Link for copy error logs. public string ErrorLogLink { get; } + /// Link for copy verbose logs. public string VerboseLogLink { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.Serialization.cs index f88ad407a9c9..ec1334804d53 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.Serialization.cs @@ -10,14 +10,17 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxCustomerDiskCopyProgress : IUtf8JsonSerializable, IJsonModel + /// DataBox CustomerDisk Copy Progress. + public partial class DataBoxCustomerDiskCopyProgress : DataBoxCopyProgress, 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(); @@ -29,12 +32,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// 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(DataBoxCustomerDiskCopyProgress)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(SerialNumber)) { @@ -48,28 +50,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxCustomerDiskCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxCustomerDiskCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxCustomerDiskCopyProgress)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxCopyProgress 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(DataBoxCustomerDiskCopyProgress)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxCustomerDiskCopyProgress(document.RootElement, options); } - internal static DataBoxCustomerDiskCopyProgress DeserializeDataBoxCustomerDiskCopyProgress(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxCustomerDiskCopyProgress DeserializeDataBoxCustomerDiskCopyProgress(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string serialNumber = default; - DataBoxCopyStatus? copyStatus = default; string storageAccountName = default; DataBoxJobTransferType? transferType = default; DataAccountType? dataAccountType = default; @@ -87,184 +92,184 @@ internal static DataBoxCustomerDiskCopyProgress DeserializeDataBoxCustomerDiskCo bool? isEnumerationInProgress = default; ResponseError error = default; IReadOnlyList actions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serialNumber = default; + DataBoxCopyStatus? copyStatus = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("serialNumber"u8)) + if (prop.NameEquals("storageAccountName"u8)) { - serialNumber = property.Value.GetString(); + storageAccountName = prop.Value.GetString(); continue; } - if (property.NameEquals("copyStatus"u8)) + if (prop.NameEquals("transferType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - copyStatus = new DataBoxCopyStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("storageAccountName"u8)) - { - storageAccountName = property.Value.GetString(); + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); continue; } - if (property.NameEquals("transferType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferType = property.Value.GetString().ToDataBoxJobTransferType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("dataAccountType"u8)) + if (prop.NameEquals("accountId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataAccountType = property.Value.GetString().ToDataAccountType(); + accountId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("accountId"u8)) + if (prop.NameEquals("bytesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - accountId = new ResourceIdentifier(property.Value.GetString()); + bytesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("bytesProcessed"u8)) + if (prop.NameEquals("totalBytesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - bytesProcessed = property.Value.GetInt64(); + totalBytesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalBytesToProcess"u8)) + if (prop.NameEquals("filesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalBytesToProcess = property.Value.GetInt64(); + filesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesProcessed"u8)) + if (prop.NameEquals("totalFilesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesProcessed = property.Value.GetInt64(); + totalFilesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalFilesToProcess"u8)) + if (prop.NameEquals("invalidFilesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalFilesToProcess = property.Value.GetInt64(); + invalidFilesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFilesProcessed"u8)) + if (prop.NameEquals("invalidFileBytesUploaded"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFilesProcessed = property.Value.GetInt64(); + invalidFileBytesUploaded = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFileBytesUploaded"u8)) + if (prop.NameEquals("renamedContainerCount"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFileBytesUploaded = property.Value.GetInt64(); + renamedContainerCount = prop.Value.GetInt64(); continue; } - if (property.NameEquals("renamedContainerCount"u8)) + if (prop.NameEquals("filesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - renamedContainerCount = property.Value.GetInt64(); + filesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesErroredOut"u8)) + if (prop.NameEquals("directoriesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesErroredOut = property.Value.GetInt64(); + directoriesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("directoriesErroredOut"u8)) + if (prop.NameEquals("invalidDirectoriesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - directoriesErroredOut = property.Value.GetInt64(); + invalidDirectoriesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidDirectoriesProcessed"u8)) + if (prop.NameEquals("isEnumerationInProgress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidDirectoriesProcessed = property.Value.GetInt64(); + isEnumerationInProgress = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("isEnumerationInProgress"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isEnumerationInProgress = property.Value.GetBoolean(); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("actions"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetString().ToCustomerResolutionCode()); + } + actions = array; + continue; + } + if (prop.NameEquals("serialNumber"u8)) + { + serialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("copyStatus"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()) - { - array.Add(item.GetString().ToCustomerResolutionCode()); - } - actions = array; + copyStatus = new DataBoxCopyStatus(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 DataBoxCustomerDiskCopyProgress( storageAccountName, transferType, @@ -283,15 +288,18 @@ internal static DataBoxCustomerDiskCopyProgress DeserializeDataBoxCustomerDiskCo isEnumerationInProgress, error, actions ?? new ChangeTrackingList(), - serializedAdditionalRawData, + additionalBinaryDataProperties, serialNumber, copyStatus); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -301,15 +309,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DataBoxCustomerDiskCopyProgress 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. + DataBoxCustomerDiskCopyProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxCustomerDiskCopyProgress)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxCopyProgress 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 DeserializeDataBoxCustomerDiskCopyProgress(document.RootElement, options); } default: @@ -317,6 +330,7 @@ DataBoxCustomerDiskCopyProgress IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.cs index 307a6afcdfdb..c3b6fca7b5aa 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskCopyProgress.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure; using Azure.Core; namespace Azure.ResourceManager.DataBox.Models @@ -40,10 +41,10 @@ internal DataBoxCustomerDiskCopyProgress() /// /// Error, if any, in the stage. /// Available actions on the job. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Disk Serial Number. /// The Status of the copy. - internal DataBoxCustomerDiskCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary serializedAdditionalRawData, string serialNumber, DataBoxCopyStatus? copyStatus) : base(storageAccountName, transferType, dataAccountType, accountId, bytesProcessed, totalBytesToProcess, filesProcessed, totalFilesToProcess, invalidFilesProcessed, invalidFileBytesUploaded, renamedContainerCount, filesErroredOut, directoriesErroredOut, invalidDirectoriesProcessed, isEnumerationInProgress, error, actions, serializedAdditionalRawData) + internal DataBoxCustomerDiskCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary additionalBinaryDataProperties, string serialNumber, DataBoxCopyStatus? copyStatus) : base(storageAccountName, transferType, dataAccountType, accountId, bytesProcessed, totalBytesToProcess, filesProcessed, totalFilesToProcess, invalidFilesProcessed, invalidFileBytesUploaded, renamedContainerCount, filesErroredOut, directoriesErroredOut, invalidDirectoriesProcessed, isEnumerationInProgress, error, actions, additionalBinaryDataProperties) { SerialNumber = serialNumber; CopyStatus = copyStatus; @@ -51,6 +52,7 @@ internal DataBoxCustomerDiskCopyProgress(string storageAccountName, DataBoxJobTr /// Disk Serial Number. public string SerialNumber { get; } + /// The Status of the copy. public DataBoxCopyStatus? CopyStatus { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.Serialization.cs index f304a59b84a6..4a787eb20a1b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxCustomerDiskJobDetails : IUtf8JsonSerializable, IJsonModel + /// Customer disk job details. + public partial class DataBoxCustomerDiskJobDetails : DataBoxBasicJobDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxCustomerDiskJobDetails() + { + } + /// 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.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(DataBoxCustomerDiskJobDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(ImportDiskDetails)) { @@ -61,7 +66,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("copyProgress"u8); writer.WriteStartArray(); - foreach (var item in CopyProgress) + foreach (DataBoxCustomerDiskCopyProgress item in CopyProgress) { writer.WriteObjectValue(item, options); } @@ -81,32 +86,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxCustomerDiskJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxCustomerDiskJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxCustomerDiskJobDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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(DataBoxCustomerDiskJobDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxCustomerDiskJobDetails(document.RootElement, options); } - internal static DataBoxCustomerDiskJobDetails DeserializeDataBoxCustomerDiskJobDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxCustomerDiskJobDetails DeserializeDataBoxCustomerDiskJobDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IDictionary importDiskDetailsCollection = default; - IReadOnlyDictionary exportDiskDetailsCollection = default; - IReadOnlyList copyProgress = default; - PackageCarrierInfo deliverToDcPackageDetails = default; - PackageCarrierDetails returnToCustomerPackageDetails = default; - bool? enableManifestBackup = default; IReadOnlyList jobStages = default; DataBoxContactDetails contactDetails = default; DataBoxShippingAddress shippingAddress = default; @@ -122,275 +126,279 @@ internal static DataBoxCustomerDiskJobDetails DeserializeDataBoxCustomerDiskJobD string chainOfCustodySasKey = default; DeviceErasureDetails deviceErasureDetails = default; DataBoxKeyEncryptionKey keyEncryptionKey = default; - int? expectedDataSizeInTeraBytes = default; + int? expectedDataSizeInTerabytes = default; IReadOnlyList actions = default; LastMitigationActionOnJob lastMitigationActionOnJob = default; - DataCenterAddressResult datacenterAddress = default; + DataCenterAddressResult dataCenterAddress = default; DataCenterCode? dataCenterCode = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary importDiskDetails = default; + IReadOnlyDictionary exportDiskDetails = default; + IReadOnlyList copyProgress = default; + PackageCarrierInfo deliverToDataCenterPackageDetails = default; + PackageCarrierDetails returnToCustomerPackageDetails = default; + bool? enableManifestBackup = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("importDiskDetailsCollection"u8)) + if (prop.NameEquals("jobStages"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - dictionary.Add(property0.Name, Models.ImportDiskDetails.DeserializeImportDiskDetails(property0.Value, options)); + array.Add(DataBoxJobStage.DeserializeDataBoxJobStage(item, options)); } - importDiskDetailsCollection = dictionary; + jobStages = array; continue; } - if (property.NameEquals("exportDiskDetailsCollection"u8)) + if (prop.NameEquals("contactDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, Models.ExportDiskDetails.DeserializeExportDiskDetails(property0.Value, options)); - } - exportDiskDetailsCollection = dictionary; + contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(prop.Value, options); continue; } - if (property.NameEquals("copyProgress"u8)) + if (prop.NameEquals("shippingAddress"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()) - { - array.Add(DataBoxCustomerDiskCopyProgress.DeserializeDataBoxCustomerDiskCopyProgress(item, options)); - } - copyProgress = array; + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("deliverToDcPackageDetails"u8)) + if (prop.NameEquals("deliveryPackage"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deliverToDcPackageDetails = PackageCarrierInfo.DeserializePackageCarrierInfo(property.Value, options); + deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("returnToCustomerPackageDetails"u8)) + if (prop.NameEquals("returnPackage"u8)) { - returnToCustomerPackageDetails = PackageCarrierDetails.DeserializePackageCarrierDetails(property.Value, options); - continue; - } - if (property.NameEquals("enableManifestBackup"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - enableManifestBackup = property.Value.GetBoolean(); + returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("jobStages"u8)) + if (prop.NameEquals("dataImportDetails"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(DataBoxJobStage.DeserializeDataBoxJobStage(item, options)); + array.Add(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); } - jobStages = array; - continue; - } - if (property.NameEquals("contactDetails"u8)) - { - contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(property.Value, options); + dataImportDetails = array; continue; } - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("dataExportDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); + } + dataExportDetails = array; continue; } - if (property.NameEquals("deliveryPackage"u8)) + if (prop.NameEquals("jobDetailsType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + jobDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("returnPackage"u8)) + if (prop.NameEquals("preferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(prop.Value, options); continue; } - if (property.NameEquals("dataImportDetails"u8)) + if (prop.NameEquals("reverseShippingDetails"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()) - { - array.Add(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); - } - dataImportDetails = array; + reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("dataExportDetails"u8)) + if (prop.NameEquals("copyLogDetails"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); + array.Add(Models.CopyLogDetails.DeserializeCopyLogDetails(item, options)); } - dataExportDetails = array; + copyLogDetails = array; continue; } - if (property.NameEquals("jobDetailsType"u8)) + if (prop.NameEquals("reverseShipmentLabelSasKey"u8)) { - jobDetailsType = property.Value.GetString().ToDataBoxOrderType(); + reverseShipmentLabelSasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("preferences"u8)) + if (prop.NameEquals("chainOfCustodySasKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + chainOfCustodySasKey = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("deviceErasureDetails"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(property.Value, options); + deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(prop.Value, options); continue; } - if (property.NameEquals("reverseShippingDetails"u8)) + if (prop.NameEquals("keyEncryptionKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(property.Value, options); + keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(prop.Value, options); continue; } - if (property.NameEquals("copyLogDetails"u8)) + if (prop.NameEquals("expectedDataSizeInTeraBytes"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()) - { - array.Add(Models.CopyLogDetails.DeserializeCopyLogDetails(item, options)); - } - copyLogDetails = array; + expectedDataSizeInTerabytes = prop.Value.GetInt32(); continue; } - if (property.NameEquals("reverseShipmentLabelSasKey"u8)) + if (prop.NameEquals("actions"u8)) { - reverseShipmentLabelSasKey = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetString().ToCustomerResolutionCode()); + } + actions = array; continue; } - if (property.NameEquals("chainOfCustodySasKey"u8)) + if (prop.NameEquals("lastMitigationActionOnJob"u8)) { - chainOfCustodySasKey = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(prop.Value, options); continue; } - if (property.NameEquals("deviceErasureDetails"u8)) + if (prop.NameEquals("datacenterAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(property.Value, options); + dataCenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(prop.Value, options); continue; } - if (property.NameEquals("keyEncryptionKey"u8)) + if (prop.NameEquals("dataCenterCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(property.Value, options); + dataCenterCode = new DataCenterCode(prop.Value.GetString()); continue; } - if (property.NameEquals("expectedDataSizeInTeraBytes"u8)) + if (prop.NameEquals("importDiskDetailsCollection"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expectedDataSizeInTeraBytes = property.Value.GetInt32(); + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, Models.ImportDiskDetails.DeserializeImportDiskDetails(prop0.Value, options)); + } + importDiskDetails = dictionary; continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("exportDiskDetailsCollection"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()) + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) { - array.Add(item.GetString().ToCustomerResolutionCode()); + dictionary.Add(prop0.Name, Models.ExportDiskDetails.DeserializeExportDiskDetails(prop0.Value, options)); } - actions = array; + exportDiskDetails = dictionary; continue; } - if (property.NameEquals("lastMitigationActionOnJob"u8)) + if (prop.NameEquals("copyProgress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(property.Value, options); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxCustomerDiskCopyProgress.DeserializeDataBoxCustomerDiskCopyProgress(item, options)); + } + copyProgress = array; continue; } - if (property.NameEquals("datacenterAddress"u8)) + if (prop.NameEquals("deliverToDcPackageDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datacenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(property.Value, options); + deliverToDataCenterPackageDetails = PackageCarrierInfo.DeserializePackageCarrierInfo(prop.Value, options); + continue; + } + if (prop.NameEquals("returnToCustomerPackageDetails"u8)) + { + returnToCustomerPackageDetails = PackageCarrierDetails.DeserializePackageCarrierDetails(prop.Value, options); continue; } - if (property.NameEquals("dataCenterCode"u8)) + if (prop.NameEquals("enableManifestBackup"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataCenterCode = new DataCenterCode(property.Value.GetString()); + enableManifestBackup = prop.Value.GetBoolean(); 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 DataBoxCustomerDiskJobDetails( jobStages ?? new ChangeTrackingList(), contactDetails, @@ -407,24 +415,27 @@ internal static DataBoxCustomerDiskJobDetails DeserializeDataBoxCustomerDiskJobD chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, - expectedDataSizeInTeraBytes, + expectedDataSizeInTerabytes, actions ?? new ChangeTrackingList(), lastMitigationActionOnJob, - datacenterAddress, + dataCenterAddress, dataCenterCode, - serializedAdditionalRawData, - importDiskDetailsCollection ?? new ChangeTrackingDictionary(), - exportDiskDetailsCollection ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties, + importDiskDetails ?? new ChangeTrackingDictionary(), + exportDiskDetails ?? new ChangeTrackingDictionary(), copyProgress ?? new ChangeTrackingList(), - deliverToDcPackageDetails, + deliverToDataCenterPackageDetails, returnToCustomerPackageDetails, enableManifestBackup); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -434,15 +445,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - DataBoxCustomerDiskJobDetails 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. + DataBoxCustomerDiskJobDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxCustomerDiskJobDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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 DeserializeDataBoxCustomerDiskJobDetails(document.RootElement, options); } default: @@ -450,6 +466,7 @@ DataBoxCustomerDiskJobDetails IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.cs index c7878ed0ee84..dc9d1c3d8014 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxCustomerDiskJobDetails.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -17,7 +18,7 @@ public partial class DataBoxCustomerDiskJobDetails : DataBoxBasicJobDetails /// Contact details for notification and shipping. /// Return package shipping details. /// or is null. - public DataBoxCustomerDiskJobDetails(DataBoxContactDetails contactDetails, PackageCarrierDetails returnToCustomerPackageDetails) : base(contactDetails) + public DataBoxCustomerDiskJobDetails(DataBoxContactDetails contactDetails, PackageCarrierDetails returnToCustomerPackageDetails) : base(contactDetails, DataBoxOrderType.DataBoxCustomerDisk) { Argument.AssertNotNull(contactDetails, nameof(contactDetails)); Argument.AssertNotNull(returnToCustomerPackageDetails, nameof(returnToCustomerPackageDetails)); @@ -26,7 +27,6 @@ public DataBoxCustomerDiskJobDetails(DataBoxContactDetails contactDetails, Packa ExportDiskDetails = new ChangeTrackingDictionary(); CopyProgress = new ChangeTrackingList(); ReturnToCustomerPackageDetails = returnToCustomerPackageDetails; - JobDetailsType = DataBoxOrderType.DataBoxCustomerDisk; } /// Initializes a new instance of . @@ -40,11 +40,7 @@ public DataBoxCustomerDiskJobDetails(DataBoxContactDetails contactDetails, Packa /// Indicates the type of job details. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -52,20 +48,16 @@ public DataBoxCustomerDiskJobDetails(DataBoxContactDetails contactDetails, Packa /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Contains the map of disk serial number to the disk details for import jobs. /// Contains the map of disk serial number to the disk details for export jobs. /// Copy progress per disk. /// Delivery package shipping details. /// Return package shipping details. /// Flag to indicate if disk manifest should be backed-up in the Storage Account. - internal DataBoxCustomerDiskJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary serializedAdditionalRawData, IDictionary importDiskDetails, IReadOnlyDictionary exportDiskDetails, IReadOnlyList copyProgress, PackageCarrierInfo deliverToDataCenterPackageDetails, PackageCarrierDetails returnToCustomerPackageDetails, bool? enableManifestBackup) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, serializedAdditionalRawData) + internal DataBoxCustomerDiskJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary additionalBinaryDataProperties, IDictionary importDiskDetails, IReadOnlyDictionary exportDiskDetails, IReadOnlyList copyProgress, PackageCarrierInfo deliverToDataCenterPackageDetails, PackageCarrierDetails returnToCustomerPackageDetails, bool? enableManifestBackup) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, additionalBinaryDataProperties) { ImportDiskDetails = importDiskDetails; ExportDiskDetails = exportDiskDetails; @@ -73,24 +65,23 @@ internal DataBoxCustomerDiskJobDetails(IReadOnlyList jobStages, DeliverToDataCenterPackageDetails = deliverToDataCenterPackageDetails; ReturnToCustomerPackageDetails = returnToCustomerPackageDetails; EnableManifestBackup = enableManifestBackup; - JobDetailsType = jobDetailsType; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxCustomerDiskJobDetails() - { } /// Contains the map of disk serial number to the disk details for import jobs. public IDictionary ImportDiskDetails { get; } + /// Contains the map of disk serial number to the disk details for export jobs. public IReadOnlyDictionary ExportDiskDetails { get; } + /// Copy progress per disk. public IReadOnlyList CopyProgress { get; } + /// Delivery package shipping details. public PackageCarrierInfo DeliverToDataCenterPackageDetails { get; } + /// Return package shipping details. public PackageCarrierDetails ReturnToCustomerPackageDetails { get; set; } + /// Flag to indicate if disk manifest should be backed-up in the Storage Account. public bool? EnableManifestBackup { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.Serialization.cs index f321e3636dfc..d56400893ef3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxDiskCopyLogDetails : IUtf8JsonSerializable, IJsonModel + /// Copy Log Details for a disk. + public partial class DataBoxDiskCopyLogDetails : CopyLogDetails, 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, ModelRea /// 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(DataBoxDiskCopyLogDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(DiskSerialNumber)) { @@ -52,67 +52,73 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxDiskCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxDiskCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxDiskCopyLogDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override CopyLogDetails 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(DataBoxDiskCopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxDiskCopyLogDetails(document.RootElement, options); } - internal static DataBoxDiskCopyLogDetails DeserializeDataBoxDiskCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxDiskCopyLogDetails DeserializeDataBoxDiskCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxOrderType copyLogDetailsType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string diskSerialNumber = default; string errorLogLink = default; string verboseLogLink = default; - DataBoxOrderType copyLogDetailsType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("diskSerialNumber"u8)) + if (prop.NameEquals("copyLogDetailsType"u8)) { - diskSerialNumber = property.Value.GetString(); + copyLogDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("errorLogLink"u8)) + if (prop.NameEquals("diskSerialNumber"u8)) { - errorLogLink = property.Value.GetString(); + diskSerialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("verboseLogLink"u8)) + if (prop.NameEquals("errorLogLink"u8)) { - verboseLogLink = property.Value.GetString(); + errorLogLink = prop.Value.GetString(); continue; } - if (property.NameEquals("copyLogDetailsType"u8)) + if (prop.NameEquals("verboseLogLink"u8)) { - copyLogDetailsType = property.Value.GetString().ToDataBoxOrderType(); + verboseLogLink = 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 DataBoxDiskCopyLogDetails(copyLogDetailsType, serializedAdditionalRawData, diskSerialNumber, errorLogLink, verboseLogLink); + return new DataBoxDiskCopyLogDetails(copyLogDetailsType, additionalBinaryDataProperties, diskSerialNumber, errorLogLink, verboseLogLink); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO } } - DataBoxDiskCopyLogDetails 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. + DataBoxDiskCopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxDiskCopyLogDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override CopyLogDetails 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 DeserializeDataBoxDiskCopyLogDetails(document.RootElement, options); } default: @@ -138,6 +149,7 @@ DataBoxDiskCopyLogDetails IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.cs index 048847427467..b23db883c1bc 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyLogDetails.cs @@ -14,29 +14,29 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxDiskCopyLogDetails : CopyLogDetails { /// Initializes a new instance of . - internal DataBoxDiskCopyLogDetails() + internal DataBoxDiskCopyLogDetails() : base(DataBoxOrderType.DataBoxDisk) { - CopyLogDetailsType = DataBoxOrderType.DataBoxDisk; } /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Disk Serial Number. /// Link for copy error logs. /// Link for copy verbose logs. - internal DataBoxDiskCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData, string diskSerialNumber, string errorLogLink, string verboseLogLink) : base(copyLogDetailsType, serializedAdditionalRawData) + internal DataBoxDiskCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties, string diskSerialNumber, string errorLogLink, string verboseLogLink) : base(copyLogDetailsType, additionalBinaryDataProperties) { DiskSerialNumber = diskSerialNumber; ErrorLogLink = errorLogLink; VerboseLogLink = verboseLogLink; - CopyLogDetailsType = copyLogDetailsType; } /// Disk Serial Number. public string DiskSerialNumber { get; } + /// Link for copy error logs. public string ErrorLogLink { get; } + /// Link for copy verbose logs. public string VerboseLogLink { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.Serialization.cs index c431e644669a..36b8ed49d719 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxDiskCopyProgress : IUtf8JsonSerializable, IJsonModel + /// DataBox Disk Copy Progress. + public partial class DataBoxDiskCopyProgress : 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(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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(DataBoxDiskCopyProgress)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(SerialNumber)) { writer.WritePropertyName("serialNumber"u8); @@ -64,21 +65,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("actions"u8); writer.WriteStartArray(); - foreach (var item in Actions) + foreach (CustomerResolutionCode item in Actions) { writer.WriteStringValue(item.ToSerialString()); } 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); } @@ -87,22 +88,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxDiskCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxDiskCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxDiskCopyProgress 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(DataBoxDiskCopyProgress)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxDiskCopyProgress(document.RootElement, options); } - internal static DataBoxDiskCopyProgress DeserializeDataBoxDiskCopyProgress(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxDiskCopyProgress DeserializeDataBoxDiskCopyProgress(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -113,59 +119,58 @@ internal static DataBoxDiskCopyProgress DeserializeDataBoxDiskCopyProgress(JsonE DataBoxCopyStatus? status = default; ResponseError error = default; IReadOnlyList actions = 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("serialNumber"u8)) + if (prop.NameEquals("serialNumber"u8)) { - serialNumber = property.Value.GetString(); + serialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("bytesCopied"u8)) + if (prop.NameEquals("bytesCopied"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - bytesCopied = property.Value.GetInt64(); + bytesCopied = prop.Value.GetInt64(); continue; } - if (property.NameEquals("percentComplete"u8)) + if (prop.NameEquals("percentComplete"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - percentComplete = property.Value.GetInt32(); + percentComplete = prop.Value.GetInt32(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new DataBoxCopyStatus(property.Value.GetString()); + status = new DataBoxCopyStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("actions"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().ToCustomerResolutionCode()); } @@ -174,10 +179,9 @@ internal static DataBoxDiskCopyProgress DeserializeDataBoxDiskCopyProgress(JsonE } 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 DataBoxDiskCopyProgress( serialNumber, bytesCopied, @@ -185,13 +189,16 @@ internal static DataBoxDiskCopyProgress DeserializeDataBoxDiskCopyProgress(JsonE status, error, actions ?? new ChangeTrackingList(), - 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": @@ -201,15 +208,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - DataBoxDiskCopyProgress 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. + DataBoxDiskCopyProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxDiskCopyProgress 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 DeserializeDataBoxDiskCopyProgress(document.RootElement, options); } default: @@ -217,6 +229,7 @@ DataBoxDiskCopyProgress IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.cs index 102b70dec76b..e0fb4394bae3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskCopyProgress.cs @@ -7,43 +7,16 @@ using System; using System.Collections.Generic; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// DataBox Disk Copy Progress. public partial class DataBoxDiskCopyProgress { - /// - /// 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 DataBoxDiskCopyProgress() @@ -58,8 +31,8 @@ internal DataBoxDiskCopyProgress() /// The Status of the copy. /// Error, if any, in the stage. /// Available actions on the job. - /// Keeps track of any properties unknown to the library. - internal DataBoxDiskCopyProgress(string serialNumber, long? bytesCopied, int? percentComplete, DataBoxCopyStatus? status, ResponseError error, IReadOnlyList actions, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxDiskCopyProgress(string serialNumber, long? bytesCopied, int? percentComplete, DataBoxCopyStatus? status, ResponseError error, IReadOnlyList actions, IDictionary additionalBinaryDataProperties) { SerialNumber = serialNumber; BytesCopied = bytesCopied; @@ -67,19 +40,24 @@ internal DataBoxDiskCopyProgress(string serialNumber, long? bytesCopied, int? pe Status = status; Error = error; Actions = actions; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The serial number of the disk. public string SerialNumber { get; } + /// Bytes copied during the copy of disk. public long? BytesCopied { get; } + /// Indicates the percentage completed for the copy of the disk. public int? PercentComplete { get; } + /// The Status of the copy. public DataBoxCopyStatus? Status { get; } + /// Error, if any, in the stage. public ResponseError Error { get; } + /// Available actions on the job. public IReadOnlyList Actions { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.Serialization.cs index 2b5b35b8cbad..87631a3fb16c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxDiskGranularCopyLogDetails : IUtf8JsonSerializable, IJsonModel + /// Granular Copy Log Details for customer disk. + public partial class DataBoxDiskGranularCopyLogDetails : GranularCopyLogDetails, 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, /// 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(DataBoxDiskGranularCopyLogDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(SerialNumber)) { @@ -57,83 +58,89 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxDiskGranularCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxDiskGranularCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxDiskGranularCopyLogDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override GranularCopyLogDetails 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(DataBoxDiskGranularCopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxDiskGranularCopyLogDetails(document.RootElement, options); } - internal static DataBoxDiskGranularCopyLogDetails DeserializeDataBoxDiskGranularCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxDiskGranularCopyLogDetails DeserializeDataBoxDiskGranularCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxOrderType copyLogDetailsType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string serialNumber = default; ResourceIdentifier accountId = default; string errorLogLink = default; string verboseLogLink = default; - DataBoxOrderType copyLogDetailsType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("serialNumber"u8)) + if (prop.NameEquals("copyLogDetailsType"u8)) { - serialNumber = property.Value.GetString(); + copyLogDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("accountId"u8)) + if (prop.NameEquals("serialNumber"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - accountId = new ResourceIdentifier(property.Value.GetString()); + serialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("errorLogLink"u8)) + if (prop.NameEquals("accountId"u8)) { - errorLogLink = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + accountId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("verboseLogLink"u8)) + if (prop.NameEquals("errorLogLink"u8)) { - verboseLogLink = property.Value.GetString(); + errorLogLink = prop.Value.GetString(); continue; } - if (property.NameEquals("copyLogDetailsType"u8)) + if (prop.NameEquals("verboseLogLink"u8)) { - copyLogDetailsType = property.Value.GetString().ToDataBoxOrderType(); + verboseLogLink = 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 DataBoxDiskGranularCopyLogDetails( copyLogDetailsType, - serializedAdditionalRawData, + additionalBinaryDataProperties, serialNumber, accountId, errorLogLink, verboseLogLink); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -143,15 +150,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - DataBoxDiskGranularCopyLogDetails 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. + DataBoxDiskGranularCopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxDiskGranularCopyLogDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override GranularCopyLogDetails 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 DeserializeDataBoxDiskGranularCopyLogDetails(document.RootElement, options); } default: @@ -159,6 +171,7 @@ DataBoxDiskGranularCopyLogDetails IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.cs index 6294cd67e782..ad8a8b2f089c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyLogDetails.cs @@ -15,33 +15,34 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxDiskGranularCopyLogDetails : GranularCopyLogDetails { /// Initializes a new instance of . - internal DataBoxDiskGranularCopyLogDetails() + internal DataBoxDiskGranularCopyLogDetails() : base(DataBoxOrderType.DataBoxCustomerDisk) { - CopyLogDetailsType = DataBoxOrderType.DataBoxCustomerDisk; } /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Disk Serial Number. /// Account id. /// Link for copy error logs. /// Link for copy verbose logs. - internal DataBoxDiskGranularCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData, string serialNumber, ResourceIdentifier accountId, string errorLogLink, string verboseLogLink) : base(copyLogDetailsType, serializedAdditionalRawData) + internal DataBoxDiskGranularCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties, string serialNumber, ResourceIdentifier accountId, string errorLogLink, string verboseLogLink) : base(copyLogDetailsType, additionalBinaryDataProperties) { SerialNumber = serialNumber; AccountId = accountId; ErrorLogLink = errorLogLink; VerboseLogLink = verboseLogLink; - CopyLogDetailsType = copyLogDetailsType; } /// Disk Serial Number. public string SerialNumber { get; } + /// Account id. public ResourceIdentifier AccountId { get; } + /// Link for copy error logs. public string ErrorLogLink { get; } + /// Link for copy verbose logs. public string VerboseLogLink { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.Serialization.cs index bfc9f98e6349..cf78463aa5ff 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.Serialization.cs @@ -10,14 +10,17 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxDiskGranularCopyProgress : IUtf8JsonSerializable, IJsonModel + /// DataBox Disk Granular Copy Progress. + public partial class DataBoxDiskGranularCopyProgress : GranularCopyProgress, 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(); @@ -29,12 +32,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// 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(DataBoxDiskGranularCopyProgress)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(SerialNumber)) { @@ -48,28 +50,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxDiskGranularCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxDiskGranularCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxDiskGranularCopyProgress)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override GranularCopyProgress 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(DataBoxDiskGranularCopyProgress)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxDiskGranularCopyProgress(document.RootElement, options); } - internal static DataBoxDiskGranularCopyProgress DeserializeDataBoxDiskGranularCopyProgress(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxDiskGranularCopyProgress DeserializeDataBoxDiskGranularCopyProgress(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string serialNumber = default; - DataBoxCopyStatus? copyStatus = default; string storageAccountName = default; DataBoxJobTransferType? transferType = default; DataAccountType? dataAccountType = default; @@ -87,184 +92,184 @@ internal static DataBoxDiskGranularCopyProgress DeserializeDataBoxDiskGranularCo bool? isEnumerationInProgress = default; ResponseError error = default; IReadOnlyList actions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serialNumber = default; + DataBoxCopyStatus? copyStatus = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("serialNumber"u8)) + if (prop.NameEquals("storageAccountName"u8)) { - serialNumber = property.Value.GetString(); + storageAccountName = prop.Value.GetString(); continue; } - if (property.NameEquals("copyStatus"u8)) + if (prop.NameEquals("transferType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - copyStatus = new DataBoxCopyStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("storageAccountName"u8)) - { - storageAccountName = property.Value.GetString(); + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); continue; } - if (property.NameEquals("transferType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferType = property.Value.GetString().ToDataBoxJobTransferType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("dataAccountType"u8)) + if (prop.NameEquals("accountId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataAccountType = property.Value.GetString().ToDataAccountType(); + accountId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("accountId"u8)) + if (prop.NameEquals("bytesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - accountId = new ResourceIdentifier(property.Value.GetString()); + bytesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("bytesProcessed"u8)) + if (prop.NameEquals("totalBytesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - bytesProcessed = property.Value.GetInt64(); + totalBytesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalBytesToProcess"u8)) + if (prop.NameEquals("filesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalBytesToProcess = property.Value.GetInt64(); + filesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesProcessed"u8)) + if (prop.NameEquals("totalFilesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesProcessed = property.Value.GetInt64(); + totalFilesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalFilesToProcess"u8)) + if (prop.NameEquals("invalidFilesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalFilesToProcess = property.Value.GetInt64(); + invalidFilesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFilesProcessed"u8)) + if (prop.NameEquals("invalidFileBytesUploaded"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFilesProcessed = property.Value.GetInt64(); + invalidFileBytesUploaded = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFileBytesUploaded"u8)) + if (prop.NameEquals("renamedContainerCount"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFileBytesUploaded = property.Value.GetInt64(); + renamedContainerCount = prop.Value.GetInt64(); continue; } - if (property.NameEquals("renamedContainerCount"u8)) + if (prop.NameEquals("filesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - renamedContainerCount = property.Value.GetInt64(); + filesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesErroredOut"u8)) + if (prop.NameEquals("directoriesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesErroredOut = property.Value.GetInt64(); + directoriesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("directoriesErroredOut"u8)) + if (prop.NameEquals("invalidDirectoriesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - directoriesErroredOut = property.Value.GetInt64(); + invalidDirectoriesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidDirectoriesProcessed"u8)) + if (prop.NameEquals("isEnumerationInProgress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidDirectoriesProcessed = property.Value.GetInt64(); + isEnumerationInProgress = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("isEnumerationInProgress"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isEnumerationInProgress = property.Value.GetBoolean(); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("actions"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetString().ToCustomerResolutionCode()); + } + actions = array; + continue; + } + if (prop.NameEquals("serialNumber"u8)) + { + serialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("copyStatus"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()) - { - array.Add(item.GetString().ToCustomerResolutionCode()); - } - actions = array; + copyStatus = new DataBoxCopyStatus(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 DataBoxDiskGranularCopyProgress( storageAccountName, transferType, @@ -283,15 +288,18 @@ internal static DataBoxDiskGranularCopyProgress DeserializeDataBoxDiskGranularCo isEnumerationInProgress, error, actions ?? new ChangeTrackingList(), - serializedAdditionalRawData, + additionalBinaryDataProperties, serialNumber, copyStatus); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -301,15 +309,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DataBoxDiskGranularCopyProgress 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. + DataBoxDiskGranularCopyProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxDiskGranularCopyProgress)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override GranularCopyProgress 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 DeserializeDataBoxDiskGranularCopyProgress(document.RootElement, options); } default: @@ -317,6 +330,7 @@ DataBoxDiskGranularCopyProgress IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.cs index 32f3bf372216..2c65328df4ae 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskGranularCopyProgress.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure; using Azure.Core; namespace Azure.ResourceManager.DataBox.Models @@ -40,10 +41,10 @@ internal DataBoxDiskGranularCopyProgress() /// /// Error, if any, in the stage. /// Available actions on the job. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Disk Serial Number. /// The Status of the copy. - internal DataBoxDiskGranularCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary serializedAdditionalRawData, string serialNumber, DataBoxCopyStatus? copyStatus) : base(storageAccountName, transferType, dataAccountType, accountId, bytesProcessed, totalBytesToProcess, filesProcessed, totalFilesToProcess, invalidFilesProcessed, invalidFileBytesUploaded, renamedContainerCount, filesErroredOut, directoriesErroredOut, invalidDirectoriesProcessed, isEnumerationInProgress, error, actions, serializedAdditionalRawData) + internal DataBoxDiskGranularCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary additionalBinaryDataProperties, string serialNumber, DataBoxCopyStatus? copyStatus) : base(storageAccountName, transferType, dataAccountType, accountId, bytesProcessed, totalBytesToProcess, filesProcessed, totalFilesToProcess, invalidFilesProcessed, invalidFileBytesUploaded, renamedContainerCount, filesErroredOut, directoriesErroredOut, invalidDirectoriesProcessed, isEnumerationInProgress, error, actions, additionalBinaryDataProperties) { SerialNumber = serialNumber; CopyStatus = copyStatus; @@ -51,6 +52,7 @@ internal DataBoxDiskGranularCopyProgress(string storageAccountName, DataBoxJobTr /// Disk Serial Number. public string SerialNumber { get; } + /// The Status of the copy. public DataBoxCopyStatus? CopyStatus { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.Serialization.cs index 67b7601f1ee8..76f37db3c525 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxDiskJobDetails : IUtf8JsonSerializable, IJsonModel + /// DataBox Disk Job Details. + public partial class DataBoxDiskJobDetails : DataBoxBasicJobDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxDiskJobDetails() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderW /// 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(DataBoxDiskJobDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(PreferredDisks)) { @@ -50,7 +55,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("copyProgress"u8); writer.WriteStartArray(); - foreach (var item in CopyProgress) + foreach (DataBoxDiskCopyProgress item in CopyProgress) { writer.WriteObjectValue(item, options); } @@ -60,7 +65,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("granularCopyProgress"u8); writer.WriteStartArray(); - foreach (var item in GranularCopyProgress) + foreach (DataBoxDiskGranularCopyProgress item in GranularCopyProgress) { writer.WriteObjectValue(item, options); } @@ -70,7 +75,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("granularCopyLogDetails"u8); writer.WriteStartArray(); - foreach (var item in GranularCopyLogDetails) + foreach (DataBoxDiskGranularCopyLogDetails item in GranularCopyLogDetails) { writer.WriteObjectValue(item, options); } @@ -94,32 +99,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxDiskJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxDiskJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxDiskJobDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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(DataBoxDiskJobDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxDiskJobDetails(document.RootElement, options); } - internal static DataBoxDiskJobDetails DeserializeDataBoxDiskJobDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxDiskJobDetails DeserializeDataBoxDiskJobDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IDictionary preferredDisks = default; - IReadOnlyList copyProgress = default; - IReadOnlyList granularCopyProgress = default; - IReadOnlyList granularCopyLogDetails = default; - IReadOnlyDictionary disksAndSizeDetails = default; - string passkey = default; IReadOnlyList jobStages = default; DataBoxContactDetails contactDetails = default; DataBoxShippingAddress shippingAddress = default; @@ -135,285 +139,289 @@ internal static DataBoxDiskJobDetails DeserializeDataBoxDiskJobDetails(JsonEleme string chainOfCustodySasKey = default; DeviceErasureDetails deviceErasureDetails = default; DataBoxKeyEncryptionKey keyEncryptionKey = default; - int? expectedDataSizeInTeraBytes = default; + int? expectedDataSizeInTerabytes = default; IReadOnlyList actions = default; LastMitigationActionOnJob lastMitigationActionOnJob = default; - DataCenterAddressResult datacenterAddress = default; + DataCenterAddressResult dataCenterAddress = default; DataCenterCode? dataCenterCode = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary preferredDisks = default; + IReadOnlyList copyProgress = default; + IReadOnlyList granularCopyProgress = default; + IReadOnlyList granularCopyLogDetails = default; + IReadOnlyDictionary disksAndSizeDetails = default; + string passkey = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("preferredDisks"u8)) + if (prop.NameEquals("jobStages"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - dictionary.Add(property0.Name, property0.Value.GetInt32()); + array.Add(DataBoxJobStage.DeserializeDataBoxJobStage(item, options)); } - preferredDisks = dictionary; + jobStages = array; + continue; + } + if (prop.NameEquals("contactDetails"u8)) + { + contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(prop.Value, options); continue; } - if (property.NameEquals("copyProgress"u8)) + if (prop.NameEquals("shippingAddress"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()) - { - array.Add(DataBoxDiskCopyProgress.DeserializeDataBoxDiskCopyProgress(item, options)); - } - copyProgress = array; + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("granularCopyProgress"u8)) + if (prop.NameEquals("deliveryPackage"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()) - { - array.Add(DataBoxDiskGranularCopyProgress.DeserializeDataBoxDiskGranularCopyProgress(item, options)); - } - granularCopyProgress = array; + deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("granularCopyLogDetails"u8)) + if (prop.NameEquals("returnPackage"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()) - { - array.Add(DataBoxDiskGranularCopyLogDetails.DeserializeDataBoxDiskGranularCopyLogDetails(item, options)); - } - granularCopyLogDetails = array; + returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("disksAndSizeDetails"u8)) + if (prop.NameEquals("dataImportDetails"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - dictionary.Add(property0.Name, property0.Value.GetInt32()); + array.Add(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); } - disksAndSizeDetails = dictionary; - continue; - } - if (property.NameEquals("passkey"u8)) - { - passkey = property.Value.GetString(); + dataImportDetails = array; continue; } - if (property.NameEquals("jobStages"u8)) + if (prop.NameEquals("dataExportDetails"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(DataBoxJobStage.DeserializeDataBoxJobStage(item, options)); + array.Add(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); } - jobStages = array; - continue; - } - if (property.NameEquals("contactDetails"u8)) - { - contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(property.Value, options); + dataExportDetails = array; continue; } - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("jobDetailsType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + jobDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("deliveryPackage"u8)) + if (prop.NameEquals("preferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(prop.Value, options); continue; } - if (property.NameEquals("returnPackage"u8)) + if (prop.NameEquals("reverseShippingDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("dataImportDetails"u8)) + if (prop.NameEquals("copyLogDetails"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); + array.Add(Models.CopyLogDetails.DeserializeCopyLogDetails(item, options)); } - dataImportDetails = array; + copyLogDetails = array; continue; } - if (property.NameEquals("dataExportDetails"u8)) + if (prop.NameEquals("reverseShipmentLabelSasKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); - } - dataExportDetails = array; + reverseShipmentLabelSasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("jobDetailsType"u8)) + if (prop.NameEquals("chainOfCustodySasKey"u8)) { - jobDetailsType = property.Value.GetString().ToDataBoxOrderType(); + chainOfCustodySasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("preferences"u8)) + if (prop.NameEquals("deviceErasureDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(property.Value, options); + deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(prop.Value, options); continue; } - if (property.NameEquals("reverseShippingDetails"u8)) + if (prop.NameEquals("keyEncryptionKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(property.Value, options); + keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(prop.Value, options); continue; } - if (property.NameEquals("copyLogDetails"u8)) + if (prop.NameEquals("expectedDataSizeInTeraBytes"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()) - { - array.Add(Models.CopyLogDetails.DeserializeCopyLogDetails(item, options)); - } - copyLogDetails = array; + expectedDataSizeInTerabytes = prop.Value.GetInt32(); continue; } - if (property.NameEquals("reverseShipmentLabelSasKey"u8)) + if (prop.NameEquals("actions"u8)) { - reverseShipmentLabelSasKey = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetString().ToCustomerResolutionCode()); + } + actions = array; continue; } - if (property.NameEquals("chainOfCustodySasKey"u8)) + if (prop.NameEquals("lastMitigationActionOnJob"u8)) { - chainOfCustodySasKey = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(prop.Value, options); continue; } - if (property.NameEquals("deviceErasureDetails"u8)) + if (prop.NameEquals("datacenterAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(property.Value, options); + dataCenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(prop.Value, options); continue; } - if (property.NameEquals("keyEncryptionKey"u8)) + if (prop.NameEquals("dataCenterCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(property.Value, options); + dataCenterCode = new DataCenterCode(prop.Value.GetString()); continue; } - if (property.NameEquals("expectedDataSizeInTeraBytes"u8)) + if (prop.NameEquals("preferredDisks"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expectedDataSizeInTeraBytes = property.Value.GetInt32(); + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, prop0.Value.GetInt32()); + } + preferredDisks = dictionary; continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("copyProgress"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()) + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString().ToCustomerResolutionCode()); + array.Add(DataBoxDiskCopyProgress.DeserializeDataBoxDiskCopyProgress(item, options)); } - actions = array; + copyProgress = array; continue; } - if (property.NameEquals("lastMitigationActionOnJob"u8)) + if (prop.NameEquals("granularCopyProgress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(property.Value, options); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxDiskGranularCopyProgress.DeserializeDataBoxDiskGranularCopyProgress(item, options)); + } + granularCopyProgress = array; continue; } - if (property.NameEquals("datacenterAddress"u8)) + if (prop.NameEquals("granularCopyLogDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datacenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(property.Value, options); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxDiskGranularCopyLogDetails.DeserializeDataBoxDiskGranularCopyLogDetails(item, options)); + } + granularCopyLogDetails = array; continue; } - if (property.NameEquals("dataCenterCode"u8)) + if (prop.NameEquals("disksAndSizeDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataCenterCode = new DataCenterCode(property.Value.GetString()); + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, prop0.Value.GetInt32()); + } + disksAndSizeDetails = dictionary; + continue; + } + if (prop.NameEquals("passkey"u8)) + { + passkey = 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 DataBoxDiskJobDetails( jobStages ?? new ChangeTrackingList(), contactDetails, @@ -430,12 +438,12 @@ internal static DataBoxDiskJobDetails DeserializeDataBoxDiskJobDetails(JsonEleme chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, - expectedDataSizeInTeraBytes, + expectedDataSizeInTerabytes, actions ?? new ChangeTrackingList(), lastMitigationActionOnJob, - datacenterAddress, + dataCenterAddress, dataCenterCode, - serializedAdditionalRawData, + additionalBinaryDataProperties, preferredDisks ?? new ChangeTrackingDictionary(), copyProgress ?? new ChangeTrackingList(), granularCopyProgress ?? new ChangeTrackingList(), @@ -444,10 +452,13 @@ internal static DataBoxDiskJobDetails DeserializeDataBoxDiskJobDetails(JsonEleme passkey); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -457,15 +468,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - DataBoxDiskJobDetails 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. + DataBoxDiskJobDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxDiskJobDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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 DeserializeDataBoxDiskJobDetails(document.RootElement, options); } default: @@ -473,6 +489,7 @@ DataBoxDiskJobDetails IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.cs index 1a3cff977159..55792df34e21 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobDetails.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -16,7 +17,7 @@ public partial class DataBoxDiskJobDetails : DataBoxBasicJobDetails /// Initializes a new instance of . /// Contact details for notification and shipping. /// is null. - public DataBoxDiskJobDetails(DataBoxContactDetails contactDetails) : base(contactDetails) + public DataBoxDiskJobDetails(DataBoxContactDetails contactDetails) : base(contactDetails, DataBoxOrderType.DataBoxDisk) { Argument.AssertNotNull(contactDetails, nameof(contactDetails)); @@ -25,7 +26,6 @@ public DataBoxDiskJobDetails(DataBoxContactDetails contactDetails) : base(contac GranularCopyProgress = new ChangeTrackingList(); GranularCopyLogDetails = new ChangeTrackingList(); DisksAndSizeDetails = new ChangeTrackingDictionary(); - JobDetailsType = DataBoxOrderType.DataBoxDisk; } /// Initializes a new instance of . @@ -39,11 +39,7 @@ public DataBoxDiskJobDetails(DataBoxContactDetails contactDetails) : base(contac /// Indicates the type of job details. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -51,20 +47,16 @@ public DataBoxDiskJobDetails(DataBoxContactDetails contactDetails) : base(contac /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// User preference on what size disks are needed for the job. The map is from the disk size in TB to the count. Eg. {2,5} means 5 disks of 2 TB size. Key is string but will be checked against an int. /// Copy progress per disk. /// Copy progress per disk. /// Copy progress per disk. /// Contains the map of disk serial number to the disk size being used for the job. Is returned only after the disks are shipped to the customer. /// User entered passkey for DataBox Disk job. - internal DataBoxDiskJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary serializedAdditionalRawData, IDictionary preferredDisks, IReadOnlyList copyProgress, IReadOnlyList granularCopyProgress, IReadOnlyList granularCopyLogDetails, IReadOnlyDictionary disksAndSizeDetails, string passkey) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, serializedAdditionalRawData) + internal DataBoxDiskJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary additionalBinaryDataProperties, IDictionary preferredDisks, IReadOnlyList copyProgress, IReadOnlyList granularCopyProgress, IReadOnlyList granularCopyLogDetails, IReadOnlyDictionary disksAndSizeDetails, string passkey) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, additionalBinaryDataProperties) { PreferredDisks = preferredDisks; CopyProgress = copyProgress; @@ -72,24 +64,23 @@ internal DataBoxDiskJobDetails(IReadOnlyList jobStages, DataBox GranularCopyLogDetails = granularCopyLogDetails; DisksAndSizeDetails = disksAndSizeDetails; Passkey = passkey; - JobDetailsType = jobDetailsType; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxDiskJobDetails() - { } /// User preference on what size disks are needed for the job. The map is from the disk size in TB to the count. Eg. {2,5} means 5 disks of 2 TB size. Key is string but will be checked against an int. public IDictionary PreferredDisks { get; } + /// Copy progress per disk. public IReadOnlyList CopyProgress { get; } + /// Copy progress per disk. public IReadOnlyList GranularCopyProgress { get; } + /// Copy progress per disk. public IReadOnlyList GranularCopyLogDetails { get; } + /// Contains the map of disk serial number to the disk size being used for the job. Is returned only after the disks are shipped to the customer. public IReadOnlyDictionary DisksAndSizeDetails { get; } + /// User entered passkey for DataBox Disk job. public string Passkey { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.Serialization.cs index 4a3689a0e824..8c51f73c0e94 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxDiskJobSecrets : IUtf8JsonSerializable, IJsonModel + /// The secrets related to disk job. + public partial class DataBoxDiskJobSecrets : JobSecrets, 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(); @@ -29,18 +31,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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(DataBoxDiskJobSecrets)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsCollectionDefined(DiskSecrets)) { writer.WritePropertyName("diskSecrets"u8); writer.WriteStartArray(); - foreach (var item in DiskSecrets) + foreach (DataBoxDiskSecret item in DiskSecrets) { writer.WriteObjectValue(item, options); } @@ -58,107 +59,113 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxDiskJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxDiskJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxDiskJobSecrets)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override JobSecrets 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(DataBoxDiskJobSecrets)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxDiskJobSecrets(document.RootElement, options); } - internal static DataBoxDiskJobSecrets DeserializeDataBoxDiskJobSecrets(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxDiskJobSecrets DeserializeDataBoxDiskJobSecrets(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList diskSecrets = default; - string passKey = default; - bool? isPasskeyUserDefined = default; DataBoxOrderType jobSecretsType = default; - DataCenterAccessSecurityCode dcAccessSecurityCode = default; + DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IReadOnlyList diskSecrets = default; + string passkey = default; + bool? isPasskeyUserDefined = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("diskSecrets"u8)) + if (prop.NameEquals("jobSecretsType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DataBoxDiskSecret.DeserializeDataBoxDiskSecret(item, options)); - } - diskSecrets = array; + jobSecretsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("passKey"u8)) + if (prop.NameEquals("dcAccessSecurityCode"u8)) { - passKey = property.Value.GetString(); - continue; - } - if (property.NameEquals("isPasskeyUserDefined"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isPasskeyUserDefined = property.Value.GetBoolean(); + dataCenterAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(prop.Value, options); continue; } - if (property.NameEquals("jobSecretsType"u8)) + if (prop.NameEquals("error"u8)) { - jobSecretsType = property.Value.GetString().ToDataBoxOrderType(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("dcAccessSecurityCode"u8)) + if (prop.NameEquals("diskSecrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dcAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(property.Value, options); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxDiskSecret.DeserializeDataBoxDiskSecret(item, options)); + } + diskSecrets = array; + continue; + } + if (prop.NameEquals("passKey"u8)) + { + passkey = prop.Value.GetString(); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("isPasskeyUserDefined"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + isPasskeyUserDefined = prop.Value.GetBoolean(); 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 DataBoxDiskJobSecrets( jobSecretsType, - dcAccessSecurityCode, + dataCenterAccessSecurityCode, error, - serializedAdditionalRawData, + additionalBinaryDataProperties, diskSecrets ?? new ChangeTrackingList(), - passKey, + passkey, isPasskeyUserDefined); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -168,15 +175,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - DataBoxDiskJobSecrets 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. + DataBoxDiskJobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxDiskJobSecrets)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override JobSecrets 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 DeserializeDataBoxDiskJobSecrets(document.RootElement, options); } default: @@ -184,6 +196,7 @@ DataBoxDiskJobSecrets IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.cs index 67084c3897f8..5596563effcc 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskJobSecrets.cs @@ -7,6 +7,8 @@ using System; using System.Collections.Generic; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,32 +16,32 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxDiskJobSecrets : JobSecrets { /// Initializes a new instance of . - internal DataBoxDiskJobSecrets() + internal DataBoxDiskJobSecrets() : base(DataBoxOrderType.DataBoxDisk) { DiskSecrets = new ChangeTrackingList(); - JobSecretsType = DataBoxOrderType.DataBoxDisk; } /// Initializes a new instance of . /// Used to indicate what type of job secrets object. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Contains the list of secrets object for that device. /// PassKey for the disk Job. /// Whether passkey was provided by user. - internal DataBoxDiskJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary serializedAdditionalRawData, IReadOnlyList diskSecrets, string passkey, bool? isPasskeyUserDefined) : base(jobSecretsType, dataCenterAccessSecurityCode, error, serializedAdditionalRawData) + internal DataBoxDiskJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary additionalBinaryDataProperties, IReadOnlyList diskSecrets, string passkey, bool? isPasskeyUserDefined) : base(jobSecretsType, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties) { DiskSecrets = diskSecrets; Passkey = passkey; IsPasskeyUserDefined = isPasskeyUserDefined; - JobSecretsType = jobSecretsType; } /// Contains the list of secrets object for that device. public IReadOnlyList DiskSecrets { get; } + /// PassKey for the disk Job. public string Passkey { get; } + /// Whether passkey was provided by user. public bool? IsPasskeyUserDefined { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.Serialization.cs index 179d425f4d1e..6197176014a9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxDiskSecret : IUtf8JsonSerializable, IJsonModel + /// Contains all the secrets of a Disk. + public partial class DataBoxDiskSecret : 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, ModelReaderWrite /// 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(DataBoxDiskSecret)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(DiskSerialNumber)) { writer.WritePropertyName("diskSerialNumber"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("bitLockerKey"u8); writer.WriteStringValue(BitLockerKey); } - 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,55 +61,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxDiskSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxDiskSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxDiskSecret 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(DataBoxDiskSecret)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxDiskSecret(document.RootElement, options); } - internal static DataBoxDiskSecret DeserializeDataBoxDiskSecret(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxDiskSecret DeserializeDataBoxDiskSecret(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string diskSerialNumber = default; string bitLockerKey = 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("diskSerialNumber"u8)) + if (prop.NameEquals("diskSerialNumber"u8)) { - diskSerialNumber = property.Value.GetString(); + diskSerialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("bitLockerKey"u8)) + if (prop.NameEquals("bitLockerKey"u8)) { - bitLockerKey = property.Value.GetString(); + bitLockerKey = 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 DataBoxDiskSecret(diskSerialNumber, bitLockerKey, serializedAdditionalRawData); + return new DataBoxDiskSecret(diskSerialNumber, bitLockerKey, 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": @@ -119,15 +125,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - DataBoxDiskSecret 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. + DataBoxDiskSecret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxDiskSecret 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 DeserializeDataBoxDiskSecret(document.RootElement, options); } default: @@ -135,6 +146,7 @@ DataBoxDiskSecret IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.cs index d487e08128e5..26a478de159b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDiskSecret.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Contains all the secrets of a Disk. public partial class DataBoxDiskSecret { - /// - /// 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 DataBoxDiskSecret() @@ -53,16 +24,17 @@ internal DataBoxDiskSecret() /// Initializes a new instance of . /// Serial number of the assigned disk. /// Bit Locker key of the disk which can be used to unlock the disk to copy data. - /// Keeps track of any properties unknown to the library. - internal DataBoxDiskSecret(string diskSerialNumber, string bitLockerKey, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxDiskSecret(string diskSerialNumber, string bitLockerKey, IDictionary additionalBinaryDataProperties) { DiskSerialNumber = diskSerialNumber; BitLockerKey = bitLockerKey; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Serial number of the assigned disk. public string DiskSerialNumber { get; } + /// Bit Locker key of the disk which can be used to unlock the disk to copy data. public string BitLockerKey { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDoubleEncryption.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDoubleEncryption.Serialization.cs index b2a2e8a8c443..35ce3e19746a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDoubleEncryption.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxDoubleEncryption.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxDoubleEncryptionExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxDoubleEncryption value) => value switch { DataBoxDoubleEncryption.Enabled => "Enabled", @@ -18,10 +19,17 @@ internal static partial class DataBoxDoubleEncryptionExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxDoubleEncryption value.") }; + /// The value to deserialize. public static DataBoxDoubleEncryption ToDataBoxDoubleEncryption(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) return DataBoxDoubleEncryption.Enabled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) return DataBoxDoubleEncryption.Disabled; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) + { + return DataBoxDoubleEncryption.Enabled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) + { + return DataBoxDoubleEncryption.Disabled; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxDoubleEncryption value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.Serialization.cs index a0b6d01288a3..39acee1f5914 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxEncryptionPreferences : IUtf8JsonSerializable, IJsonModel + /// Preferences related to the Encryption. + public partial class DataBoxEncryptionPreferences : 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, Model /// 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(DataBoxEncryptionPreferences)} does not support writing '{format}' format."); } - if (Optional.IsDefined(DoubleEncryption)) { writer.WritePropertyName("doubleEncryption"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("hardwareEncryption"u8); writer.WriteStringValue(HardwareEncryption.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); } @@ -61,63 +61,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxEncryptionPreferences IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxEncryptionPreferences IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxEncryptionPreferences 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(DataBoxEncryptionPreferences)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxEncryptionPreferences(document.RootElement, options); } - internal static DataBoxEncryptionPreferences DeserializeDataBoxEncryptionPreferences(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxEncryptionPreferences DeserializeDataBoxEncryptionPreferences(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxDoubleEncryption? doubleEncryption = default; HardwareEncryption? hardwareEncryption = 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("doubleEncryption"u8)) + if (prop.NameEquals("doubleEncryption"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - doubleEncryption = property.Value.GetString().ToDataBoxDoubleEncryption(); + doubleEncryption = prop.Value.GetString().ToDataBoxDoubleEncryption(); continue; } - if (property.NameEquals("hardwareEncryption"u8)) + if (prop.NameEquals("hardwareEncryption"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - hardwareEncryption = property.Value.GetString().ToHardwareEncryption(); + hardwareEncryption = prop.Value.GetString().ToHardwareEncryption(); 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 DataBoxEncryptionPreferences(doubleEncryption, hardwareEncryption, serializedAdditionalRawData); + return new DataBoxEncryptionPreferences(doubleEncryption, hardwareEncryption, 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": @@ -127,15 +133,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - DataBoxEncryptionPreferences 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. + DataBoxEncryptionPreferences IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxEncryptionPreferences 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 DeserializeDataBoxEncryptionPreferences(document.RootElement, options); } default: @@ -143,6 +154,7 @@ DataBoxEncryptionPreferences IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.cs index 87cdbac1d5d5..7c1b1e865b20 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxEncryptionPreferences.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Preferences related to the Encryption. public partial class DataBoxEncryptionPreferences { - /// - /// 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 DataBoxEncryptionPreferences() @@ -53,16 +24,17 @@ public DataBoxEncryptionPreferences() /// Initializes a new instance of . /// Defines secondary layer of software-based encryption enablement. /// Defines Hardware level encryption (Only for disk). - /// Keeps track of any properties unknown to the library. - internal DataBoxEncryptionPreferences(DataBoxDoubleEncryption? doubleEncryption, HardwareEncryption? hardwareEncryption, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxEncryptionPreferences(DataBoxDoubleEncryption? doubleEncryption, HardwareEncryption? hardwareEncryption, IDictionary additionalBinaryDataProperties) { DoubleEncryption = doubleEncryption; HardwareEncryption = hardwareEncryption; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Defines secondary layer of software-based encryption enablement. public DataBoxDoubleEncryption? DoubleEncryption { get; set; } + /// Defines Hardware level encryption (Only for disk). public HardwareEncryption? HardwareEncryption { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.Serialization.cs index 853504483752..55b305693c2a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxHeavyAccountCopyLogDetails : IUtf8JsonSerializable, IJsonModel + /// Copy log details for a storage account for Databox heavy. + public partial class DataBoxHeavyAccountCopyLogDetails : CopyLogDetails, 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 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(DataBoxHeavyAccountCopyLogDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(AccountName)) { @@ -44,8 +44,13 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("copyLogLink"u8); writer.WriteStartArray(); - foreach (var item in CopyLogLink) + foreach (string item in CopyLogLink) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -54,93 +59,118 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("copyVerboseLogLink"u8); writer.WriteStartArray(); - foreach (var item in CopyVerboseLogLink) + foreach (string item in CopyVerboseLogLink) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); } } - DataBoxHeavyAccountCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxHeavyAccountCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxHeavyAccountCopyLogDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override CopyLogDetails 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(DataBoxHeavyAccountCopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxHeavyAccountCopyLogDetails(document.RootElement, options); } - internal static DataBoxHeavyAccountCopyLogDetails DeserializeDataBoxHeavyAccountCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxHeavyAccountCopyLogDetails DeserializeDataBoxHeavyAccountCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxOrderType copyLogDetailsType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string accountName = default; IReadOnlyList copyLogLink = default; IReadOnlyList copyVerboseLogLink = default; - DataBoxOrderType copyLogDetailsType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("accountName"u8)) + if (prop.NameEquals("copyLogDetailsType"u8)) + { + copyLogDetailsType = prop.Value.GetString().ToDataBoxOrderType(); + continue; + } + if (prop.NameEquals("accountName"u8)) { - accountName = property.Value.GetString(); + accountName = prop.Value.GetString(); continue; } - if (property.NameEquals("copyLogLink"u8)) + if (prop.NameEquals("copyLogLink"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()); + } } copyLogLink = array; continue; } - if (property.NameEquals("copyVerboseLogLink"u8)) + if (prop.NameEquals("copyVerboseLogLink"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()); + } } copyVerboseLogLink = array; continue; } - if (property.NameEquals("copyLogDetailsType"u8)) - { - copyLogDetailsType = property.Value.GetString().ToDataBoxOrderType(); - 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 DataBoxHeavyAccountCopyLogDetails(copyLogDetailsType, serializedAdditionalRawData, accountName, copyLogLink ?? new ChangeTrackingList(), copyVerboseLogLink ?? new ChangeTrackingList()); + return new DataBoxHeavyAccountCopyLogDetails(copyLogDetailsType, additionalBinaryDataProperties, accountName, copyLogLink ?? new ChangeTrackingList(), copyVerboseLogLink ?? new ChangeTrackingList()); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -150,15 +180,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - DataBoxHeavyAccountCopyLogDetails 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. + DataBoxHeavyAccountCopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxHeavyAccountCopyLogDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override CopyLogDetails 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 DeserializeDataBoxHeavyAccountCopyLogDetails(document.RootElement, options); } default: @@ -166,6 +201,7 @@ DataBoxHeavyAccountCopyLogDetails IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.cs index e58a4636b5ce..268e3827fa80 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyAccountCopyLogDetails.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,31 +15,31 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxHeavyAccountCopyLogDetails : CopyLogDetails { /// Initializes a new instance of . - internal DataBoxHeavyAccountCopyLogDetails() + internal DataBoxHeavyAccountCopyLogDetails() : base(DataBoxOrderType.DataBoxHeavy) { CopyLogLink = new ChangeTrackingList(); CopyVerboseLogLink = new ChangeTrackingList(); - CopyLogDetailsType = DataBoxOrderType.DataBoxHeavy; } /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Account name. /// Link for copy logs. /// Link for copy verbose logs. This will be set only when the LogCollectionLevel is set to verbose. - internal DataBoxHeavyAccountCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData, string accountName, IReadOnlyList copyLogLink, IReadOnlyList copyVerboseLogLink) : base(copyLogDetailsType, serializedAdditionalRawData) + internal DataBoxHeavyAccountCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties, string accountName, IReadOnlyList copyLogLink, IReadOnlyList copyVerboseLogLink) : base(copyLogDetailsType, additionalBinaryDataProperties) { AccountName = accountName; CopyLogLink = copyLogLink; CopyVerboseLogLink = copyVerboseLogLink; - CopyLogDetailsType = copyLogDetailsType; } /// Account name. public string AccountName { get; } + /// Link for copy logs. public IReadOnlyList CopyLogLink { get; } + /// Link for copy verbose logs. This will be set only when the LogCollectionLevel is set to verbose. public IReadOnlyList CopyVerboseLogLink { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.Serialization.cs index 2155bded0f65..fddc168b34d4 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxHeavyJobDetails : IUtf8JsonSerializable, IJsonModel + /// Databox Heavy Device Job Details. + public partial class DataBoxHeavyJobDetails : DataBoxBasicJobDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxHeavyJobDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,18 +34,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(DataBoxHeavyJobDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsCollectionDefined(CopyProgress)) { writer.WritePropertyName("copyProgress"u8); writer.WriteStartArray(); - foreach (var item in CopyProgress) + foreach (DataBoxCopyProgress item in CopyProgress) { writer.WriteObjectValue(item, options); } @@ -52,28 +57,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxHeavyJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxHeavyJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxHeavyJobDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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(DataBoxHeavyJobDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxHeavyJobDetails(document.RootElement, options); } - internal static DataBoxHeavyJobDetails DeserializeDataBoxHeavyJobDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxHeavyJobDetails DeserializeDataBoxHeavyJobDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList copyProgress = default; - string devicePassword = default; IReadOnlyList jobStages = default; DataBoxContactDetails contactDetails = default; DataBoxShippingAddress shippingAddress = default; @@ -89,229 +97,229 @@ internal static DataBoxHeavyJobDetails DeserializeDataBoxHeavyJobDetails(JsonEle string chainOfCustodySasKey = default; DeviceErasureDetails deviceErasureDetails = default; DataBoxKeyEncryptionKey keyEncryptionKey = default; - int? expectedDataSizeInTeraBytes = default; + int? expectedDataSizeInTerabytes = default; IReadOnlyList actions = default; LastMitigationActionOnJob lastMitigationActionOnJob = default; - DataCenterAddressResult datacenterAddress = default; + DataCenterAddressResult dataCenterAddress = default; DataCenterCode? dataCenterCode = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IReadOnlyList copyProgress = default; + string devicePassword = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("copyProgress"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DataBoxCopyProgress.DeserializeDataBoxCopyProgress(item, options)); - } - copyProgress = array; - continue; - } - if (property.NameEquals("devicePassword"u8)) + if (prop.NameEquals("jobStages"u8)) { - devicePassword = property.Value.GetString(); - continue; - } - if (property.NameEquals("jobStages"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(DataBoxJobStage.DeserializeDataBoxJobStage(item, options)); } jobStages = array; continue; } - if (property.NameEquals("contactDetails"u8)) + if (prop.NameEquals("contactDetails"u8)) { - contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(property.Value, options); + contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(prop.Value, options); continue; } - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("shippingAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("deliveryPackage"u8)) + if (prop.NameEquals("deliveryPackage"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("returnPackage"u8)) + if (prop.NameEquals("returnPackage"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("dataImportDetails"u8)) + if (prop.NameEquals("dataImportDetails"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(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); } dataImportDetails = array; continue; } - if (property.NameEquals("dataExportDetails"u8)) + if (prop.NameEquals("dataExportDetails"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(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); } dataExportDetails = array; continue; } - if (property.NameEquals("jobDetailsType"u8)) + if (prop.NameEquals("jobDetailsType"u8)) { - jobDetailsType = property.Value.GetString().ToDataBoxOrderType(); + jobDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("preferences"u8)) + if (prop.NameEquals("preferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(property.Value, options); + preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(prop.Value, options); continue; } - if (property.NameEquals("reverseShippingDetails"u8)) + if (prop.NameEquals("reverseShippingDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(property.Value, options); + reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("copyLogDetails"u8)) + if (prop.NameEquals("copyLogDetails"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(Models.CopyLogDetails.DeserializeCopyLogDetails(item, options)); } copyLogDetails = array; continue; } - if (property.NameEquals("reverseShipmentLabelSasKey"u8)) + if (prop.NameEquals("reverseShipmentLabelSasKey"u8)) { - reverseShipmentLabelSasKey = property.Value.GetString(); + reverseShipmentLabelSasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("chainOfCustodySasKey"u8)) + if (prop.NameEquals("chainOfCustodySasKey"u8)) { - chainOfCustodySasKey = property.Value.GetString(); + chainOfCustodySasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("deviceErasureDetails"u8)) + if (prop.NameEquals("deviceErasureDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(property.Value, options); + deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(prop.Value, options); continue; } - if (property.NameEquals("keyEncryptionKey"u8)) + if (prop.NameEquals("keyEncryptionKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(property.Value, options); + keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(prop.Value, options); continue; } - if (property.NameEquals("expectedDataSizeInTeraBytes"u8)) + if (prop.NameEquals("expectedDataSizeInTeraBytes"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expectedDataSizeInTeraBytes = property.Value.GetInt32(); + expectedDataSizeInTerabytes = prop.Value.GetInt32(); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("actions"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().ToCustomerResolutionCode()); } actions = array; continue; } - if (property.NameEquals("lastMitigationActionOnJob"u8)) + if (prop.NameEquals("lastMitigationActionOnJob"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(property.Value, options); + lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(prop.Value, options); continue; } - if (property.NameEquals("datacenterAddress"u8)) + if (prop.NameEquals("datacenterAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datacenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(property.Value, options); + dataCenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(prop.Value, options); continue; } - if (property.NameEquals("dataCenterCode"u8)) + if (prop.NameEquals("dataCenterCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataCenterCode = new DataCenterCode(property.Value.GetString()); + dataCenterCode = new DataCenterCode(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("copyProgress"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxCopyProgress.DeserializeDataBoxCopyProgress(item, options)); + } + copyProgress = array; + continue; + } + if (prop.NameEquals("devicePassword"u8)) + { + devicePassword = 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 DataBoxHeavyJobDetails( jobStages ?? new ChangeTrackingList(), contactDetails, @@ -328,20 +336,23 @@ internal static DataBoxHeavyJobDetails DeserializeDataBoxHeavyJobDetails(JsonEle chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, - expectedDataSizeInTeraBytes, + expectedDataSizeInTerabytes, actions ?? new ChangeTrackingList(), lastMitigationActionOnJob, - datacenterAddress, + dataCenterAddress, dataCenterCode, - serializedAdditionalRawData, + additionalBinaryDataProperties, copyProgress ?? new ChangeTrackingList(), devicePassword); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -351,15 +362,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - DataBoxHeavyJobDetails 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. + DataBoxHeavyJobDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxHeavyJobDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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 DeserializeDataBoxHeavyJobDetails(document.RootElement, options); } default: @@ -367,6 +383,7 @@ DataBoxHeavyJobDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.cs index 7827090bc2f9..842b98a9922b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobDetails.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -16,12 +17,11 @@ public partial class DataBoxHeavyJobDetails : DataBoxBasicJobDetails /// Initializes a new instance of . /// Contact details for notification and shipping. /// is null. - public DataBoxHeavyJobDetails(DataBoxContactDetails contactDetails) : base(contactDetails) + public DataBoxHeavyJobDetails(DataBoxContactDetails contactDetails) : base(contactDetails, DataBoxOrderType.DataBoxHeavy) { Argument.AssertNotNull(contactDetails, nameof(contactDetails)); CopyProgress = new ChangeTrackingList(); - JobDetailsType = DataBoxOrderType.DataBoxHeavy; } /// Initializes a new instance of . @@ -35,11 +35,7 @@ public DataBoxHeavyJobDetails(DataBoxContactDetails contactDetails) : base(conta /// Indicates the type of job details. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -47,29 +43,20 @@ public DataBoxHeavyJobDetails(DataBoxContactDetails contactDetails) : base(conta /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Copy progress per account. /// Set Device password for unlocking Databox Heavy. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. - internal DataBoxHeavyJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary serializedAdditionalRawData, IReadOnlyList copyProgress, string devicePassword) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, serializedAdditionalRawData) + internal DataBoxHeavyJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary additionalBinaryDataProperties, IReadOnlyList copyProgress, string devicePassword) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, additionalBinaryDataProperties) { CopyProgress = copyProgress; DevicePassword = devicePassword; - JobDetailsType = jobDetailsType; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxHeavyJobDetails() - { } /// Copy progress per account. public IReadOnlyList CopyProgress { get; } + /// Set Device password for unlocking Databox Heavy. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. public string DevicePassword { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.Serialization.cs index a0a30808a601..2c460f723bec 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxHeavyJobSecrets : IUtf8JsonSerializable, IJsonModel + /// The secrets related to a databox heavy job. + public partial class DataBoxHeavyJobSecrets : JobSecrets, 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(); @@ -29,18 +31,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(DataBoxHeavyJobSecrets)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsCollectionDefined(CabinetPodSecrets)) { writer.WritePropertyName("cabinetPodSecrets"u8); writer.WriteStartArray(); - foreach (var item in CabinetPodSecrets) + foreach (DataBoxHeavySecret item in CabinetPodSecrets) { writer.WriteObjectValue(item, options); } @@ -48,84 +49,90 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxHeavyJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxHeavyJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxHeavyJobSecrets)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override JobSecrets 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(DataBoxHeavyJobSecrets)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxHeavyJobSecrets(document.RootElement, options); } - internal static DataBoxHeavyJobSecrets DeserializeDataBoxHeavyJobSecrets(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxHeavyJobSecrets DeserializeDataBoxHeavyJobSecrets(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList cabinetPodSecrets = default; DataBoxOrderType jobSecretsType = default; - DataCenterAccessSecurityCode dcAccessSecurityCode = default; + DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IReadOnlyList cabinetPodSecrets = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("cabinetPodSecrets"u8)) + if (prop.NameEquals("jobSecretsType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DataBoxHeavySecret.DeserializeDataBoxHeavySecret(item, options)); - } - cabinetPodSecrets = array; + jobSecretsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("jobSecretsType"u8)) + if (prop.NameEquals("dcAccessSecurityCode"u8)) { - jobSecretsType = property.Value.GetString().ToDataBoxOrderType(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataCenterAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(prop.Value, options); continue; } - if (property.NameEquals("dcAccessSecurityCode"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dcAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(property.Value, options); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("cabinetPodSecrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxHeavySecret.DeserializeDataBoxHeavySecret(item, options)); + } + cabinetPodSecrets = 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 DataBoxHeavyJobSecrets(jobSecretsType, dcAccessSecurityCode, error, serializedAdditionalRawData, cabinetPodSecrets ?? new ChangeTrackingList()); + return new DataBoxHeavyJobSecrets(jobSecretsType, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties, cabinetPodSecrets ?? new ChangeTrackingList()); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -135,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - DataBoxHeavyJobSecrets 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. + DataBoxHeavyJobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxHeavyJobSecrets)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override JobSecrets 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 DeserializeDataBoxHeavyJobSecrets(document.RootElement, options); } default: @@ -151,6 +163,7 @@ DataBoxHeavyJobSecrets IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.cs index 6f487865b5b9..de7cd0c2783a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavyJobSecrets.cs @@ -7,6 +7,8 @@ using System; using System.Collections.Generic; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,22 +16,20 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxHeavyJobSecrets : JobSecrets { /// Initializes a new instance of . - internal DataBoxHeavyJobSecrets() + internal DataBoxHeavyJobSecrets() : base(DataBoxOrderType.DataBoxHeavy) { CabinetPodSecrets = new ChangeTrackingList(); - JobSecretsType = DataBoxOrderType.DataBoxHeavy; } /// Initializes a new instance of . /// Used to indicate what type of job secrets object. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Contains the list of secret objects for a databox heavy job. - internal DataBoxHeavyJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary serializedAdditionalRawData, IReadOnlyList cabinetPodSecrets) : base(jobSecretsType, dataCenterAccessSecurityCode, error, serializedAdditionalRawData) + internal DataBoxHeavyJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary additionalBinaryDataProperties, IReadOnlyList cabinetPodSecrets) : base(jobSecretsType, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties) { CabinetPodSecrets = cabinetPodSecrets; - JobSecretsType = jobSecretsType; } /// Contains the list of secret objects for a databox heavy job. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.Serialization.cs index 65c8818a1667..d8175c6b201d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxHeavySecret : IUtf8JsonSerializable, IJsonModel + /// The secrets related to a databox heavy. + public partial class DataBoxHeavySecret : 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, ModelReaderWrit /// 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(DataBoxHeavySecret)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(DeviceSerialNumber)) { writer.WritePropertyName("deviceSerialNumber"u8); @@ -48,7 +48,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("networkConfigurations"u8); writer.WriteStartArray(); - foreach (var item in NetworkConfigurations) + foreach (ApplianceNetworkConfiguration item in NetworkConfigurations) { writer.WriteObjectValue(item, options); } @@ -63,21 +63,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("accountCredentialDetails"u8); writer.WriteStartArray(); - foreach (var item in AccountCredentialDetails) + foreach (DataBoxAccountCredentialDetails item in AccountCredentialDetails) { 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); } @@ -86,22 +86,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxHeavySecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxHeavySecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxHeavySecret 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(DataBoxHeavySecret)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxHeavySecret(document.RootElement, options); } - internal static DataBoxHeavySecret DeserializeDataBoxHeavySecret(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxHeavySecret DeserializeDataBoxHeavySecret(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -111,47 +116,46 @@ internal static DataBoxHeavySecret DeserializeDataBoxHeavySecret(JsonElement ele IReadOnlyList networkConfigurations = default; string encodedValidationCertPubKey = default; IReadOnlyList accountCredentialDetails = 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("deviceSerialNumber"u8)) + if (prop.NameEquals("deviceSerialNumber"u8)) { - deviceSerialNumber = property.Value.GetString(); + deviceSerialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("devicePassword"u8)) + if (prop.NameEquals("devicePassword"u8)) { - devicePassword = property.Value.GetString(); + devicePassword = prop.Value.GetString(); continue; } - if (property.NameEquals("networkConfigurations"u8)) + if (prop.NameEquals("networkConfigurations"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(ApplianceNetworkConfiguration.DeserializeApplianceNetworkConfiguration(item, options)); } networkConfigurations = array; continue; } - if (property.NameEquals("encodedValidationCertPubKey"u8)) + if (prop.NameEquals("encodedValidationCertPubKey"u8)) { - encodedValidationCertPubKey = property.Value.GetString(); + encodedValidationCertPubKey = prop.Value.GetString(); continue; } - if (property.NameEquals("accountCredentialDetails"u8)) + if (prop.NameEquals("accountCredentialDetails"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(DataBoxAccountCredentialDetails.DeserializeDataBoxAccountCredentialDetails(item, options)); } @@ -160,23 +164,25 @@ internal static DataBoxHeavySecret DeserializeDataBoxHeavySecret(JsonElement ele } 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 DataBoxHeavySecret( deviceSerialNumber, devicePassword, networkConfigurations ?? new ChangeTrackingList(), encodedValidationCertPubKey, accountCredentialDetails ?? new ChangeTrackingList(), - 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": @@ -186,15 +192,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DataBoxHeavySecret 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. + DataBoxHeavySecret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxHeavySecret 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 DeserializeDataBoxHeavySecret(document.RootElement, options); } default: @@ -202,6 +213,7 @@ DataBoxHeavySecret IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.cs index f4d2177a253e..887aa11b4c32 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxHeavySecret.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// The secrets related to a databox heavy. public partial class DataBoxHeavySecret { - /// - /// 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 DataBoxHeavySecret() @@ -58,25 +30,29 @@ internal DataBoxHeavySecret() /// Network configuration of the appliance. /// The base 64 encoded public key to authenticate with the device. /// Per account level access credentials. - /// Keeps track of any properties unknown to the library. - internal DataBoxHeavySecret(string deviceSerialNumber, string devicePassword, IReadOnlyList networkConfigurations, string encodedValidationCertPubKey, IReadOnlyList accountCredentialDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxHeavySecret(string deviceSerialNumber, string devicePassword, IReadOnlyList networkConfigurations, string encodedValidationCertPubKey, IReadOnlyList accountCredentialDetails, IDictionary additionalBinaryDataProperties) { DeviceSerialNumber = deviceSerialNumber; DevicePassword = devicePassword; NetworkConfigurations = networkConfigurations; EncodedValidationCertPubKey = encodedValidationCertPubKey; AccountCredentialDetails = accountCredentialDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Serial number of the assigned device. public string DeviceSerialNumber { get; } + /// Password for out of the box experience on device. public string DevicePassword { get; } + /// Network configuration of the appliance. public IReadOnlyList NetworkConfigurations { get; } + /// The base 64 encoded public key to authenticate with the device. public string EncodedValidationCertPubKey { get; } + /// Per account level access credentials. public IReadOnlyList AccountCredentialDetails { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.Serialization.cs index 5ce4ecc50ca3..66e2a018b487 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxJobCancellationReason : IUtf8JsonSerializable, IJsonModel + /// Reason for cancellation. + public partial class DataBoxJobCancellationReason : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxJobCancellationReason() + { + } + /// 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(Utf8JsonWriter writer, Model /// 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(DataBoxJobCancellationReason)} does not support writing '{format}' format."); } - writer.WritePropertyName("reason"u8); writer.WriteStringValue(Reason); - 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 } } - DataBoxJobCancellationReason IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxJobCancellationReason IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxJobCancellationReason 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(DataBoxJobCancellationReason)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxJobCancellationReason(document.RootElement, options); } - internal static DataBoxJobCancellationReason DeserializeDataBoxJobCancellationReason(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxJobCancellationReason DeserializeDataBoxJobCancellationReason(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string reason = 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("reason"u8)) + if (prop.NameEquals("reason"u8)) { - reason = property.Value.GetString(); + reason = 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 DataBoxJobCancellationReason(reason, serializedAdditionalRawData); + return new DataBoxJobCancellationReason(reason, 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.Write(ModelReaderWrit } } - DataBoxJobCancellationReason 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. + DataBoxJobCancellationReason IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxJobCancellationReason 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 DeserializeDataBoxJobCancellationReason(document.RootElement, options); } default: @@ -121,6 +138,19 @@ DataBoxJobCancellationReason IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DataBoxJobCancellationReason dataBoxJobCancellationReason) + { + if (dataBoxJobCancellationReason == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(dataBoxJobCancellationReason, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.cs index a999c53cd832..e8b56f13ba8f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobCancellationReason.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Reason for cancellation. public partial class DataBoxJobCancellationReason { - /// - /// 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 . /// Reason for cancellation. @@ -57,16 +29,11 @@ public DataBoxJobCancellationReason(string reason) /// Initializes a new instance of . /// Reason for cancellation. - /// Keeps track of any properties unknown to the library. - internal DataBoxJobCancellationReason(string reason, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxJobCancellationReason(string reason, IDictionary additionalBinaryDataProperties) { Reason = reason; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxJobCancellationReason() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Reason for cancellation. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.Serialization.cs index 2027a50bbc42..3ff467066734 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxJobDetails : IUtf8JsonSerializable, IJsonModel + /// Databox Job Details. + public partial class DataBoxJobDetails : DataBoxBasicJobDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxJobDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,18 +34,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(DataBoxJobDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsCollectionDefined(CopyProgress)) { writer.WritePropertyName("copyProgress"u8); writer.WriteStartArray(); - foreach (var item in CopyProgress) + foreach (DataBoxCopyProgress item in CopyProgress) { writer.WriteObjectValue(item, options); } @@ -52,28 +57,31 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxJobDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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(DataBoxJobDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxJobDetails(document.RootElement, options); } - internal static DataBoxJobDetails DeserializeDataBoxJobDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxJobDetails DeserializeDataBoxJobDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList copyProgress = default; - string devicePassword = default; IReadOnlyList jobStages = default; DataBoxContactDetails contactDetails = default; DataBoxShippingAddress shippingAddress = default; @@ -89,229 +97,229 @@ internal static DataBoxJobDetails DeserializeDataBoxJobDetails(JsonElement eleme string chainOfCustodySasKey = default; DeviceErasureDetails deviceErasureDetails = default; DataBoxKeyEncryptionKey keyEncryptionKey = default; - int? expectedDataSizeInTeraBytes = default; + int? expectedDataSizeInTerabytes = default; IReadOnlyList actions = default; LastMitigationActionOnJob lastMitigationActionOnJob = default; - DataCenterAddressResult datacenterAddress = default; + DataCenterAddressResult dataCenterAddress = default; DataCenterCode? dataCenterCode = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IReadOnlyList copyProgress = default; + string devicePassword = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("copyProgress"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DataBoxCopyProgress.DeserializeDataBoxCopyProgress(item, options)); - } - copyProgress = array; - continue; - } - if (property.NameEquals("devicePassword"u8)) + if (prop.NameEquals("jobStages"u8)) { - devicePassword = property.Value.GetString(); - continue; - } - if (property.NameEquals("jobStages"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(DataBoxJobStage.DeserializeDataBoxJobStage(item, options)); } jobStages = array; continue; } - if (property.NameEquals("contactDetails"u8)) + if (prop.NameEquals("contactDetails"u8)) { - contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(property.Value, options); + contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(prop.Value, options); continue; } - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("shippingAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("deliveryPackage"u8)) + if (prop.NameEquals("deliveryPackage"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("returnPackage"u8)) + if (prop.NameEquals("returnPackage"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("dataImportDetails"u8)) + if (prop.NameEquals("dataImportDetails"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(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); } dataImportDetails = array; continue; } - if (property.NameEquals("dataExportDetails"u8)) + if (prop.NameEquals("dataExportDetails"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(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); } dataExportDetails = array; continue; } - if (property.NameEquals("jobDetailsType"u8)) + if (prop.NameEquals("jobDetailsType"u8)) { - jobDetailsType = property.Value.GetString().ToDataBoxOrderType(); + jobDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("preferences"u8)) + if (prop.NameEquals("preferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(property.Value, options); + preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(prop.Value, options); continue; } - if (property.NameEquals("reverseShippingDetails"u8)) + if (prop.NameEquals("reverseShippingDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(property.Value, options); + reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("copyLogDetails"u8)) + if (prop.NameEquals("copyLogDetails"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(Models.CopyLogDetails.DeserializeCopyLogDetails(item, options)); } copyLogDetails = array; continue; } - if (property.NameEquals("reverseShipmentLabelSasKey"u8)) + if (prop.NameEquals("reverseShipmentLabelSasKey"u8)) { - reverseShipmentLabelSasKey = property.Value.GetString(); + reverseShipmentLabelSasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("chainOfCustodySasKey"u8)) + if (prop.NameEquals("chainOfCustodySasKey"u8)) { - chainOfCustodySasKey = property.Value.GetString(); + chainOfCustodySasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("deviceErasureDetails"u8)) + if (prop.NameEquals("deviceErasureDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(property.Value, options); + deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(prop.Value, options); continue; } - if (property.NameEquals("keyEncryptionKey"u8)) + if (prop.NameEquals("keyEncryptionKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(property.Value, options); + keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(prop.Value, options); continue; } - if (property.NameEquals("expectedDataSizeInTeraBytes"u8)) + if (prop.NameEquals("expectedDataSizeInTeraBytes"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expectedDataSizeInTeraBytes = property.Value.GetInt32(); + expectedDataSizeInTerabytes = prop.Value.GetInt32(); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("actions"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().ToCustomerResolutionCode()); } actions = array; continue; } - if (property.NameEquals("lastMitigationActionOnJob"u8)) + if (prop.NameEquals("lastMitigationActionOnJob"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(property.Value, options); + lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(prop.Value, options); continue; } - if (property.NameEquals("datacenterAddress"u8)) + if (prop.NameEquals("datacenterAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datacenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(property.Value, options); + dataCenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(prop.Value, options); continue; } - if (property.NameEquals("dataCenterCode"u8)) + if (prop.NameEquals("dataCenterCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataCenterCode = new DataCenterCode(property.Value.GetString()); + dataCenterCode = new DataCenterCode(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("copyProgress"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxCopyProgress.DeserializeDataBoxCopyProgress(item, options)); + } + copyProgress = array; + continue; + } + if (prop.NameEquals("devicePassword"u8)) + { + devicePassword = 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 DataBoxJobDetails( jobStages ?? new ChangeTrackingList(), contactDetails, @@ -328,20 +336,23 @@ internal static DataBoxJobDetails DeserializeDataBoxJobDetails(JsonElement eleme chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, - expectedDataSizeInTeraBytes, + expectedDataSizeInTerabytes, actions ?? new ChangeTrackingList(), lastMitigationActionOnJob, - datacenterAddress, + dataCenterAddress, dataCenterCode, - serializedAdditionalRawData, + additionalBinaryDataProperties, copyProgress ?? new ChangeTrackingList(), devicePassword); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -351,15 +362,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - DataBoxJobDetails 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. + DataBoxJobDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxJobDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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 DeserializeDataBoxJobDetails(document.RootElement, options); } default: @@ -367,6 +383,7 @@ DataBoxJobDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.cs index bd9130b2cfa2..50a3775ea62a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobDetails.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -16,12 +17,11 @@ public partial class DataBoxJobDetails : DataBoxBasicJobDetails /// Initializes a new instance of . /// Contact details for notification and shipping. /// is null. - public DataBoxJobDetails(DataBoxContactDetails contactDetails) : base(contactDetails) + public DataBoxJobDetails(DataBoxContactDetails contactDetails) : base(contactDetails, DataBoxOrderType.DataBox) { Argument.AssertNotNull(contactDetails, nameof(contactDetails)); CopyProgress = new ChangeTrackingList(); - JobDetailsType = DataBoxOrderType.DataBox; } /// Initializes a new instance of . @@ -35,11 +35,7 @@ public DataBoxJobDetails(DataBoxContactDetails contactDetails) : base(contactDet /// Indicates the type of job details. /// Preferences for the order. /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + /// List of copy log details. /// Shared access key to download the return shipment label. /// Shared access key to download the chain of custody logs. /// Holds device data erasure details. @@ -47,29 +43,20 @@ public DataBoxJobDetails(DataBoxContactDetails contactDetails) : base(contactDet /// The expected size of the data, which needs to be transferred in this job, in terabytes. /// Available actions on the job. /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address to ship to, for the given sku and storage location. /// DataCenter code. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Copy progress per storage account. /// Set Device password for unlocking Databox. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. - internal DataBoxJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary serializedAdditionalRawData, IReadOnlyList copyProgress, string devicePassword) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, serializedAdditionalRawData) + internal DataBoxJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary additionalBinaryDataProperties, IReadOnlyList copyProgress, string devicePassword) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, additionalBinaryDataProperties) { CopyProgress = copyProgress; DevicePassword = devicePassword; - JobDetailsType = jobDetailsType; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxJobDetails() - { } /// Copy progress per storage account. public IReadOnlyList CopyProgress { get; } + /// Set Device password for unlocking Databox. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. public string DevicePassword { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.Serialization.cs index 4b8453f88960..2557596c9b7b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.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.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class DataBoxJobListResult : IUtf8JsonSerializable, IJsonModel + /// Job Resource Collection. + internal partial class DataBoxJobListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxJobListResult() + { + } + /// 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, 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(DataBoxJobListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DataBoxJobData 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 } } - DataBoxJobListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxJobListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxJobListResult 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(DataBoxJobListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxJobListResult(document.RootElement, options); } - internal static DataBoxJobListResult DeserializeDataBoxJobListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxJobListResult DeserializeDataBoxJobListResult(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(DataBoxJobData.DeserializeDataBoxJobData(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 DataBoxJobListResult(value, nextLink, serializedAdditionalRawData); + return new DataBoxJobListResult(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(ModelReaderWriterOption } } - DataBoxJobListResult 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. + DataBoxJobListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxJobListResult 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 DeserializeDataBoxJobListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ DataBoxJobListResult 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 DataBoxJobListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDataBoxJobListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.cs index cbbb7ae566a5..c63c8db06f71 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Job Resource Collection. internal partial class DataBoxJobListResult { - /// - /// 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 JobResource items on this page. - /// is null. internal DataBoxJobListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The JobResource items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal DataBoxJobListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxJobListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxJobListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The JobResource 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.Serialization.cs index 4b5de62cfe51..62378f5e5187 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.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.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxJobPatch : IUtf8JsonSerializable, IJsonModel + /// The JobResourceUpdateParameter. + public partial class DataBoxJobPatch : 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(); @@ -30,12 +30,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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(DataBoxJobPatch)} does not support writing '{format}' format."); } - + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -43,6 +47,11 @@ 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(); @@ -50,25 +59,17 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - ((IJsonModel)Identity).Write(writer, options); - } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(Details)) - { - writer.WritePropertyName("details"u8); - writer.WriteObjectValue(Details, options); + writer.WriteObjectValue(Identity, options); } - 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); } @@ -77,90 +78,91 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxJobPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxJobPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxJobPatch 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(DataBoxJobPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxJobPatch(document.RootElement, options); } - internal static DataBoxJobPatch DeserializeDataBoxJobPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxJobPatch DeserializeDataBoxJobPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + UpdateJobProperties properties = default; IDictionary tags = default; - ManagedServiceIdentity identity = default; - UpdateJobDetails details = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceIdentity identity = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("properties"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()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; + properties = UpdateJobProperties.DeserializeUpdateJobProperties(prop.Value, options); continue; } - if (property.NameEquals("identity"u8)) + if (prop.NameEquals("tags"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())), options, AzureResourceManagerDataBoxContext.Default); + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + 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("properties"u8)) + if (prop.NameEquals("identity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("details"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - details = UpdateJobDetails.DeserializeUpdateJobDetails(property0.Value, options); - continue; - } - } + identity = ResourceIdentity.DeserializeResourceIdentity(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 DataBoxJobPatch(details, tags ?? new ChangeTrackingDictionary(), identity, serializedAdditionalRawData); + return new DataBoxJobPatch(properties, tags ?? new ChangeTrackingDictionary(), identity, 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": @@ -170,15 +172,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - DataBoxJobPatch 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. + DataBoxJobPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxJobPatch 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 DeserializeDataBoxJobPatch(document.RootElement, options); } default: @@ -186,6 +193,19 @@ DataBoxJobPatch IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DataBoxJobPatch dataBoxJobPatch) + { + if (dataBoxJobPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(dataBoxJobPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.cs index 8fd0159bd001..5e9aa709938f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobPatch.cs @@ -7,44 +7,15 @@ using System; using System.Collections.Generic; -using Azure.ResourceManager.Models; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// The JobResourceUpdateParameter. public partial class DataBoxJobPatch { - /// - /// 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 DataBoxJobPatch() @@ -53,23 +24,42 @@ public DataBoxJobPatch() } /// Initializes a new instance of . - /// Details of a job to be updated. + /// Properties of a job to be updated. /// The list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). /// Msi identity of the resource. - /// Keeps track of any properties unknown to the library. - internal DataBoxJobPatch(UpdateJobDetails details, IDictionary tags, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxJobPatch(UpdateJobProperties properties, IDictionary tags, ResourceIdentity identity, IDictionary additionalBinaryDataProperties) { - Details = details; + Properties = properties; Tags = tags; Identity = identity; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// Details of a job to be updated. - public UpdateJobDetails Details { get; set; } + /// Properties of a job to be updated. + internal UpdateJobProperties Properties { get; set; } + /// The list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). public IDictionary Tags { get; } + /// Msi identity of the resource. - public ManagedServiceIdentity Identity { get; set; } + public ResourceIdentity Identity { get; set; } + + /// Details of a job to be updated. + public UpdateJobDetails Details + { + get + { + return Properties is null ? default : Properties.Details; + } + set + { + if (Properties is null) + { + Properties = new UpdateJobProperties(); + } + Properties.Details = value; + } + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.Serialization.cs index 14149d4a36fd..fbf9ca0bd2fd 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxJobSecrets : IUtf8JsonSerializable, IJsonModel + /// The secrets related to a databox job. + public partial class DataBoxJobSecrets : JobSecrets, 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(); @@ -29,18 +31,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(DataBoxJobSecrets)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(PodSecrets)) { writer.WritePropertyName("podSecrets"u8); writer.WriteStartArray(); - foreach (var item in PodSecrets) + foreach (DataBoxSecret item in PodSecrets) { writer.WriteObjectValue(item, options); } @@ -48,84 +49,90 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxJobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxJobSecrets)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override JobSecrets 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(DataBoxJobSecrets)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxJobSecrets(document.RootElement, options); } - internal static DataBoxJobSecrets DeserializeDataBoxJobSecrets(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxJobSecrets DeserializeDataBoxJobSecrets(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList podSecrets = default; DataBoxOrderType jobSecretsType = default; - DataCenterAccessSecurityCode dcAccessSecurityCode = default; + DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IReadOnlyList podSecrets = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("podSecrets"u8)) + if (prop.NameEquals("jobSecretsType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DataBoxSecret.DeserializeDataBoxSecret(item, options)); - } - podSecrets = array; + jobSecretsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("jobSecretsType"u8)) + if (prop.NameEquals("dcAccessSecurityCode"u8)) { - jobSecretsType = property.Value.GetString().ToDataBoxOrderType(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataCenterAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(prop.Value, options); continue; } - if (property.NameEquals("dcAccessSecurityCode"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dcAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(property.Value, options); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("podSecrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxSecret.DeserializeDataBoxSecret(item, options)); + } + podSecrets = 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 DataBoxJobSecrets(jobSecretsType, dcAccessSecurityCode, error, serializedAdditionalRawData, podSecrets ?? new ChangeTrackingList()); + return new DataBoxJobSecrets(jobSecretsType, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties, podSecrets ?? new ChangeTrackingList()); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -135,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - DataBoxJobSecrets 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. + DataBoxJobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxJobSecrets)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override JobSecrets 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 DeserializeDataBoxJobSecrets(document.RootElement, options); } default: @@ -151,6 +163,7 @@ DataBoxJobSecrets IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.cs index f07570c915bb..ee5d39346c2a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobSecrets.cs @@ -7,6 +7,8 @@ using System; using System.Collections.Generic; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,22 +16,20 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataBoxJobSecrets : JobSecrets { /// Initializes a new instance of . - internal DataBoxJobSecrets() + internal DataBoxJobSecrets() : base(DataBoxOrderType.DataBox) { PodSecrets = new ChangeTrackingList(); - JobSecretsType = DataBoxOrderType.DataBox; } /// Initializes a new instance of . /// Used to indicate what type of job secrets object. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Contains the list of secret objects for a job. - internal DataBoxJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary serializedAdditionalRawData, IReadOnlyList podSecrets) : base(jobSecretsType, dataCenterAccessSecurityCode, error, serializedAdditionalRawData) + internal DataBoxJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary additionalBinaryDataProperties, IReadOnlyList podSecrets) : base(jobSecretsType, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties) { PodSecrets = podSecrets; - JobSecretsType = jobSecretsType; } /// Contains the list of secret objects for a job. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.Serialization.cs index 5b3ce4db2372..7fcaa66aa238 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxJobStage : IUtf8JsonSerializable, IJsonModel + /// Job stages. + public partial class DataBoxJobStage : 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, ModelReaderWriterO /// 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(DataBoxJobStage)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(StageName)) { writer.WritePropertyName("stageName"u8); @@ -58,9 +58,9 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("jobStageDetails"u8); #if NET6_0_OR_GREATER - writer.WriteRawValue(JobStageDetails); + writer.WriteRawValue(JobStageDetails); #else - using (JsonDocument document = JsonDocument.Parse(JobStageDetails, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(JobStageDetails)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -70,21 +70,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("delayInformation"u8); writer.WriteStartArray(); - foreach (var item in DelayInformation) + foreach (JobDelayDetails item in DelayInformation) { 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); } @@ -93,22 +93,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxJobStage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxJobStage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxJobStage 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(DataBoxJobStage)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxJobStage(document.RootElement, options); } - internal static DataBoxJobStage DeserializeDataBoxJobStage(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxJobStage DeserializeDataBoxJobStage(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -119,59 +124,58 @@ internal static DataBoxJobStage DeserializeDataBoxJobStage(JsonElement element, DateTimeOffset? stageTime = default; BinaryData jobStageDetails = default; IReadOnlyList delayInformation = 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("stageName"u8)) + if (prop.NameEquals("stageName"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - stageName = new DataBoxStageName(property.Value.GetString()); + stageName = new DataBoxStageName(prop.Value.GetString()); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("stageStatus"u8)) + if (prop.NameEquals("stageStatus"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - stageStatus = property.Value.GetString().ToDataBoxStageStatus(); + stageStatus = prop.Value.GetString().ToDataBoxStageStatus(); continue; } - if (property.NameEquals("stageTime"u8)) + if (prop.NameEquals("stageTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - stageTime = property.Value.GetDateTimeOffset("O"); + stageTime = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("jobStageDetails"u8)) + if (prop.NameEquals("jobStageDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - jobStageDetails = BinaryData.FromString(property.Value.GetRawText()); + jobStageDetails = BinaryData.FromString(prop.Value.GetRawText()); continue; } - if (property.NameEquals("delayInformation"u8)) + if (prop.NameEquals("delayInformation"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(JobDelayDetails.DeserializeJobDelayDetails(item, options)); } @@ -180,10 +184,9 @@ internal static DataBoxJobStage DeserializeDataBoxJobStage(JsonElement element, } 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 DataBoxJobStage( stageName, displayName, @@ -191,13 +194,16 @@ internal static DataBoxJobStage DeserializeDataBoxJobStage(JsonElement element, stageTime, jobStageDetails, delayInformation ?? new ChangeTrackingList(), - 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": @@ -207,15 +213,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - DataBoxJobStage 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. + DataBoxJobStage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxJobStage 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 DeserializeDataBoxJobStage(document.RootElement, options); } default: @@ -223,6 +234,7 @@ DataBoxJobStage IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.cs index c6b7f275b554..53f3dcbd1a0e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobStage.cs @@ -7,43 +7,16 @@ using System; using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Job stages. public partial class DataBoxJobStage { - /// - /// 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 DataBoxJobStage() @@ -58,8 +31,8 @@ internal DataBoxJobStage() /// Time for the job stage in UTC ISO 8601 format. /// Job Stage Details. /// Delay information for the job stages. - /// Keeps track of any properties unknown to the library. - internal DataBoxJobStage(DataBoxStageName? stageName, string displayName, DataBoxStageStatus? stageStatus, DateTimeOffset? stageTime, BinaryData jobStageDetails, IReadOnlyList delayInformation, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxJobStage(DataBoxStageName? stageName, string displayName, DataBoxStageStatus? stageStatus, DateTimeOffset? stageTime, BinaryData jobStageDetails, IReadOnlyList delayInformation, IDictionary additionalBinaryDataProperties) { StageName = stageName; DisplayName = displayName; @@ -67,46 +40,46 @@ internal DataBoxJobStage(DataBoxStageName? stageName, string displayName, DataBo StageTime = stageTime; JobStageDetails = jobStageDetails; DelayInformation = delayInformation; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the job stage. public DataBoxStageName? StageName { get; } + /// Display name of the job stage. public string DisplayName { get; } + /// Status of the job stage. public DataBoxStageStatus? StageStatus { get; } + /// /// Job Stage Details - /// - /// 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 JobStageDetails { get; } + /// Delay information for the job stages. public IReadOnlyList DelayInformation { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobTransferType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobTransferType.Serialization.cs index 9b1a9e0bc977..e7f151364665 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobTransferType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxJobTransferType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxJobTransferTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxJobTransferType value) => value switch { DataBoxJobTransferType.ImportToAzure => "ImportToAzure", @@ -18,10 +19,17 @@ internal static partial class DataBoxJobTransferTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxJobTransferType value.") }; + /// The value to deserialize. public static DataBoxJobTransferType ToDataBoxJobTransferType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ImportToAzure")) return DataBoxJobTransferType.ImportToAzure; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ExportFromAzure")) return DataBoxJobTransferType.ExportFromAzure; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ImportToAzure")) + { + return DataBoxJobTransferType.ImportToAzure; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ExportFromAzure")) + { + return DataBoxJobTransferType.ExportFromAzure; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxJobTransferType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.Serialization.cs index 5d232cdc3efa..b8b66a0e1274 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxKeyEncryptionKey : IUtf8JsonSerializable, IJsonModel + /// Encryption key containing details about key to encrypt different keys. + public partial class DataBoxKeyEncryptionKey : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxKeyEncryptionKey() + { + } + /// 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, ModelReade /// 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(DataBoxKeyEncryptionKey)} does not support writing '{format}' format."); } - writer.WritePropertyName("kekType"u8); writer.WriteStringValue(KekType.ToSerialString()); if (Optional.IsDefined(ManagedIdentity)) @@ -46,20 +52,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("kekUrl"u8); writer.WriteStringValue(KekUri.AbsoluteUri); } - if (Optional.IsDefined(KekVaultResourceId)) + if (Optional.IsDefined(KekVaultResourceID)) { writer.WritePropertyName("kekVaultResourceID"u8); - writer.WriteStringValue(KekVaultResourceId); + writer.WriteStringValue(KekVaultResourceID); } - 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); } @@ -68,79 +74,85 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxKeyEncryptionKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxKeyEncryptionKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxKeyEncryptionKey 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(DataBoxKeyEncryptionKey)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxKeyEncryptionKey(document.RootElement, options); } - internal static DataBoxKeyEncryptionKey DeserializeDataBoxKeyEncryptionKey(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxKeyEncryptionKey DeserializeDataBoxKeyEncryptionKey(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxKeyEncryptionKeyType kekType = default; - DataBoxManagedIdentity identityProperties = default; - Uri kekUrl = default; - ResourceIdentifier kekVaultResourceId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DataBoxManagedIdentity managedIdentity = default; + Uri kekUri = default; + ResourceIdentifier kekVaultResourceID = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("kekType"u8)) + if (prop.NameEquals("kekType"u8)) { - kekType = property.Value.GetString().ToDataBoxKeyEncryptionKeyType(); + kekType = prop.Value.GetString().ToDataBoxKeyEncryptionKeyType(); continue; } - if (property.NameEquals("identityProperties"u8)) + if (prop.NameEquals("identityProperties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - identityProperties = DataBoxManagedIdentity.DeserializeDataBoxManagedIdentity(property.Value, options); + managedIdentity = DataBoxManagedIdentity.DeserializeDataBoxManagedIdentity(prop.Value, options); continue; } - if (property.NameEquals("kekUrl"u8)) + if (prop.NameEquals("kekUrl"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - kekUrl = new Uri(property.Value.GetString()); + kekUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("kekVaultResourceID"u8)) + if (prop.NameEquals("kekVaultResourceID"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - kekVaultResourceId = new ResourceIdentifier(property.Value.GetString()); + kekVaultResourceID = 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 DataBoxKeyEncryptionKey(kekType, identityProperties, kekUrl, kekVaultResourceId, serializedAdditionalRawData); + return new DataBoxKeyEncryptionKey(kekType, managedIdentity, kekUri, kekVaultResourceID, 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 +162,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - DataBoxKeyEncryptionKey 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. + DataBoxKeyEncryptionKey IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxKeyEncryptionKey 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 DeserializeDataBoxKeyEncryptionKey(document.RootElement, options); } default: @@ -166,6 +183,7 @@ DataBoxKeyEncryptionKey IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.cs index 7a51d45b8033..3b750663d370 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKey.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Encryption key containing details about key to encrypt different keys. public partial class DataBoxKeyEncryptionKey { - /// - /// 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 . /// Type of encryption key used for key encryption. @@ -57,29 +28,27 @@ public DataBoxKeyEncryptionKey(DataBoxKeyEncryptionKeyType kekType) /// Type of encryption key used for key encryption. /// Managed identity properties used for key encryption. /// Key encryption key. It is required in case of Customer managed KekType. - /// Kek vault resource id. It is required in case of Customer managed KekType. - /// Keeps track of any properties unknown to the library. - internal DataBoxKeyEncryptionKey(DataBoxKeyEncryptionKeyType kekType, DataBoxManagedIdentity managedIdentity, Uri kekUri, ResourceIdentifier kekVaultResourceId, IDictionary serializedAdditionalRawData) + /// Kek vault resource id. It is required in case of Customer managed KekType. + /// Keeps track of any properties unknown to the library. + internal DataBoxKeyEncryptionKey(DataBoxKeyEncryptionKeyType kekType, DataBoxManagedIdentity managedIdentity, Uri kekUri, ResourceIdentifier kekVaultResourceID, IDictionary additionalBinaryDataProperties) { KekType = kekType; ManagedIdentity = managedIdentity; KekUri = kekUri; - KekVaultResourceId = kekVaultResourceId; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxKeyEncryptionKey() - { + KekVaultResourceID = kekVaultResourceID; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of encryption key used for key encryption. public DataBoxKeyEncryptionKeyType KekType { get; set; } + /// Managed identity properties used for key encryption. public DataBoxManagedIdentity ManagedIdentity { get; set; } + /// Key encryption key. It is required in case of Customer managed KekType. public Uri KekUri { get; set; } + /// Kek vault resource id. It is required in case of Customer managed KekType. - public ResourceIdentifier KekVaultResourceId { get; set; } + public ResourceIdentifier KekVaultResourceID { get; set; } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKeyType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKeyType.Serialization.cs index 30c8d2f6c458..c25ffbfd6d2c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKeyType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxKeyEncryptionKeyType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxKeyEncryptionKeyTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxKeyEncryptionKeyType value) => value switch { DataBoxKeyEncryptionKeyType.MicrosoftManaged => "MicrosoftManaged", @@ -18,10 +19,17 @@ internal static partial class DataBoxKeyEncryptionKeyTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxKeyEncryptionKeyType value.") }; + /// The value to deserialize. public static DataBoxKeyEncryptionKeyType ToDataBoxKeyEncryptionKeyType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "MicrosoftManaged")) return DataBoxKeyEncryptionKeyType.MicrosoftManaged; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerManaged")) return DataBoxKeyEncryptionKeyType.CustomerManaged; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "MicrosoftManaged")) + { + return DataBoxKeyEncryptionKeyType.MicrosoftManaged; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerManaged")) + { + return DataBoxKeyEncryptionKeyType.CustomerManaged; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxKeyEncryptionKeyType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.Serialization.cs index af8387af40a5..99bf82c2c193 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxManagedIdentity : IUtf8JsonSerializable, IJsonModel + /// Managed identity properties. + public partial class DataBoxManagedIdentity : 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, ModelReader /// 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(DataBoxManagedIdentity)} does not support writing '{format}' format."); } - if (Optional.IsDefined(IdentityType)) { writer.WritePropertyName("type"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("userAssigned"u8); writer.WriteObjectValue(UserAssigned, 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); } @@ -61,59 +61,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxManagedIdentity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxManagedIdentity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxManagedIdentity 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(DataBoxManagedIdentity)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxManagedIdentity(document.RootElement, options); } - internal static DataBoxManagedIdentity DeserializeDataBoxManagedIdentity(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxManagedIdentity DeserializeDataBoxManagedIdentity(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string type = default; + string identityType = default; DataBoxUserAssignedIdentity userAssigned = 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("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + identityType = prop.Value.GetString(); continue; } - if (property.NameEquals("userAssigned"u8)) + if (prop.NameEquals("userAssigned"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - userAssigned = DataBoxUserAssignedIdentity.DeserializeDataBoxUserAssignedIdentity(property.Value, options); + userAssigned = DataBoxUserAssignedIdentity.DeserializeDataBoxUserAssignedIdentity(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 DataBoxManagedIdentity(type, userAssigned, serializedAdditionalRawData); + return new DataBoxManagedIdentity(identityType, userAssigned, 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 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - DataBoxManagedIdentity 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. + DataBoxManagedIdentity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxManagedIdentity 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 DeserializeDataBoxManagedIdentity(document.RootElement, options); } default: @@ -139,6 +150,7 @@ DataBoxManagedIdentity IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.cs index 7d75a2a68698..50a313d4e92c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxManagedIdentity.cs @@ -7,44 +7,14 @@ using System; using System.Collections.Generic; -using Azure.Core; namespace Azure.ResourceManager.DataBox.Models { /// Managed identity properties. public partial class DataBoxManagedIdentity { - /// - /// 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 DataBoxManagedIdentity() @@ -54,16 +24,17 @@ public DataBoxManagedIdentity() /// Initializes a new instance of . /// Managed service identity type. /// User assigned identity properties. - /// Keeps track of any properties unknown to the library. - internal DataBoxManagedIdentity(string identityType, DataBoxUserAssignedIdentity userAssigned, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxManagedIdentity(string identityType, DataBoxUserAssignedIdentity userAssigned, IDictionary additionalBinaryDataProperties) { IdentityType = identityType; UserAssigned = userAssigned; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Managed service identity type. public string IdentityType { get; set; } + /// User assigned identity properties. internal DataBoxUserAssignedIdentity UserAssigned { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.Serialization.cs index a2177032ce3e..6193407a24e1 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxOrderPreferences : IUtf8JsonSerializable, IJsonModel + /// Preferences related to the order. + public partial class DataBoxOrderPreferences : 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,18 +29,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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(DataBoxOrderPreferences)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(PreferredDataCenterRegion)) { writer.WritePropertyName("preferredDataCenterRegion"u8); writer.WriteStartArray(); - foreach (var item in PreferredDataCenterRegion) + foreach (string item in PreferredDataCenterRegion) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -63,21 +68,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("storageAccountAccessTierPreferences"u8); writer.WriteStartArray(); - foreach (var item in StorageAccountAccessTierPreferences) + foreach (string item in StorageAccountAccessTierPreferences) { + 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); } @@ -86,22 +96,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxOrderPreferences IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxOrderPreferences IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxOrderPreferences 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(DataBoxOrderPreferences)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxOrderPreferences(document.RootElement, options); } - internal static DataBoxOrderPreferences DeserializeDataBoxOrderPreferences(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxOrderPreferences DeserializeDataBoxOrderPreferences(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -111,84 +126,99 @@ internal static DataBoxOrderPreferences DeserializeDataBoxOrderPreferences(JsonE TransportPreferences reverseTransportPreferences = default; DataBoxEncryptionPreferences encryptionPreferences = default; IList storageAccountAccessTierPreferences = 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("preferredDataCenterRegion"u8)) + if (prop.NameEquals("preferredDataCenterRegion"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()); + } } preferredDataCenterRegion = array; continue; } - if (property.NameEquals("transportPreferences"u8)) + if (prop.NameEquals("transportPreferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transportPreferences = TransportPreferences.DeserializeTransportPreferences(property.Value, options); + transportPreferences = TransportPreferences.DeserializeTransportPreferences(prop.Value, options); continue; } - if (property.NameEquals("reverseTransportPreferences"u8)) + if (prop.NameEquals("reverseTransportPreferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reverseTransportPreferences = TransportPreferences.DeserializeTransportPreferences(property.Value, options); + reverseTransportPreferences = TransportPreferences.DeserializeTransportPreferences(prop.Value, options); continue; } - if (property.NameEquals("encryptionPreferences"u8)) + if (prop.NameEquals("encryptionPreferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - encryptionPreferences = DataBoxEncryptionPreferences.DeserializeDataBoxEncryptionPreferences(property.Value, options); + encryptionPreferences = DataBoxEncryptionPreferences.DeserializeDataBoxEncryptionPreferences(prop.Value, options); continue; } - if (property.NameEquals("storageAccountAccessTierPreferences"u8)) + if (prop.NameEquals("storageAccountAccessTierPreferences"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()); + } } storageAccountAccessTierPreferences = 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 DataBoxOrderPreferences( preferredDataCenterRegion ?? new ChangeTrackingList(), transportPreferences, reverseTransportPreferences, encryptionPreferences, storageAccountAccessTierPreferences ?? new ChangeTrackingList(), - 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": @@ -198,15 +228,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - DataBoxOrderPreferences 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. + DataBoxOrderPreferences IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxOrderPreferences 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 DeserializeDataBoxOrderPreferences(document.RootElement, options); } default: @@ -214,6 +249,7 @@ DataBoxOrderPreferences IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.cs index ad58a6abbf37..7917dfd71f6d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderPreferences.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Preferences related to the order. public partial class DataBoxOrderPreferences { - /// - /// 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 DataBoxOrderPreferences() @@ -58,25 +30,29 @@ public DataBoxOrderPreferences() /// Optional Preferences related to the reverse shipment logistics of the sku. /// Preferences related to the Encryption. /// Preferences related to the Access Tier of storage accounts. - /// Keeps track of any properties unknown to the library. - internal DataBoxOrderPreferences(IList preferredDataCenterRegion, TransportPreferences transportPreferences, TransportPreferences reverseTransportPreferences, DataBoxEncryptionPreferences encryptionPreferences, IList storageAccountAccessTierPreferences, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxOrderPreferences(IList preferredDataCenterRegion, TransportPreferences transportPreferences, TransportPreferences reverseTransportPreferences, DataBoxEncryptionPreferences encryptionPreferences, IList storageAccountAccessTierPreferences, IDictionary additionalBinaryDataProperties) { PreferredDataCenterRegion = preferredDataCenterRegion; TransportPreferences = transportPreferences; ReverseTransportPreferences = reverseTransportPreferences; EncryptionPreferences = encryptionPreferences; StorageAccountAccessTierPreferences = storageAccountAccessTierPreferences; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Preferred data center region. public IList PreferredDataCenterRegion { get; } + /// Preferences related to the shipment logistics of the sku. public TransportPreferences TransportPreferences { get; set; } + /// Optional Preferences related to the reverse shipment logistics of the sku. public TransportPreferences ReverseTransportPreferences { get; set; } + /// Preferences related to the Encryption. public DataBoxEncryptionPreferences EncryptionPreferences { get; set; } + /// Preferences related to the Access Tier of storage accounts. public IList StorageAccountAccessTierPreferences { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderType.Serialization.cs index ecd6d739067a..956468507560 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxOrderType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxOrderTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxOrderType value) => value switch { DataBoxOrderType.DataBox => "DataBox", @@ -20,12 +21,25 @@ internal static partial class DataBoxOrderTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxOrderType value.") }; + /// The value to deserialize. public static DataBoxOrderType ToDataBoxOrderType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBox")) return DataBoxOrderType.DataBox; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxDisk")) return DataBoxOrderType.DataBoxDisk; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxHeavy")) return DataBoxOrderType.DataBoxHeavy; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxCustomerDisk")) return DataBoxOrderType.DataBoxCustomerDisk; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBox")) + { + return DataBoxOrderType.DataBox; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxDisk")) + { + return DataBoxOrderType.DataBoxDisk; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxHeavy")) + { + return DataBoxOrderType.DataBoxHeavy; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxCustomerDisk")) + { + return DataBoxOrderType.DataBoxCustomerDisk; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxOrderType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.Serialization.cs index 893cd0f55d80..65ae2319cc49 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxScheduleAvailabilityContent : IUtf8JsonSerializable, IJsonModel + /// Request body to get the availability for scheduling data box orders orders. + public partial class DataBoxScheduleAvailabilityContent : ScheduleAvailabilityContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxScheduleAvailabilityContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +35,35 @@ void IJsonModel.Write(Utf8JsonWriter writer, /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DataBoxScheduleAvailabilityContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - DataBoxScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxScheduleAvailabilityContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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(DataBoxScheduleAvailabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxScheduleAvailabilityContent(document.RootElement, options); } - internal static DataBoxScheduleAvailabilityContent DeserializeDataBoxScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxScheduleAvailabilityContent DeserializeDataBoxScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -61,47 +72,48 @@ internal static DataBoxScheduleAvailabilityContent DeserializeDataBoxScheduleAva DataBoxSkuName skuName = default; string country = default; DeviceModelName? model = 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("storageLocation"u8)) + if (prop.NameEquals("storageLocation"u8)) { - storageLocation = new AzureLocation(property.Value.GetString()); + storageLocation = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("skuName"u8)) + if (prop.NameEquals("skuName"u8)) { - skuName = property.Value.GetString().ToDataBoxSkuName(); + skuName = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("country"u8)) { - country = property.Value.GetString(); + country = prop.Value.GetString(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + model = prop.Value.GetString().ToDeviceModelName(); 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 DataBoxScheduleAvailabilityContent(storageLocation, skuName, country, model, serializedAdditionalRawData); + return new DataBoxScheduleAvailabilityContent(storageLocation, skuName, country, model, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -111,15 +123,20 @@ BinaryData IPersistableModel.Write(ModelRead } } - DataBoxScheduleAvailabilityContent 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. + DataBoxScheduleAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxScheduleAvailabilityContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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 DeserializeDataBoxScheduleAvailabilityContent(document.RootElement, options); } default: @@ -127,6 +144,7 @@ DataBoxScheduleAvailabilityContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.cs index 89aa18dc890b..bdf1aca1b3ab 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxScheduleAvailabilityContent.cs @@ -16,9 +16,8 @@ public partial class DataBoxScheduleAvailabilityContent : ScheduleAvailabilityCo { /// Initializes a new instance of . /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. - public DataBoxScheduleAvailabilityContent(AzureLocation storageLocation) : base(storageLocation) + public DataBoxScheduleAvailabilityContent(AzureLocation storageLocation) : base(storageLocation, DataBoxSkuName.DataBox) { - SkuName = DataBoxSkuName.DataBox; } /// Initializes a new instance of . @@ -26,14 +25,8 @@ public DataBoxScheduleAvailabilityContent(AzureLocation storageLocation) : base( /// Sku Name for which the order is to be scheduled. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal DataBoxScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary serializedAdditionalRawData) : base(storageLocation, skuName, country, model, serializedAdditionalRawData) - { - SkuName = skuName; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxScheduleAvailabilityContent() + /// Keeps track of any properties unknown to the library. + internal DataBoxScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary additionalBinaryDataProperties) : base(storageLocation, skuName, country, model, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.Serialization.cs index 63f96b5d4dfe..3ebd9e0ad9c9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxSecret : IUtf8JsonSerializable, IJsonModel + /// The secrets related to a DataBox. + public partial class DataBoxSecret : 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, ModelReaderWriterOpt /// 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(DataBoxSecret)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(DeviceSerialNumber)) { writer.WritePropertyName("deviceSerialNumber"u8); @@ -48,7 +48,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("networkConfigurations"u8); writer.WriteStartArray(); - foreach (var item in NetworkConfigurations) + foreach (ApplianceNetworkConfiguration item in NetworkConfigurations) { writer.WriteObjectValue(item, options); } @@ -63,21 +63,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("accountCredentialDetails"u8); writer.WriteStartArray(); - foreach (var item in AccountCredentialDetails) + foreach (DataBoxAccountCredentialDetails item in AccountCredentialDetails) { 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); } @@ -86,22 +86,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxSecret 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(DataBoxSecret)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxSecret(document.RootElement, options); } - internal static DataBoxSecret DeserializeDataBoxSecret(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxSecret DeserializeDataBoxSecret(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -111,47 +116,46 @@ internal static DataBoxSecret DeserializeDataBoxSecret(JsonElement element, Mode IReadOnlyList networkConfigurations = default; string encodedValidationCertPubKey = default; IReadOnlyList accountCredentialDetails = 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("deviceSerialNumber"u8)) + if (prop.NameEquals("deviceSerialNumber"u8)) { - deviceSerialNumber = property.Value.GetString(); + deviceSerialNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("devicePassword"u8)) + if (prop.NameEquals("devicePassword"u8)) { - devicePassword = property.Value.GetString(); + devicePassword = prop.Value.GetString(); continue; } - if (property.NameEquals("networkConfigurations"u8)) + if (prop.NameEquals("networkConfigurations"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(ApplianceNetworkConfiguration.DeserializeApplianceNetworkConfiguration(item, options)); } networkConfigurations = array; continue; } - if (property.NameEquals("encodedValidationCertPubKey"u8)) + if (prop.NameEquals("encodedValidationCertPubKey"u8)) { - encodedValidationCertPubKey = property.Value.GetString(); + encodedValidationCertPubKey = prop.Value.GetString(); continue; } - if (property.NameEquals("accountCredentialDetails"u8)) + if (prop.NameEquals("accountCredentialDetails"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(DataBoxAccountCredentialDetails.DeserializeDataBoxAccountCredentialDetails(item, options)); } @@ -160,23 +164,25 @@ internal static DataBoxSecret DeserializeDataBoxSecret(JsonElement element, Mode } 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 DataBoxSecret( deviceSerialNumber, devicePassword, networkConfigurations ?? new ChangeTrackingList(), encodedValidationCertPubKey, accountCredentialDetails ?? new ChangeTrackingList(), - 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": @@ -186,15 +192,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - DataBoxSecret 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. + DataBoxSecret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxSecret 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 DeserializeDataBoxSecret(document.RootElement, options); } default: @@ -202,6 +213,7 @@ DataBoxSecret IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.cs index 8f82fcaffa97..95520707474a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSecret.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// The secrets related to a DataBox. public partial class DataBoxSecret { - /// - /// 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 DataBoxSecret() @@ -58,25 +30,29 @@ internal DataBoxSecret() /// Network configuration of the appliance. /// The base 64 encoded public key to authenticate with the device. /// Per account level access credentials. - /// Keeps track of any properties unknown to the library. - internal DataBoxSecret(string deviceSerialNumber, string devicePassword, IReadOnlyList networkConfigurations, string encodedValidationCertPubKey, IReadOnlyList accountCredentialDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxSecret(string deviceSerialNumber, string devicePassword, IReadOnlyList networkConfigurations, string encodedValidationCertPubKey, IReadOnlyList accountCredentialDetails, IDictionary additionalBinaryDataProperties) { DeviceSerialNumber = deviceSerialNumber; DevicePassword = devicePassword; NetworkConfigurations = networkConfigurations; EncodedValidationCertPubKey = encodedValidationCertPubKey; AccountCredentialDetails = accountCredentialDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Serial number of the assigned device. public string DeviceSerialNumber { get; } + /// Password for out of the box experience on device. public string DevicePassword { get; } + /// Network configuration of the appliance. public IReadOnlyList NetworkConfigurations { get; } + /// The base 64 encoded public key to authenticate with the device. public string EncodedValidationCertPubKey { get; } + /// Per account level access credentials. public IReadOnlyList AccountCredentialDetails { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.Serialization.cs index 03663b5e0cde..f3e3a57874c8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.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.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxShipmentPickUpResult : IUtf8JsonSerializable, IJsonModel + /// Shipment pick up response. + public partial class DataBoxShipmentPickUpResult : 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, 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(DataBoxShipmentPickUpResult)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ConfirmationNumber)) { writer.WritePropertyName("confirmationNumber"u8); @@ -44,15 +45,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("readyByTime"u8); writer.WriteStringValue(ReadyBy.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); } @@ -61,59 +62,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxShipmentPickUpResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxShipmentPickUpResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxShipmentPickUpResult 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(DataBoxShipmentPickUpResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxShipmentPickUpResult(document.RootElement, options); } - internal static DataBoxShipmentPickUpResult DeserializeDataBoxShipmentPickUpResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxShipmentPickUpResult DeserializeDataBoxShipmentPickUpResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string confirmationNumber = default; - DateTimeOffset? readyByTime = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DateTimeOffset? readyBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("confirmationNumber"u8)) + if (prop.NameEquals("confirmationNumber"u8)) { - confirmationNumber = property.Value.GetString(); + confirmationNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("readyByTime"u8)) + if (prop.NameEquals("readyByTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - readyByTime = property.Value.GetDateTimeOffset("O"); + readyBy = 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 DataBoxShipmentPickUpResult(confirmationNumber, readyByTime, serializedAdditionalRawData); + return new DataBoxShipmentPickUpResult(confirmationNumber, readyBy, 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 +130,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - DataBoxShipmentPickUpResult 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. + DataBoxShipmentPickUpResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxShipmentPickUpResult 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 DeserializeDataBoxShipmentPickUpResult(document.RootElement, options); } default: @@ -139,6 +151,14 @@ DataBoxShipmentPickUpResult IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static DataBoxShipmentPickUpResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDataBoxShipmentPickUpResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.cs index c5068ccc3f4a..231af8ce1ff3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShipmentPickUpResult.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Shipment pick up response. public partial class DataBoxShipmentPickUpResult { - /// - /// 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 DataBoxShipmentPickUpResult() @@ -53,16 +24,17 @@ internal DataBoxShipmentPickUpResult() /// Initializes a new instance of . /// Confirmation number for the pick up request. /// Time by which shipment should be ready for pick up, this is in local time of pick up area. - /// Keeps track of any properties unknown to the library. - internal DataBoxShipmentPickUpResult(string confirmationNumber, DateTimeOffset? readyBy, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxShipmentPickUpResult(string confirmationNumber, DateTimeOffset? readyBy, IDictionary additionalBinaryDataProperties) { ConfirmationNumber = confirmationNumber; ReadyBy = readyBy; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Confirmation number for the pick up request. public string ConfirmationNumber { get; } + /// Time by which shipment should be ready for pick up, this is in local time of pick up area. public DateTimeOffset? ReadyBy { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.Serialization.cs index aaabe76f20ad..1b63f51cf18d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxShippingAddress : IUtf8JsonSerializable, IJsonModel + /// Shipping address where customer wishes to receive the device. + public partial class DataBoxShippingAddress : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxShippingAddress() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReader /// 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(DataBoxShippingAddress)} does not support writing '{format}' format."); } - writer.WritePropertyName("streetAddress1"u8); writer.WriteStringValue(StreetAddress1); if (Optional.IsDefined(StreetAddress2)) @@ -88,15 +93,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("taxIdentificationNumber"u8); writer.WriteStringValue(TaxIdentificationNumber); } - 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,22 +110,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxShippingAddress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxShippingAddress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxShippingAddress 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(DataBoxShippingAddress)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxShippingAddress(document.RootElement, options); } - internal static DataBoxShippingAddress DeserializeDataBoxShippingAddress(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxShippingAddress DeserializeDataBoxShippingAddress(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -137,84 +147,82 @@ internal static DataBoxShippingAddress DeserializeDataBoxShippingAddress(JsonEle DataBoxShippingAddressType? addressType = default; bool? skipAddressValidation = default; string taxIdentificationNumber = 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("streetAddress1"u8)) + if (prop.NameEquals("streetAddress1"u8)) { - streetAddress1 = property.Value.GetString(); + streetAddress1 = prop.Value.GetString(); continue; } - if (property.NameEquals("streetAddress2"u8)) + if (prop.NameEquals("streetAddress2"u8)) { - streetAddress2 = property.Value.GetString(); + streetAddress2 = prop.Value.GetString(); continue; } - if (property.NameEquals("streetAddress3"u8)) + if (prop.NameEquals("streetAddress3"u8)) { - streetAddress3 = property.Value.GetString(); + streetAddress3 = prop.Value.GetString(); continue; } - if (property.NameEquals("city"u8)) + if (prop.NameEquals("city"u8)) { - city = property.Value.GetString(); + city = prop.Value.GetString(); continue; } - if (property.NameEquals("stateOrProvince"u8)) + if (prop.NameEquals("stateOrProvince"u8)) { - stateOrProvince = property.Value.GetString(); + stateOrProvince = prop.Value.GetString(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("country"u8)) { - country = property.Value.GetString(); + country = prop.Value.GetString(); continue; } - if (property.NameEquals("postalCode"u8)) + if (prop.NameEquals("postalCode"u8)) { - postalCode = property.Value.GetString(); + postalCode = prop.Value.GetString(); continue; } - if (property.NameEquals("zipExtendedCode"u8)) + if (prop.NameEquals("zipExtendedCode"u8)) { - zipExtendedCode = property.Value.GetString(); + zipExtendedCode = prop.Value.GetString(); continue; } - if (property.NameEquals("companyName"u8)) + if (prop.NameEquals("companyName"u8)) { - companyName = property.Value.GetString(); + companyName = prop.Value.GetString(); continue; } - if (property.NameEquals("addressType"u8)) + if (prop.NameEquals("addressType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - addressType = property.Value.GetString().ToDataBoxShippingAddressType(); + addressType = prop.Value.GetString().ToDataBoxShippingAddressType(); continue; } - if (property.NameEquals("skipAddressValidation"u8)) + if (prop.NameEquals("skipAddressValidation"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - skipAddressValidation = property.Value.GetBoolean(); + skipAddressValidation = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("taxIdentificationNumber"u8)) + if (prop.NameEquals("taxIdentificationNumber"u8)) { - taxIdentificationNumber = property.Value.GetString(); + taxIdentificationNumber = 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 DataBoxShippingAddress( streetAddress1, streetAddress2, @@ -228,13 +236,16 @@ internal static DataBoxShippingAddress DeserializeDataBoxShippingAddress(JsonEle addressType, skipAddressValidation, taxIdentificationNumber, - 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": @@ -244,15 +255,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - DataBoxShippingAddress 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. + DataBoxShippingAddress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxShippingAddress 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 DeserializeDataBoxShippingAddress(document.RootElement, options); } default: @@ -260,6 +276,7 @@ DataBoxShippingAddress IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.cs index f7fa51c651c0..8f4cc9af2f65 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddress.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Shipping address where customer wishes to receive the device. public partial class DataBoxShippingAddress { - /// - /// 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 . /// Street Address line 1. @@ -71,8 +43,8 @@ public DataBoxShippingAddress(string streetAddress1, string country) /// Type of address. /// Flag to indicate if customer has chosen to skip default address validation. /// Tax Identification Number. - /// Keeps track of any properties unknown to the library. - internal DataBoxShippingAddress(string streetAddress1, string streetAddress2, string streetAddress3, string city, string stateOrProvince, string country, string postalCode, string zipExtendedCode, string companyName, DataBoxShippingAddressType? addressType, bool? skipAddressValidation, string taxIdentificationNumber, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxShippingAddress(string streetAddress1, string streetAddress2, string streetAddress3, string city, string stateOrProvince, string country, string postalCode, string zipExtendedCode, string companyName, DataBoxShippingAddressType? addressType, bool? skipAddressValidation, string taxIdentificationNumber, IDictionary additionalBinaryDataProperties) { StreetAddress1 = streetAddress1; StreetAddress2 = streetAddress2; @@ -86,36 +58,42 @@ internal DataBoxShippingAddress(string streetAddress1, string streetAddress2, st AddressType = addressType; SkipAddressValidation = skipAddressValidation; TaxIdentificationNumber = taxIdentificationNumber; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxShippingAddress() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Street Address line 1. public string StreetAddress1 { get; set; } + /// Street Address line 2. public string StreetAddress2 { get; set; } + /// Street Address line 3. public string StreetAddress3 { get; set; } + /// Name of the City. public string City { get; set; } + /// Name of the State or Province. public string StateOrProvince { get; set; } + /// Name of the Country. public string Country { get; set; } + /// Postal code. public string PostalCode { get; set; } + /// Extended Zip Code. public string ZipExtendedCode { get; set; } + /// Name of the company. public string CompanyName { get; set; } + /// Type of address. public DataBoxShippingAddressType? AddressType { get; set; } + /// Flag to indicate if customer has chosen to skip default address validation. public bool? SkipAddressValidation { get; set; } + /// Tax Identification Number. public string TaxIdentificationNumber { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddressType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddressType.Serialization.cs index 0592b1109e4d..18cf85ed435e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddressType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxShippingAddressType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxShippingAddressTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxShippingAddressType value) => value switch { DataBoxShippingAddressType.None => "None", @@ -19,11 +20,21 @@ internal static partial class DataBoxShippingAddressTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxShippingAddressType value.") }; + /// The value to deserialize. public static DataBoxShippingAddressType ToDataBoxShippingAddressType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) return DataBoxShippingAddressType.None; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Residential")) return DataBoxShippingAddressType.Residential; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Commercial")) return DataBoxShippingAddressType.Commercial; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) + { + return DataBoxShippingAddressType.None; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Residential")) + { + return DataBoxShippingAddressType.Residential; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Commercial")) + { + return DataBoxShippingAddressType.Commercial; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxShippingAddressType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.Serialization.cs index 8da985d6588d..b8b17d0b4526 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxSku : IUtf8JsonSerializable, IJsonModel + /// The Sku. + public partial class DataBoxSku : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxSku() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderWriterOption /// 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(DataBoxSku)} does not support writing '{format}' format."); } - writer.WritePropertyName("name"u8); writer.WriteStringValue(Name.ToSerialString()); if (Optional.IsDefined(DisplayName)) @@ -51,15 +56,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("model"u8); writer.WriteStringValue(Model.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); } @@ -68,22 +73,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxSku 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(DataBoxSku)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxSku(document.RootElement, options); } - internal static DataBoxSku DeserializeDataBoxSku(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxSku DeserializeDataBoxSku(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -92,47 +102,48 @@ internal static DataBoxSku DeserializeDataBoxSku(JsonElement element, ModelReade string displayName = default; string family = default; DeviceModelName? model = 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().ToDataBoxSkuName(); + name = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("family"u8)) + if (prop.NameEquals("family"u8)) { - family = property.Value.GetString(); + family = prop.Value.GetString(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + model = prop.Value.GetString().ToDeviceModelName(); 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 DataBoxSku(name, displayName, family, model, serializedAdditionalRawData); + return new DataBoxSku(name, displayName, family, model, 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": @@ -142,15 +153,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) } } - DataBoxSku 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. + DataBoxSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxSku 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 DeserializeDataBoxSku(document.RootElement, options); } default: @@ -158,6 +174,7 @@ DataBoxSku IPersistableModel.Create(BinaryData data, ModelReaderWrit } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.cs index e12428be6d80..8bd14ae36c96 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSku.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// The Sku. public partial class DataBoxSku { - /// - /// 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 sku name. @@ -57,27 +28,25 @@ public DataBoxSku(DataBoxSkuName name) /// The display name of the sku. /// The sku family. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal DataBoxSku(DataBoxSkuName name, string displayName, string family, DeviceModelName? model, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxSku(DataBoxSkuName name, string displayName, string family, DeviceModelName? model, IDictionary additionalBinaryDataProperties) { Name = name; DisplayName = displayName; Family = family; Model = model; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxSku() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The sku name. public DataBoxSkuName Name { get; set; } + /// The display name of the sku. public string DisplayName { get; set; } + /// The sku family. public string Family { get; set; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.Serialization.cs index 000a385d168c..4d6cb1be3ee3 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxSkuCapacity : IUtf8JsonSerializable, IJsonModel + /// Capacity of the sku. + public partial class DataBoxSkuCapacity : 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, ModelReaderWrit /// 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(DataBoxSkuCapacity)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Usable)) { writer.WritePropertyName("usable"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("individualSkuUsable"u8); writer.WriteStringValue(IndividualSkuUsable); } - 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 } } - DataBoxSkuCapacity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxSkuCapacity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxSkuCapacity 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(DataBoxSkuCapacity)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxSkuCapacity(document.RootElement, options); } - internal static DataBoxSkuCapacity DeserializeDataBoxSkuCapacity(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxSkuCapacity DeserializeDataBoxSkuCapacity(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,38 +94,39 @@ internal static DataBoxSkuCapacity DeserializeDataBoxSkuCapacity(JsonElement ele string usable = default; string maximum = default; string individualSkuUsable = 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("usable"u8)) + if (prop.NameEquals("usable"u8)) { - usable = property.Value.GetString(); + usable = prop.Value.GetString(); continue; } - if (property.NameEquals("maximum"u8)) + if (prop.NameEquals("maximum"u8)) { - maximum = property.Value.GetString(); + maximum = prop.Value.GetString(); continue; } - if (property.NameEquals("individualSkuUsable"u8)) + if (prop.NameEquals("individualSkuUsable"u8)) { - individualSkuUsable = property.Value.GetString(); + individualSkuUsable = 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 DataBoxSkuCapacity(usable, maximum, individualSkuUsable, serializedAdditionalRawData); + return new DataBoxSkuCapacity(usable, maximum, individualSkuUsable, 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 +136,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DataBoxSkuCapacity 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. + DataBoxSkuCapacity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxSkuCapacity 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 DeserializeDataBoxSkuCapacity(document.RootElement, options); } default: @@ -146,6 +157,7 @@ DataBoxSkuCapacity IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.cs index f515f172c881..050f8198e14c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCapacity.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Capacity of the sku. public partial class DataBoxSkuCapacity { - /// - /// 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 DataBoxSkuCapacity() @@ -54,19 +25,21 @@ internal DataBoxSkuCapacity() /// Usable capacity in TB. /// Maximum capacity in TB. /// Maximum capacity per device in TB. - /// Keeps track of any properties unknown to the library. - internal DataBoxSkuCapacity(string usable, string maximum, string individualSkuUsable, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxSkuCapacity(string usable, string maximum, string individualSkuUsable, IDictionary additionalBinaryDataProperties) { Usable = usable; Maximum = maximum; IndividualSkuUsable = individualSkuUsable; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Usable capacity in TB. public string Usable { get; } + /// Maximum capacity in TB. public string Maximum { get; } + /// Maximum capacity per device in TB. public string IndividualSkuUsable { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.Serialization.cs index b7193be2113f..8f50dbf7380d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxSkuCost : IUtf8JsonSerializable, IJsonModel + /// Describes metadata for retrieving price info. + public partial class DataBoxSkuCost : 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, ModelReaderWriterOp /// 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(DataBoxSkuCost)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(MeterId)) { writer.WritePropertyName("meterId"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("multiplier"u8); writer.WriteNumberValue(Multiplier.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 } } - DataBoxSkuCost IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxSkuCost IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxSkuCost 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(DataBoxSkuCost)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxSkuCost(document.RootElement, options); } - internal static DataBoxSkuCost DeserializeDataBoxSkuCost(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxSkuCost DeserializeDataBoxSkuCost(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,46 +94,47 @@ internal static DataBoxSkuCost DeserializeDataBoxSkuCost(JsonElement element, Mo Guid? meterId = default; string meterType = default; double? multiplier = 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("meterId"u8)) + if (prop.NameEquals("meterId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - meterId = property.Value.GetGuid(); + meterId = new Guid(prop.Value.GetString()); continue; } - if (property.NameEquals("meterType"u8)) + if (prop.NameEquals("meterType"u8)) { - meterType = property.Value.GetString(); + meterType = prop.Value.GetString(); continue; } - if (property.NameEquals("multiplier"u8)) + if (prop.NameEquals("multiplier"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - multiplier = property.Value.GetDouble(); + multiplier = prop.Value.GetDouble(); 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 DataBoxSkuCost(meterId, meterType, multiplier, serializedAdditionalRawData); + return new DataBoxSkuCost(meterId, meterType, multiplier, 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(ModelReaderWriterOptions opti } } - DataBoxSkuCost 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. + DataBoxSkuCost IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxSkuCost 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 DeserializeDataBoxSkuCost(document.RootElement, options); } default: @@ -154,6 +165,7 @@ DataBoxSkuCost IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.cs index 3b4fd1bdef24..38854c83aaac 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuCost.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Describes metadata for retrieving price info. public partial class DataBoxSkuCost { - /// - /// 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 DataBoxSkuCost() @@ -54,19 +25,21 @@ internal DataBoxSkuCost() /// Meter id of the Sku. /// The type of the meter. /// Multiplier specifies the region specific value to be multiplied with 1$ guid. Eg: Our new regions will be using 1$ shipping guid with appropriate multiplier specific to region. - /// Keeps track of any properties unknown to the library. - internal DataBoxSkuCost(Guid? meterId, string meterType, double? multiplier, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxSkuCost(Guid? meterId, string meterType, double? multiplier, IDictionary additionalBinaryDataProperties) { MeterId = meterId; MeterType = meterType; Multiplier = multiplier; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Meter id of the Sku. public Guid? MeterId { get; } + /// The type of the meter. public string MeterType { get; } + /// Multiplier specifies the region specific value to be multiplied with 1$ guid. Eg: Our new regions will be using 1$ shipping guid with appropriate multiplier specific to region. public double? Multiplier { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.Serialization.cs index 4b9c3faa1321..9014d62ad864 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxSkuInformation : IUtf8JsonSerializable, IJsonModel + /// Information of the sku. + public partial class DataBoxSkuInformation : 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, ModelReaderW /// 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(DataBoxSkuInformation)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Sku)) { writer.WritePropertyName("sku"u8); @@ -44,78 +44,20 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("enabled"u8); writer.WriteBooleanValue(IsEnabled.Value); } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsCollectionDefined(DataLocationToServiceLocationMap)) - { - writer.WritePropertyName("dataLocationToServiceLocationMap"u8); - writer.WriteStartArray(); - foreach (var item in DataLocationToServiceLocationMap) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && Optional.IsDefined(Capacity)) - { - writer.WritePropertyName("capacity"u8); - writer.WriteObjectValue(Capacity, options); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Costs)) - { - writer.WritePropertyName("costs"u8); - writer.WriteStartArray(); - foreach (var item in Costs) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && Optional.IsCollectionDefined(ApiVersions)) - { - writer.WritePropertyName("apiVersions"u8); - writer.WriteStartArray(); - foreach (var item in ApiVersions) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && Optional.IsDefined(DisabledReason)) - { - writer.WritePropertyName("disabledReason"u8); - writer.WriteStringValue(DisabledReason.Value.ToSerialString()); - } - if (options.Format != "W" && Optional.IsDefined(DisabledReasonMessage)) - { - writer.WritePropertyName("disabledReasonMessage"u8); - writer.WriteStringValue(DisabledReasonMessage); - } - if (options.Format != "W" && Optional.IsDefined(RequiredFeature)) + if (options.Format != "W" && Optional.IsDefined(Properties)) { - writer.WritePropertyName("requiredFeature"u8); - writer.WriteStringValue(RequiredFeature); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && Optional.IsCollectionDefined(CountriesWithinCommerceBoundary)) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - writer.WritePropertyName("countriesWithinCommerceBoundary"u8); - writer.WriteStartArray(); - foreach (var item in CountriesWithinCommerceBoundary) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != 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); } @@ -124,178 +66,79 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxSkuInformation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxSkuInformation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxSkuInformation 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(DataBoxSkuInformation)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxSkuInformation(document.RootElement, options); } - internal static DataBoxSkuInformation DeserializeDataBoxSkuInformation(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxSkuInformation DeserializeDataBoxSkuInformation(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxSku sku = default; - bool? enabled = default; - IReadOnlyList dataLocationToServiceLocationMap = default; - DataBoxSkuCapacity capacity = default; - IReadOnlyList costs = default; - IReadOnlyList apiVersions = default; - SkuDisabledReason? disabledReason = default; - string disabledReasonMessage = default; - string requiredFeature = default; - IReadOnlyList countriesWithinCommerceBoundary = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + bool? isEnabled = default; + SkuProperties properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sku"u8)) + if (prop.NameEquals("sku"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sku = DataBoxSku.DeserializeDataBoxSku(property.Value, options); + sku = DataBoxSku.DeserializeDataBoxSku(prop.Value, options); continue; } - if (property.NameEquals("enabled"u8)) + if (prop.NameEquals("enabled"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - enabled = property.Value.GetBoolean(); + isEnabled = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("dataLocationToServiceLocationMap"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(Models.DataLocationToServiceLocationMap.DeserializeDataLocationToServiceLocationMap(item, options)); - } - dataLocationToServiceLocationMap = array; - continue; - } - if (property0.NameEquals("capacity"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - capacity = DataBoxSkuCapacity.DeserializeDataBoxSkuCapacity(property0.Value, options); - continue; - } - if (property0.NameEquals("costs"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(DataBoxSkuCost.DeserializeDataBoxSkuCost(item, options)); - } - costs = array; - continue; - } - if (property0.NameEquals("apiVersions"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - apiVersions = array; - continue; - } - if (property0.NameEquals("disabledReason"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - disabledReason = property0.Value.GetString().ToSkuDisabledReason(); - continue; - } - if (property0.NameEquals("disabledReasonMessage"u8)) - { - disabledReasonMessage = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("requiredFeature"u8)) - { - requiredFeature = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("countriesWithinCommerceBoundary"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - countriesWithinCommerceBoundary = array; - continue; - } - } + properties = SkuProperties.DeserializeSkuProperties(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 DataBoxSkuInformation( - sku, - enabled, - dataLocationToServiceLocationMap ?? new ChangeTrackingList(), - capacity, - costs ?? new ChangeTrackingList(), - apiVersions ?? new ChangeTrackingList(), - disabledReason, - disabledReasonMessage, - requiredFeature, - countriesWithinCommerceBoundary ?? new ChangeTrackingList(), - serializedAdditionalRawData); + return new DataBoxSkuInformation(sku, isEnabled, properties, 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": @@ -305,15 +148,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - DataBoxSkuInformation 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. + DataBoxSkuInformation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxSkuInformation 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 DeserializeDataBoxSkuInformation(document.RootElement, options); } default: @@ -321,6 +169,7 @@ DataBoxSkuInformation IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.cs index 06d42b4562c2..6ae773c6ffa7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuInformation.cs @@ -13,93 +13,106 @@ namespace Azure.ResourceManager.DataBox.Models /// Information of the sku. public partial class DataBoxSkuInformation { - /// - /// 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 DataBoxSkuInformation() { - DataLocationToServiceLocationMap = new ChangeTrackingList(); - Costs = new ChangeTrackingList(); - ApiVersions = new ChangeTrackingList(); - CountriesWithinCommerceBoundary = new ChangeTrackingList(); } /// Initializes a new instance of . /// The Sku. /// The sku is enabled or not. - /// The map of data location to service location. - /// Capacity of the Sku. - /// Cost of the Sku. - /// Api versions that support this Sku. - /// Reason why the Sku is disabled. - /// Message for why the Sku is disabled. - /// Required feature to access the sku. - /// List of all the Countries in the SKU specific commerce boundary. - /// Keeps track of any properties unknown to the library. - internal DataBoxSkuInformation(DataBoxSku sku, bool? isEnabled, IReadOnlyList dataLocationToServiceLocationMap, DataBoxSkuCapacity capacity, IReadOnlyList costs, IReadOnlyList apiVersions, SkuDisabledReason? disabledReason, string disabledReasonMessage, string requiredFeature, IReadOnlyList countriesWithinCommerceBoundary, IDictionary serializedAdditionalRawData) + /// Properties of the sku. + /// Keeps track of any properties unknown to the library. + internal DataBoxSkuInformation(DataBoxSku sku, bool? isEnabled, SkuProperties properties, IDictionary additionalBinaryDataProperties) { Sku = sku; IsEnabled = isEnabled; - DataLocationToServiceLocationMap = dataLocationToServiceLocationMap; - Capacity = capacity; - Costs = costs; - ApiVersions = apiVersions; - DisabledReason = disabledReason; - DisabledReasonMessage = disabledReasonMessage; - RequiredFeature = requiredFeature; - CountriesWithinCommerceBoundary = countriesWithinCommerceBoundary; - _serializedAdditionalRawData = serializedAdditionalRawData; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Sku. public DataBoxSku Sku { get; } + /// The sku is enabled or not. public bool? IsEnabled { get; } + + /// Properties of the sku. + internal SkuProperties Properties { get; } + /// The map of data location to service location. - public IReadOnlyList DataLocationToServiceLocationMap { get; } + public IReadOnlyList DataLocationToServiceLocationMap + { + get + { + return Properties.DataLocationToServiceLocationMap; + } + } + /// Capacity of the Sku. - public DataBoxSkuCapacity Capacity { get; } + public DataBoxSkuCapacity Capacity + { + get + { + return Properties.Capacity; + } + } + /// Cost of the Sku. - public IReadOnlyList Costs { get; } + public IReadOnlyList Costs + { + get + { + return Properties.Costs; + } + } + /// Api versions that support this Sku. - public IReadOnlyList ApiVersions { get; } + public IReadOnlyList ApiVersions + { + get + { + return Properties.ApiVersions; + } + } + /// Reason why the Sku is disabled. - public SkuDisabledReason? DisabledReason { get; } + public SkuDisabledReason? DisabledReason + { + get + { + return Properties.DisabledReason; + } + } + /// Message for why the Sku is disabled. - public string DisabledReasonMessage { get; } + public string DisabledReasonMessage + { + get + { + return Properties.DisabledReasonMessage; + } + } + /// Required feature to access the sku. - public string RequiredFeature { get; } + public string RequiredFeature + { + get + { + return Properties.RequiredFeature; + } + } + /// List of all the Countries in the SKU specific commerce boundary. - public IReadOnlyList CountriesWithinCommerceBoundary { get; } + public IReadOnlyList CountriesWithinCommerceBoundary + { + get + { + return Properties.CountriesWithinCommerceBoundary; + } + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuName.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuName.Serialization.cs index cc7aa354bc9a..d864d0cf742a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuName.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxSkuName.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxSkuNameExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxSkuName value) => value switch { DataBoxSkuName.DataBox => "DataBox", @@ -20,12 +21,25 @@ internal static partial class DataBoxSkuNameExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxSkuName value.") }; + /// The value to deserialize. public static DataBoxSkuName ToDataBoxSkuName(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBox")) return DataBoxSkuName.DataBox; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxDisk")) return DataBoxSkuName.DataBoxDisk; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxHeavy")) return DataBoxSkuName.DataBoxHeavy; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxCustomerDisk")) return DataBoxSkuName.DataBoxCustomerDisk; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBox")) + { + return DataBoxSkuName.DataBox; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxDisk")) + { + return DataBoxSkuName.DataBoxDisk; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxHeavy")) + { + return DataBoxSkuName.DataBoxHeavy; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxCustomerDisk")) + { + return DataBoxSkuName.DataBoxCustomerDisk; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxSkuName value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageName.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageName.cs index a776590f8b8b..91627ec89570 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageName.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageName.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,95 +15,152 @@ namespace Azure.ResourceManager.DataBox.Models public readonly partial struct DataBoxStageName : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DataBoxStageName(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - + /// An order has been created. private const string DeviceOrderedValue = "DeviceOrdered"; + /// A device has been prepared for the order. private const string DevicePreparedValue = "DevicePrepared"; + /// Device has been dispatched to the user of the order. private const string DispatchedValue = "Dispatched"; + /// Device has been delivered to the user of the order. private const string DeliveredValue = "Delivered"; + /// Device has been picked up from user and in transit to Azure datacenter. private const string PickedUpValue = "PickedUp"; + /// Device has been received at Azure datacenter from the user. private const string AtAzureDataCenterValue = "AtAzureDC"; + /// Data copy from the device at Azure datacenter. private const string DataCopyValue = "DataCopy"; + /// Order has completed. private const string CompletedValue = "Completed"; + /// Order has completed with errors. private const string CompletedWithErrorsValue = "CompletedWithErrors"; + /// Order has been cancelled. private const string CancelledValue = "Cancelled"; + /// Order has failed due to issue reported by user. private const string FailedIssueReportedAtCustomerValue = "Failed_IssueReportedAtCustomer"; + /// Order has failed due to issue detected at Azure datacenter. private const string FailedIssueDetectedAtAzureDataCenterValue = "Failed_IssueDetectedAtAzureDC"; + /// Order has been aborted. private const string AbortedValue = "Aborted"; + /// Order has completed with warnings. private const string CompletedWithWarningsValue = "CompletedWithWarnings"; + /// Device is ready to be handed to customer from Azure DC. private const string ReadyToDispatchFromAzureDataCenterValue = "ReadyToDispatchFromAzureDC"; + /// Device can be dropped off at Azure DC. private const string ReadyToReceiveAtAzureDataCenterValue = "ReadyToReceiveAtAzureDC"; + /// Job created by the customer. private const string CreatedValue = "Created"; + /// User shipped the device to AzureDC. private const string ShippedToAzureDataCenterValue = "ShippedToAzureDC"; + /// Awaiting shipment details of device from customer. private const string AwaitingShipmentDetailsValue = "AwaitingShipmentDetails"; + /// Preparing the device to ship to customer. private const string PreparingToShipFromAzureDataCenterValue = "PreparingToShipFromAzureDC"; + /// Shipped the device to customer. private const string ShippedToCustomerValue = "ShippedToCustomer"; + /// Initializes a new instance of . + /// The value. + /// is null. + public DataBoxStageName(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// An order has been created. public static DataBoxStageName DeviceOrdered { get; } = new DataBoxStageName(DeviceOrderedValue); + /// A device has been prepared for the order. public static DataBoxStageName DevicePrepared { get; } = new DataBoxStageName(DevicePreparedValue); + /// Device has been dispatched to the user of the order. public static DataBoxStageName Dispatched { get; } = new DataBoxStageName(DispatchedValue); + /// Device has been delivered to the user of the order. public static DataBoxStageName Delivered { get; } = new DataBoxStageName(DeliveredValue); + /// Device has been picked up from user and in transit to Azure datacenter. public static DataBoxStageName PickedUp { get; } = new DataBoxStageName(PickedUpValue); + /// Device has been received at Azure datacenter from the user. public static DataBoxStageName AtAzureDataCenter { get; } = new DataBoxStageName(AtAzureDataCenterValue); + /// Data copy from the device at Azure datacenter. public static DataBoxStageName DataCopy { get; } = new DataBoxStageName(DataCopyValue); + /// Order has completed. public static DataBoxStageName Completed { get; } = new DataBoxStageName(CompletedValue); + /// Order has completed with errors. public static DataBoxStageName CompletedWithErrors { get; } = new DataBoxStageName(CompletedWithErrorsValue); + /// Order has been cancelled. public static DataBoxStageName Cancelled { get; } = new DataBoxStageName(CancelledValue); + /// Order has failed due to issue reported by user. public static DataBoxStageName FailedIssueReportedAtCustomer { get; } = new DataBoxStageName(FailedIssueReportedAtCustomerValue); + /// Order has failed due to issue detected at Azure datacenter. public static DataBoxStageName FailedIssueDetectedAtAzureDataCenter { get; } = new DataBoxStageName(FailedIssueDetectedAtAzureDataCenterValue); + /// Order has been aborted. public static DataBoxStageName Aborted { get; } = new DataBoxStageName(AbortedValue); + /// Order has completed with warnings. public static DataBoxStageName CompletedWithWarnings { get; } = new DataBoxStageName(CompletedWithWarningsValue); + /// Device is ready to be handed to customer from Azure DC. public static DataBoxStageName ReadyToDispatchFromAzureDataCenter { get; } = new DataBoxStageName(ReadyToDispatchFromAzureDataCenterValue); + /// Device can be dropped off at Azure DC. public static DataBoxStageName ReadyToReceiveAtAzureDataCenter { get; } = new DataBoxStageName(ReadyToReceiveAtAzureDataCenterValue); + /// Job created by the customer. public static DataBoxStageName Created { get; } = new DataBoxStageName(CreatedValue); + /// User shipped the device to AzureDC. public static DataBoxStageName ShippedToAzureDataCenter { get; } = new DataBoxStageName(ShippedToAzureDataCenterValue); + /// Awaiting shipment details of device from customer. public static DataBoxStageName AwaitingShipmentDetails { get; } = new DataBoxStageName(AwaitingShipmentDetailsValue); + /// Preparing the device to ship to customer. public static DataBoxStageName PreparingToShipFromAzureDataCenter { get; } = new DataBoxStageName(PreparingToShipFromAzureDataCenterValue); + /// Shipped the device to customer. public static DataBoxStageName ShippedToCustomer { get; } = new DataBoxStageName(ShippedToCustomerValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DataBoxStageName left, DataBoxStageName 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 !=(DataBoxStageName left, DataBoxStageName right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DataBoxStageName(string value) => new DataBoxStageName(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DataBoxStageName?(string value) => value == null ? null : new DataBoxStageName(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DataBoxStageName other && Equals(other); - /// + + /// public bool Equals(DataBoxStageName 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageStatus.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageStatus.Serialization.cs index f50c39b0213b..85fb450fe0af 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageStatus.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStageStatus.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxStageStatusExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxStageStatus value) => value switch { DataBoxStageStatus.None => "None", @@ -29,21 +30,61 @@ internal static partial class DataBoxStageStatusExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxStageStatus value.") }; + /// The value to deserialize. public static DataBoxStageStatus ToDataBoxStageStatus(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) return DataBoxStageStatus.None; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "InProgress")) return DataBoxStageStatus.InProgress; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Succeeded")) return DataBoxStageStatus.Succeeded; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Failed")) return DataBoxStageStatus.Failed; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Cancelled")) return DataBoxStageStatus.Cancelled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Cancelling")) return DataBoxStageStatus.Cancelling; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "SucceededWithErrors")) return DataBoxStageStatus.SucceededWithErrors; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "WaitingForCustomerAction")) return DataBoxStageStatus.WaitingForCustomerAction; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "SucceededWithWarnings")) return DataBoxStageStatus.SucceededWithWarnings; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "WaitingForCustomerActionForKek")) return DataBoxStageStatus.WaitingForCustomerActionForKek; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "WaitingForCustomerActionForCleanUp")) return DataBoxStageStatus.WaitingForCustomerActionForCleanUp; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerActionPerformedForCleanUp")) return DataBoxStageStatus.CustomerActionPerformedForCleanUp; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerActionPerformed")) return DataBoxStageStatus.CustomerActionPerformed; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) + { + return DataBoxStageStatus.None; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "InProgress")) + { + return DataBoxStageStatus.InProgress; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Succeeded")) + { + return DataBoxStageStatus.Succeeded; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Failed")) + { + return DataBoxStageStatus.Failed; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Cancelled")) + { + return DataBoxStageStatus.Cancelled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Cancelling")) + { + return DataBoxStageStatus.Cancelling; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "SucceededWithErrors")) + { + return DataBoxStageStatus.SucceededWithErrors; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "WaitingForCustomerAction")) + { + return DataBoxStageStatus.WaitingForCustomerAction; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "SucceededWithWarnings")) + { + return DataBoxStageStatus.SucceededWithWarnings; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "WaitingForCustomerActionForKek")) + { + return DataBoxStageStatus.WaitingForCustomerActionForKek; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "WaitingForCustomerActionForCleanUp")) + { + return DataBoxStageStatus.WaitingForCustomerActionForCleanUp; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerActionPerformedForCleanUp")) + { + return DataBoxStageStatus.CustomerActionPerformedForCleanUp; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerActionPerformed")) + { + return DataBoxStageStatus.CustomerActionPerformed; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxStageStatus value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.Serialization.cs index 09f8d9920d4c..96cd8cffd256 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxStorageAccountDetails : IUtf8JsonSerializable, IJsonModel + /// Details for the storage account. + public partial class DataBoxStorageAccountDetails : DataAccountDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxStorageAccountDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,72 +35,77 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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(DataBoxStorageAccountDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("storageAccountId"u8); writer.WriteStringValue(StorageAccountId); } - DataBoxStorageAccountDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxStorageAccountDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxStorageAccountDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataAccountDetails 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(DataBoxStorageAccountDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxStorageAccountDetails(document.RootElement, options); } - internal static DataBoxStorageAccountDetails DeserializeDataBoxStorageAccountDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxStorageAccountDetails DeserializeDataBoxStorageAccountDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier storageAccountId = default; DataAccountType dataAccountType = default; string sharePassword = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResourceIdentifier storageAccountId = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("storageAccountId"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - storageAccountId = new ResourceIdentifier(property.Value.GetString()); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("dataAccountType"u8)) + if (prop.NameEquals("sharePassword"u8)) { - dataAccountType = property.Value.GetString().ToDataAccountType(); + sharePassword = prop.Value.GetString(); continue; } - if (property.NameEquals("sharePassword"u8)) + if (prop.NameEquals("storageAccountId"u8)) { - sharePassword = property.Value.GetString(); + storageAccountId = 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 DataBoxStorageAccountDetails(dataAccountType, sharePassword, serializedAdditionalRawData, storageAccountId); + return new DataBoxStorageAccountDetails(dataAccountType, sharePassword, additionalBinaryDataProperties, storageAccountId); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -103,15 +115,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - DataBoxStorageAccountDetails 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. + DataBoxStorageAccountDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxStorageAccountDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataAccountDetails 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 DeserializeDataBoxStorageAccountDetails(document.RootElement, options); } default: @@ -119,6 +136,7 @@ DataBoxStorageAccountDetails IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.cs index f57782a38441..45582414d910 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxStorageAccountDetails.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -17,28 +18,21 @@ public partial class DataBoxStorageAccountDetails : DataAccountDetails /// Initializes a new instance of . /// Storage Account Resource Id. /// is null. - public DataBoxStorageAccountDetails(ResourceIdentifier storageAccountId) + public DataBoxStorageAccountDetails(ResourceIdentifier storageAccountId) : base(DataAccountType.StorageAccount) { Argument.AssertNotNull(storageAccountId, nameof(storageAccountId)); StorageAccountId = storageAccountId; - DataAccountType = DataAccountType.StorageAccount; } /// Initializes a new instance of . /// Account Type of the data to be transferred. /// Password for all the shares to be created on the device. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Storage Account Resource Id. - internal DataBoxStorageAccountDetails(DataAccountType dataAccountType, string sharePassword, IDictionary serializedAdditionalRawData, ResourceIdentifier storageAccountId) : base(dataAccountType, sharePassword, serializedAdditionalRawData) + internal DataBoxStorageAccountDetails(DataAccountType dataAccountType, string sharePassword, IDictionary additionalBinaryDataProperties, ResourceIdentifier storageAccountId) : base(dataAccountType, sharePassword, additionalBinaryDataProperties) { StorageAccountId = storageAccountId; - DataAccountType = dataAccountType; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxStorageAccountDetails() - { } /// Storage Account Resource Id. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.Serialization.cs index 1adcb2ef8d41..24c0bb061af7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class DataBoxUserAssignedIdentity : IUtf8JsonSerializable, IJsonModel + /// User assigned identity properties. + internal partial class DataBoxUserAssignedIdentity : 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, 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(DataBoxUserAssignedIdentity)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ResourceId)) { writer.WritePropertyName("resourceId"u8); writer.WriteStringValue(ResourceId); } - 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 +57,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxUserAssignedIdentity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxUserAssignedIdentity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxUserAssignedIdentity 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(DataBoxUserAssignedIdentity)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxUserAssignedIdentity(document.RootElement, options); } - internal static DataBoxUserAssignedIdentity DeserializeDataBoxUserAssignedIdentity(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxUserAssignedIdentity DeserializeDataBoxUserAssignedIdentity(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier resourceId = 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)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - resourceId = new ResourceIdentifier(property.Value.GetString()); + resourceId = 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 DataBoxUserAssignedIdentity(resourceId, serializedAdditionalRawData); + return new DataBoxUserAssignedIdentity(resourceId, 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 +119,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - DataBoxUserAssignedIdentity 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. + DataBoxUserAssignedIdentity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxUserAssignedIdentity 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 DeserializeDataBoxUserAssignedIdentity(document.RootElement, options); } default: @@ -128,6 +140,7 @@ DataBoxUserAssignedIdentity IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.cs index 4a88d42b5a4d..7d9e344d1cfe 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxUserAssignedIdentity.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DataBox.Models /// User assigned identity properties. internal partial class DataBoxUserAssignedIdentity { - /// - /// 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 DataBoxUserAssignedIdentity() @@ -53,11 +24,11 @@ public DataBoxUserAssignedIdentity() /// Initializes a new instance of . /// Arm resource id for user assigned identity to be used to fetch MSI token. - /// Keeps track of any properties unknown to the library. - internal DataBoxUserAssignedIdentity(ResourceIdentifier resourceId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxUserAssignedIdentity(ResourceIdentifier resourceId, IDictionary additionalBinaryDataProperties) { ResourceId = resourceId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Arm resource id for user assigned identity to be used to fetch MSI token. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.Serialization.cs index cf4b910ebfb1..6f19ef8bc7c0 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxValidateAddressContent : IUtf8JsonSerializable, IJsonModel + /// The requirements to validate customer address where the device needs to be shipped. + public partial class DataBoxValidateAddressContent : DataBoxValidationInputContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxValidateAddressContent() + { + } + /// 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, 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(DataBoxValidateAddressContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("shippingAddress"u8); writer.WriteObjectValue(ShippingAddress, options); @@ -51,87 +57,93 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataBoxValidateAddressContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidateAddressContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataBoxValidateAddressContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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(DataBoxValidateAddressContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxValidateAddressContent(document.RootElement, options); } - internal static DataBoxValidateAddressContent DeserializeDataBoxValidateAddressContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxValidateAddressContent DeserializeDataBoxValidateAddressContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxValidationInputDiscriminator validationType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); DataBoxShippingAddress shippingAddress = default; DataBoxSkuName deviceType = default; TransportPreferences transportPreferences = default; DeviceModelName? model = default; - DataBoxValidationInputDiscriminator validationType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("validationType"u8)) { - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("deviceType"u8)) + if (prop.NameEquals("shippingAddress"u8)) { - deviceType = property.Value.GetString().ToDataBoxSkuName(); + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("transportPreferences"u8)) + if (prop.NameEquals("deviceType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - transportPreferences = TransportPreferences.DeserializeTransportPreferences(property.Value, options); + deviceType = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("transportPreferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + transportPreferences = TransportPreferences.DeserializeTransportPreferences(prop.Value, options); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("model"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = prop.Value.GetString().ToDeviceModelName(); 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 DataBoxValidateAddressContent( validationType, - serializedAdditionalRawData, + additionalBinaryDataProperties, shippingAddress, deviceType, transportPreferences, model); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -141,15 +153,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - DataBoxValidateAddressContent 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. + DataBoxValidateAddressContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataBoxValidateAddressContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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 DeserializeDataBoxValidateAddressContent(document.RootElement, options); } default: @@ -157,6 +174,19 @@ DataBoxValidateAddressContent IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DataBoxValidateAddressContent dataBoxValidateAddressContent) + { + if (dataBoxValidateAddressContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(dataBoxValidateAddressContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.cs index cd64710c967d..fd00ca3a0795 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidateAddressContent.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -17,42 +18,38 @@ public partial class DataBoxValidateAddressContent : DataBoxValidationInputConte /// Shipping address of the customer. /// Device type to be used for the job. /// is null. - public DataBoxValidateAddressContent(DataBoxShippingAddress shippingAddress, DataBoxSkuName deviceType) + public DataBoxValidateAddressContent(DataBoxShippingAddress shippingAddress, DataBoxSkuName deviceType) : base(DataBoxValidationInputDiscriminator.ValidateAddress) { Argument.AssertNotNull(shippingAddress, nameof(shippingAddress)); ShippingAddress = shippingAddress; DeviceType = deviceType; - ValidationType = DataBoxValidationInputDiscriminator.ValidateAddress; } /// Initializes a new instance of . /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Shipping address of the customer. /// Device type to be used for the job. /// Preferences related to the shipment logistics of the sku. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - internal DataBoxValidateAddressContent(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData, DataBoxShippingAddress shippingAddress, DataBoxSkuName deviceType, TransportPreferences transportPreferences, DeviceModelName? model) : base(validationType, serializedAdditionalRawData) + internal DataBoxValidateAddressContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties, DataBoxShippingAddress shippingAddress, DataBoxSkuName deviceType, TransportPreferences transportPreferences, DeviceModelName? model) : base(validationType, additionalBinaryDataProperties) { ShippingAddress = shippingAddress; DeviceType = deviceType; TransportPreferences = transportPreferences; Model = model; - ValidationType = validationType; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxValidateAddressContent() - { } /// Shipping address of the customer. public DataBoxShippingAddress ShippingAddress { get; } + /// Device type to be used for the job. public DataBoxSkuName DeviceType { get; } + /// Preferences related to the shipment logistics of the sku. public TransportPreferences TransportPreferences { get; set; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.Serialization.cs index d0880d9607f3..e68ccbdb8afa 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.Serialization.cs @@ -9,14 +9,24 @@ using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - [PersistableModelProxy(typeof(UnknownValidationRequest))] - public partial class DataBoxValidationContent : IUtf8JsonSerializable, IJsonModel + /// + /// Minimum request requirement of any validation category. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + [PersistableModelProxy(typeof(UnknownDataBoxValidationContent))] + public abstract partial class DataBoxValidationContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxValidationContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,30 +38,29 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// 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(DataBoxValidationContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("validationCategory"u8); writer.WriteStringValue(ValidationCategory); writer.WritePropertyName("individualRequestDetails"u8); writer.WriteStartArray(); - foreach (var item in IndividualRequestDetails) + foreach (DataBoxValidationInputContent item in IndividualRequestDetails) { 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); } @@ -60,40 +69,49 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxValidationContent 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(DataBoxValidationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxValidationContent(document.RootElement, options); } - internal static DataBoxValidationContent DeserializeDataBoxValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxValidationContent DeserializeDataBoxValidationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("validationCategory", out JsonElement discriminator)) + if (element.TryGetProperty("validationCategory"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "JobCreationValidation": return CreateJobValidationContent.DeserializeCreateJobValidationContent(element, options); + case "JobCreationValidation": + return CreateJobValidationContent.DeserializeCreateJobValidationContent(element, options); } } - return UnknownValidationRequest.DeserializeUnknownValidationRequest(element, options); + return UnknownDataBoxValidationContent.DeserializeUnknownDataBoxValidationContent(element, options); } - 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": @@ -103,15 +121,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - DataBoxValidationContent 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. + DataBoxValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxValidationContent 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 DeserializeDataBoxValidationContent(document.RootElement, options); } default: @@ -119,6 +142,19 @@ DataBoxValidationContent IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DataBoxValidationContent dataBoxValidationContent) + { + if (dataBoxValidationContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(dataBoxValidationContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.cs index 32f8f20d799b..9d9c41c6321d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationContent.cs @@ -13,84 +13,35 @@ namespace Azure.ResourceManager.DataBox.Models { /// /// Minimum request requirement of any validation category. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include . + /// Please note this is the abstract base class. The derived classes available for instantiation are: . /// public abstract partial class DataBoxValidationContent { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - /// - /// List of request details contain validationType and its request as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// - /// is null. - protected DataBoxValidationContent(IEnumerable individualRequestDetails) + /// List of request details contain validationType and its request as key and value respectively. + private protected DataBoxValidationContent(IEnumerable individualRequestDetails) { - Argument.AssertNotNull(individualRequestDetails, nameof(individualRequestDetails)); - IndividualRequestDetails = individualRequestDetails.ToList(); } /// Initializes a new instance of . /// Identify the nature of validation. - /// - /// List of request details contain validationType and its request as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// - /// Keeps track of any properties unknown to the library. - internal DataBoxValidationContent(string validationCategory, IList individualRequestDetails, IDictionary serializedAdditionalRawData) + /// List of request details contain validationType and its request as key and value respectively. + /// Keeps track of any properties unknown to the library. + internal DataBoxValidationContent(string validationCategory, IList individualRequestDetails, IDictionary additionalBinaryDataProperties) { ValidationCategory = validationCategory; IndividualRequestDetails = individualRequestDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataBoxValidationContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Identify the nature of validation. - internal string ValidationCategory { get; set; } - /// - /// List of request details contain validationType and its request as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// + internal string ValidationCategory { get; set; } = "JobCreationValidation"; + + /// List of request details contain validationType and its request as key and value respectively. public IList IndividualRequestDetails { get; } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.Serialization.cs index 4d46a7401e19..62830d5599c7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - [PersistableModelProxy(typeof(UnknownValidationInputRequest))] - public partial class DataBoxValidationInputContent : IUtf8JsonSerializable, IJsonModel + /// + /// Minimum fields that must be present in any type of validation request. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// + [PersistableModelProxy(typeof(UnknownDataBoxValidationInputContent))] + public abstract partial class DataBoxValidationInputContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxValidationInputContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,23 +37,22 @@ 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(DataBoxValidationInputContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("validationType"u8); writer.WriteStringValue(ValidationType.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); } @@ -53,45 +61,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxValidationInputContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidationInputContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxValidationInputContent 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(DataBoxValidationInputContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxValidationInputContent(document.RootElement, options); } - internal static DataBoxValidationInputContent DeserializeDataBoxValidationInputContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxValidationInputContent DeserializeDataBoxValidationInputContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("validationType", out JsonElement discriminator)) + if (element.TryGetProperty("validationType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "ValidateAddress": return DataBoxValidateAddressContent.DeserializeDataBoxValidateAddressContent(element, options); - case "ValidateCreateOrderLimit": return CreateOrderLimitForSubscriptionValidationContent.DeserializeCreateOrderLimitForSubscriptionValidationContent(element, options); - case "ValidateDataTransferDetails": return DataTransferDetailsValidationContent.DeserializeDataTransferDetailsValidationContent(element, options); - case "ValidatePreferences": return PreferencesValidationContent.DeserializePreferencesValidationContent(element, options); - case "ValidateSkuAvailability": return SkuAvailabilityValidationContent.DeserializeSkuAvailabilityValidationContent(element, options); - case "ValidateSubscriptionIsAllowedToCreateJob": return SubscriptionIsAllowedToCreateJobValidationContent.DeserializeSubscriptionIsAllowedToCreateJobValidationContent(element, options); + case "ValidateAddress": + return DataBoxValidateAddressContent.DeserializeDataBoxValidateAddressContent(element, options); + case "ValidateCreateOrderLimit": + return CreateOrderLimitForSubscriptionValidationContent.DeserializeCreateOrderLimitForSubscriptionValidationContent(element, options); + case "ValidateDataTransferDetails": + return DataTransferDetailsValidationContent.DeserializeDataTransferDetailsValidationContent(element, options); + case "ValidatePreferences": + return PreferencesValidationContent.DeserializePreferencesValidationContent(element, options); + case "ValidateSkuAvailability": + return SkuAvailabilityValidationContent.DeserializeSkuAvailabilityValidationContent(element, options); + case "ValidateSubscriptionIsAllowedToCreateJob": + return SubscriptionIsAllowedToCreateJobValidationContent.DeserializeSubscriptionIsAllowedToCreateJobValidationContent(element, options); } } - return UnknownValidationInputRequest.DeserializeUnknownValidationInputRequest(element, options); + return UnknownDataBoxValidationInputContent.DeserializeUnknownDataBoxValidationInputContent(element, options); } - 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": @@ -101,15 +123,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - DataBoxValidationInputContent 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. + DataBoxValidationInputContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxValidationInputContent 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 DeserializeDataBoxValidationInputContent(document.RootElement, options); } default: @@ -117,6 +144,7 @@ DataBoxValidationInputContent IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.cs index f074c32d9ea0..a9cd3b10abd2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputContent.cs @@ -12,55 +12,27 @@ namespace Azure.ResourceManager.DataBox.Models { /// /// Minimum fields that must be present in any type of validation request. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . /// public abstract partial class DataBoxValidationInputContent { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected DataBoxValidationInputContent() + /// Identifies the type of validation request. + private protected DataBoxValidationInputContent(DataBoxValidationInputDiscriminator validationType) { + ValidationType = validationType; } /// Initializes a new instance of . /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. - internal DataBoxValidationInputContent(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxValidationInputContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties) { ValidationType = validationType; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Identifies the type of validation request. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputDiscriminator.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputDiscriminator.Serialization.cs index 92124b134158..853c0d06728a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputDiscriminator.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputDiscriminator.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxValidationInputDiscriminatorExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxValidationInputDiscriminator value) => value switch { DataBoxValidationInputDiscriminator.ValidateAddress => "ValidateAddress", @@ -22,14 +23,33 @@ internal static partial class DataBoxValidationInputDiscriminatorExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxValidationInputDiscriminator value.") }; + /// The value to deserialize. public static DataBoxValidationInputDiscriminator ToDataBoxValidationInputDiscriminator(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateAddress")) return DataBoxValidationInputDiscriminator.ValidateAddress; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateSubscriptionIsAllowedToCreateJob")) return DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidatePreferences")) return DataBoxValidationInputDiscriminator.ValidatePreferences; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateCreateOrderLimit")) return DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateSkuAvailability")) return DataBoxValidationInputDiscriminator.ValidateSkuAvailability; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateDataTransferDetails")) return DataBoxValidationInputDiscriminator.ValidateDataTransferDetails; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateAddress")) + { + return DataBoxValidationInputDiscriminator.ValidateAddress; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateSubscriptionIsAllowedToCreateJob")) + { + return DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidatePreferences")) + { + return DataBoxValidationInputDiscriminator.ValidatePreferences; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateCreateOrderLimit")) + { + return DataBoxValidationInputDiscriminator.ValidateCreateOrderLimit; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateSkuAvailability")) + { + return DataBoxValidationInputDiscriminator.ValidateSkuAvailability; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ValidateDataTransferDetails")) + { + return DataBoxValidationInputDiscriminator.ValidateDataTransferDetails; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxValidationInputDiscriminator value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.Serialization.cs index 27a1e998d766..b9d84e7c1ef7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.Serialization.cs @@ -8,15 +8,25 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - [PersistableModelProxy(typeof(UnknownValidationInputResponse))] - public partial class DataBoxValidationInputResult : IUtf8JsonSerializable, IJsonModel + /// + /// Minimum properties that should be present in each individual validation response. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// + [PersistableModelProxy(typeof(UnknownDataBoxValidationInputResult))] + public abstract partial class DataBoxValidationInputResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataBoxValidationInputResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +38,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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(DataBoxValidationInputResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("validationType"u8); writer.WriteStringValue(ValidationType.ToSerialString()); if (options.Format != "W" && Optional.IsDefined(Error)) @@ -41,15 +50,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("error"u8); ((IJsonModel)Error).Write(writer, 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); } @@ -58,45 +67,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxValidationInputResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidationInputResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxValidationInputResult 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(DataBoxValidationInputResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxValidationInputResult(document.RootElement, options); } - internal static DataBoxValidationInputResult DeserializeDataBoxValidationInputResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxValidationInputResult DeserializeDataBoxValidationInputResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("validationType", out JsonElement discriminator)) + if (element.TryGetProperty("validationType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "ValidateAddress": return AddressValidationResult.DeserializeAddressValidationResult(element, options); - case "ValidateCreateOrderLimit": return CreateOrderLimitForSubscriptionValidationResult.DeserializeCreateOrderLimitForSubscriptionValidationResult(element, options); - case "ValidateDataTransferDetails": return DataTransferDetailsValidationResult.DeserializeDataTransferDetailsValidationResult(element, options); - case "ValidatePreferences": return PreferencesValidationResult.DeserializePreferencesValidationResult(element, options); - case "ValidateSkuAvailability": return SkuAvailabilityValidationResult.DeserializeSkuAvailabilityValidationResult(element, options); - case "ValidateSubscriptionIsAllowedToCreateJob": return SubscriptionIsAllowedToCreateJobValidationResult.DeserializeSubscriptionIsAllowedToCreateJobValidationResult(element, options); + case "ValidateAddress": + return AddressValidationResult.DeserializeAddressValidationResult(element, options); + case "ValidateCreateOrderLimit": + return CreateOrderLimitForSubscriptionValidationResult.DeserializeCreateOrderLimitForSubscriptionValidationResult(element, options); + case "ValidateDataTransferDetails": + return DataTransferDetailsValidationResult.DeserializeDataTransferDetailsValidationResult(element, options); + case "ValidatePreferences": + return PreferencesValidationResult.DeserializePreferencesValidationResult(element, options); + case "ValidateSkuAvailability": + return SkuAvailabilityValidationResult.DeserializeSkuAvailabilityValidationResult(element, options); + case "ValidateSubscriptionIsAllowedToCreateJob": + return SubscriptionIsAllowedToCreateJobValidationResult.DeserializeSubscriptionIsAllowedToCreateJobValidationResult(element, options); } } - return UnknownValidationInputResponse.DeserializeUnknownValidationInputResponse(element, options); + return UnknownDataBoxValidationInputResult.DeserializeUnknownDataBoxValidationInputResult(element, options); } - 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": @@ -106,15 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - DataBoxValidationInputResult 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. + DataBoxValidationInputResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxValidationInputResult 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 DeserializeDataBoxValidationInputResult(document.RootElement, options); } default: @@ -122,6 +150,7 @@ DataBoxValidationInputResult IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.cs index ab3600f1deed..9ccae421c4b9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationInputResult.cs @@ -7,66 +7,40 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { /// /// Minimum properties that should be present in each individual validation response. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . /// public abstract partial class DataBoxValidationInputResult { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected DataBoxValidationInputResult() + /// Identifies the type of validation response. + private protected DataBoxValidationInputResult(DataBoxValidationInputDiscriminator validationType) { + ValidationType = validationType; } /// Initializes a new instance of . /// Identifies the type of validation response. /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. - internal DataBoxValidationInputResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataBoxValidationInputResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties) { ValidationType = validationType; Error = error; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Identifies the type of validation response. internal DataBoxValidationInputDiscriminator ValidationType { get; set; } + /// Error code and message of validation response. public ResponseError Error { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.Serialization.cs index 01c85ac5c097..f3489eb853f2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.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.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataBoxValidationResult : IUtf8JsonSerializable, IJsonModel + /// Response of pre job creation validations. + public partial class DataBoxValidationResult : 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,39 +30,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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(DataBoxValidationResult)} does not support writing '{format}' format."); } - - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(Status)) + if (options.Format != "W" && Optional.IsDefined(Properties)) { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.Value.ToSerialString()); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && Optional.IsCollectionDefined(IndividualResponseDetails)) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - writer.WritePropertyName("individualResponseDetails"u8); - writer.WriteStartArray(); - foreach (var item in IndividualResponseDetails) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != 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); } @@ -69,80 +57,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataBoxValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataBoxValidationResult 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(DataBoxValidationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxValidationResult(document.RootElement, options); } - internal static DataBoxValidationResult DeserializeDataBoxValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataBoxValidationResult DeserializeDataBoxValidationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - OverallValidationStatus? status = default; - IReadOnlyList individualResponseDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ValidationResponseProperties properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("status"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = property0.Value.GetString().ToOverallValidationStatus(); - continue; - } - if (property0.NameEquals("individualResponseDetails"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(DataBoxValidationInputResult.DeserializeDataBoxValidationInputResult(item, options)); - } - individualResponseDetails = array; - continue; - } - } + properties = ValidationResponseProperties.DeserializeValidationResponseProperties(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 DataBoxValidationResult(status, individualResponseDetails ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new DataBoxValidationResult(properties, 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": @@ -152,15 +119,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - DataBoxValidationResult 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. + DataBoxValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataBoxValidationResult 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 DeserializeDataBoxValidationResult(document.RootElement, options); } default: @@ -168,6 +140,14 @@ DataBoxValidationResult IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static DataBoxValidationResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDataBoxValidationResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.cs index 8bef7dbcc720..095b297a245e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationResult.cs @@ -13,66 +13,42 @@ namespace Azure.ResourceManager.DataBox.Models /// Response of pre job creation validations. public partial class DataBoxValidationResult { - /// - /// 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 DataBoxValidationResult() { - IndividualResponseDetails = new ChangeTrackingList(); } /// Initializes a new instance of . - /// Overall validation status. - /// - /// List of response details contain validationType and its response as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// - /// Keeps track of any properties unknown to the library. - internal DataBoxValidationResult(OverallValidationStatus? status, IReadOnlyList individualResponseDetails, IDictionary serializedAdditionalRawData) + /// Properties of pre job creation validation response. + /// Keeps track of any properties unknown to the library. + internal DataBoxValidationResult(ValidationResponseProperties properties, IDictionary additionalBinaryDataProperties) { - Status = status; - IndividualResponseDetails = individualResponseDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + /// Properties of pre job creation validation response. + internal ValidationResponseProperties Properties { get; } + /// Overall validation status. - public OverallValidationStatus? Status { get; } - /// - /// List of response details contain validationType and its response as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// - public IReadOnlyList IndividualResponseDetails { get; } + public OverallValidationStatus? Status + { + get + { + return Properties.Status; + } + } + + /// List of response details contain validationType and its response as key and value respectively. + public IReadOnlyList IndividualResponseDetails + { + get + { + return Properties.IndividualResponseDetails; + } + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationStatus.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationStatus.Serialization.cs index b93b4cd6ff01..de05f94b5f6d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationStatus.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataBoxValidationStatus.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DataBoxValidationStatusExtensions { + /// The value to serialize. public static string ToSerialString(this DataBoxValidationStatus value) => value switch { DataBoxValidationStatus.Valid => "Valid", @@ -19,11 +20,21 @@ internal static partial class DataBoxValidationStatusExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxValidationStatus value.") }; + /// The value to deserialize. public static DataBoxValidationStatus ToDataBoxValidationStatus(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Valid")) return DataBoxValidationStatus.Valid; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Invalid")) return DataBoxValidationStatus.Invalid; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Skipped")) return DataBoxValidationStatus.Skipped; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Valid")) + { + return DataBoxValidationStatus.Valid; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Invalid")) + { + return DataBoxValidationStatus.Invalid; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Skipped")) + { + return DataBoxValidationStatus.Skipped; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DataBoxValidationStatus value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.Serialization.cs index b313ef583027..16c86548e813 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataCenterAccessSecurityCode : IUtf8JsonSerializable, IJsonModel + /// Dc access security code. + public partial class DataCenterAccessSecurityCode : 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, Model /// 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(DataCenterAccessSecurityCode)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ReverseDataCenterAccessCode)) { writer.WritePropertyName("reverseDCAccessCode"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("forwardDCAccessCode"u8); writer.WriteStringValue(ForwardDataCenterAccessCode); } - 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,55 +61,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataCenterAccessSecurityCode IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataCenterAccessSecurityCode IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataCenterAccessSecurityCode 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(DataCenterAccessSecurityCode)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataCenterAccessSecurityCode(document.RootElement, options); } - internal static DataCenterAccessSecurityCode DeserializeDataCenterAccessSecurityCode(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataCenterAccessSecurityCode DeserializeDataCenterAccessSecurityCode(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string reverseDCAccessCode = default; - string forwardDCAccessCode = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string reverseDataCenterAccessCode = default; + string forwardDataCenterAccessCode = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("reverseDCAccessCode"u8)) + if (prop.NameEquals("reverseDCAccessCode"u8)) { - reverseDCAccessCode = property.Value.GetString(); + reverseDataCenterAccessCode = prop.Value.GetString(); continue; } - if (property.NameEquals("forwardDCAccessCode"u8)) + if (prop.NameEquals("forwardDCAccessCode"u8)) { - forwardDCAccessCode = property.Value.GetString(); + forwardDataCenterAccessCode = 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 DataCenterAccessSecurityCode(reverseDCAccessCode, forwardDCAccessCode, serializedAdditionalRawData); + return new DataCenterAccessSecurityCode(reverseDataCenterAccessCode, forwardDataCenterAccessCode, 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": @@ -119,15 +125,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - DataCenterAccessSecurityCode 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. + DataCenterAccessSecurityCode IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataCenterAccessSecurityCode 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 DeserializeDataCenterAccessSecurityCode(document.RootElement, options); } default: @@ -135,6 +146,7 @@ DataCenterAccessSecurityCode IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.cs index a5e2500f3c03..b8981652248c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAccessSecurityCode.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Dc access security code. public partial class DataCenterAccessSecurityCode { - /// - /// 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 DataCenterAccessSecurityCode() @@ -53,16 +24,17 @@ internal DataCenterAccessSecurityCode() /// Initializes a new instance of . /// Reverse Dc access security code. /// Forward Dc access security code. - /// Keeps track of any properties unknown to the library. - internal DataCenterAccessSecurityCode(string reverseDataCenterAccessCode, string forwardDataCenterAccessCode, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataCenterAccessSecurityCode(string reverseDataCenterAccessCode, string forwardDataCenterAccessCode, IDictionary additionalBinaryDataProperties) { ReverseDataCenterAccessCode = reverseDataCenterAccessCode; ForwardDataCenterAccessCode = forwardDataCenterAccessCode; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Reverse Dc access security code. public string ReverseDataCenterAccessCode { get; } + /// Forward Dc access security code. public string ForwardDataCenterAccessCode { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.Serialization.cs index 191495b7a9dd..845e0a880c68 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataCenterAddressContent : IUtf8JsonSerializable, IJsonModel + /// Request body to get the datacenter address. + public partial class DataCenterAddressContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataCenterAddressContent() + { + } + /// 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, ModelRead /// 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(DataCenterAddressContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("storageLocation"u8); writer.WriteStringValue(StorageLocation); writer.WritePropertyName("skuName"u8); @@ -43,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("model"u8); writer.WriteStringValue(Model.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); } @@ -60,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataCenterAddressContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataCenterAddressContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataCenterAddressContent 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(DataCenterAddressContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataCenterAddressContent(document.RootElement, options); } - internal static DataCenterAddressContent DeserializeDataCenterAddressContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataCenterAddressContent DeserializeDataCenterAddressContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -83,42 +94,43 @@ internal static DataCenterAddressContent DeserializeDataCenterAddressContent(Jso AzureLocation storageLocation = default; DataBoxSkuName skuName = default; DeviceModelName? model = 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("storageLocation"u8)) + if (prop.NameEquals("storageLocation"u8)) { - storageLocation = new AzureLocation(property.Value.GetString()); + storageLocation = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("skuName"u8)) + if (prop.NameEquals("skuName"u8)) { - skuName = property.Value.GetString().ToDataBoxSkuName(); + skuName = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + model = prop.Value.GetString().ToDeviceModelName(); 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 DataCenterAddressContent(storageLocation, skuName, model, serializedAdditionalRawData); + return new DataCenterAddressContent(storageLocation, skuName, model, 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(ModelReaderWriterOp } } - DataCenterAddressContent 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. + DataCenterAddressContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataCenterAddressContent 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 DeserializeDataCenterAddressContent(document.RootElement, options); } default: @@ -144,6 +161,7 @@ DataCenterAddressContent IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.cs index 8e73123bb110..bde435657af1 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressContent.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Request body to get the datacenter address. public partial class DataCenterAddressContent { - /// - /// 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 . /// Storage location. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. @@ -59,24 +30,21 @@ public DataCenterAddressContent(AzureLocation storageLocation, DataBoxSkuName sk /// Storage location. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Sku Name for which the data center address requested. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal DataCenterAddressContent(AzureLocation storageLocation, DataBoxSkuName skuName, DeviceModelName? model, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataCenterAddressContent(AzureLocation storageLocation, DataBoxSkuName skuName, DeviceModelName? model, IDictionary additionalBinaryDataProperties) { StorageLocation = storageLocation; SkuName = skuName; Model = model; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataCenterAddressContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Storage location. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. public AzureLocation StorageLocation { get; } + /// Sku Name for which the data center address requested. public DataBoxSkuName SkuName { get; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.Serialization.cs index 27f9839cb856..48693a23642e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataCenterAddressInstructionResult : IUtf8JsonSerializable, IJsonModel + /// Datacenter instruction for given storage location. + public partial class DataCenterAddressInstructionResult : DataCenterAddressResult, 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, /// 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(DataCenterAddressInstructionResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(CommunicationInstruction)) { @@ -42,80 +43,93 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataCenterAddressInstructionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataCenterAddressInstructionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataCenterAddressInstructionResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataCenterAddressResult 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(DataCenterAddressInstructionResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataCenterAddressInstructionResult(document.RootElement, options); } - internal static DataCenterAddressInstructionResult DeserializeDataCenterAddressInstructionResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataCenterAddressInstructionResult DeserializeDataCenterAddressInstructionResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string communicationInstruction = default; DatacenterAddressType datacenterAddressType = default; IReadOnlyList supportedCarriersForReturnShipment = default; AzureLocation? dataCenterAzureLocation = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string communicationInstruction = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("communicationInstruction"u8)) + if (prop.NameEquals("datacenterAddressType"u8)) { - communicationInstruction = property.Value.GetString(); + datacenterAddressType = prop.Value.GetString().ToDatacenterAddressType(); continue; } - if (property.NameEquals("datacenterAddressType"u8)) + if (prop.NameEquals("supportedCarriersForReturnShipment"u8)) { - datacenterAddressType = property.Value.GetString().ToDatacenterAddressType(); - continue; - } - if (property.NameEquals("supportedCarriersForReturnShipment"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()); + } } supportedCarriersForReturnShipment = array; continue; } - if (property.NameEquals("dataCenterAzureLocation"u8)) + if (prop.NameEquals("dataCenterAzureLocation"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataCenterAzureLocation = new AzureLocation(property.Value.GetString()); + dataCenterAzureLocation = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("communicationInstruction"u8)) + { + communicationInstruction = 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 DataCenterAddressInstructionResult(datacenterAddressType, supportedCarriersForReturnShipment ?? new ChangeTrackingList(), dataCenterAzureLocation, serializedAdditionalRawData, communicationInstruction); + return new DataCenterAddressInstructionResult(datacenterAddressType, supportedCarriersForReturnShipment ?? new ChangeTrackingList(), dataCenterAzureLocation, additionalBinaryDataProperties, communicationInstruction); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -125,15 +139,20 @@ BinaryData IPersistableModel.Write(ModelRead } } - DataCenterAddressInstructionResult 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. + DataCenterAddressInstructionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataCenterAddressInstructionResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataCenterAddressResult 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 DeserializeDataCenterAddressInstructionResult(document.RootElement, options); } default: @@ -141,6 +160,7 @@ DataCenterAddressInstructionResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.cs index d91b7d99a4ed..2e12adcefca0 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressInstructionResult.cs @@ -15,21 +15,19 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataCenterAddressInstructionResult : DataCenterAddressResult { /// Initializes a new instance of . - internal DataCenterAddressInstructionResult() + internal DataCenterAddressInstructionResult() : base(DatacenterAddressType.DatacenterAddressInstruction) { - DatacenterAddressType = DatacenterAddressType.DatacenterAddressInstruction; } /// Initializes a new instance of . /// Data center address type. /// List of supported carriers for return shipment. /// Azure Location where the Data Center serves primarily. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Data center communication instruction. - internal DataCenterAddressInstructionResult(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary serializedAdditionalRawData, string communicationInstruction) : base(datacenterAddressType, supportedCarriersForReturnShipment, dataCenterAzureLocation, serializedAdditionalRawData) + internal DataCenterAddressInstructionResult(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary additionalBinaryDataProperties, string communicationInstruction) : base(datacenterAddressType, supportedCarriersForReturnShipment, dataCenterAzureLocation, additionalBinaryDataProperties) { CommunicationInstruction = communicationInstruction; - DatacenterAddressType = datacenterAddressType; } /// Data center communication instruction. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.Serialization.cs index 2740721c5779..63ef202f49c6 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataCenterAddressLocationResult : IUtf8JsonSerializable, IJsonModel + /// Datacenter address for given storage location. + public partial class DataCenterAddressLocationResult : DataCenterAddressResult, 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, Mo /// 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(DataCenterAddressLocationResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(ContactPersonName)) { @@ -102,26 +103,35 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataCenterAddressLocationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataCenterAddressLocationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataCenterAddressLocationResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataCenterAddressResult 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(DataCenterAddressLocationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataCenterAddressLocationResult(document.RootElement, options); } - internal static DataCenterAddressLocationResult DeserializeDataCenterAddressLocationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataCenterAddressLocationResult DeserializeDataCenterAddressLocationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DatacenterAddressType datacenterAddressType = default; + IReadOnlyList supportedCarriersForReturnShipment = default; + AzureLocation? dataCenterAzureLocation = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string contactPersonName = default; string company = default; string street1 = default; @@ -135,117 +145,118 @@ internal static DataCenterAddressLocationResult DeserializeDataCenterAddressLoca string phoneExtension = default; string addressType = default; string additionalShippingInformation = default; - DatacenterAddressType datacenterAddressType = default; - IReadOnlyList supportedCarriersForReturnShipment = default; - AzureLocation? dataCenterAzureLocation = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("contactPersonName"u8)) + if (prop.NameEquals("datacenterAddressType"u8)) { - contactPersonName = property.Value.GetString(); + datacenterAddressType = prop.Value.GetString().ToDatacenterAddressType(); continue; } - if (property.NameEquals("company"u8)) + if (prop.NameEquals("supportedCarriersForReturnShipment"u8)) { - company = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + supportedCarriersForReturnShipment = array; continue; } - if (property.NameEquals("street1"u8)) + if (prop.NameEquals("dataCenterAzureLocation"u8)) { - street1 = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataCenterAzureLocation = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("street2"u8)) + if (prop.NameEquals("contactPersonName"u8)) { - street2 = property.Value.GetString(); + contactPersonName = prop.Value.GetString(); continue; } - if (property.NameEquals("street3"u8)) + if (prop.NameEquals("company"u8)) { - street3 = property.Value.GetString(); + company = prop.Value.GetString(); continue; } - if (property.NameEquals("city"u8)) + if (prop.NameEquals("street1"u8)) { - city = property.Value.GetString(); + street1 = prop.Value.GetString(); continue; } - if (property.NameEquals("state"u8)) + if (prop.NameEquals("street2"u8)) { - state = property.Value.GetString(); + street2 = prop.Value.GetString(); continue; } - if (property.NameEquals("zip"u8)) + if (prop.NameEquals("street3"u8)) { - zip = property.Value.GetString(); + street3 = prop.Value.GetString(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("city"u8)) { - country = property.Value.GetString(); + city = prop.Value.GetString(); continue; } - if (property.NameEquals("phone"u8)) + if (prop.NameEquals("state"u8)) { - phone = property.Value.GetString(); + state = prop.Value.GetString(); continue; } - if (property.NameEquals("phoneExtension"u8)) + if (prop.NameEquals("zip"u8)) { - phoneExtension = property.Value.GetString(); + zip = prop.Value.GetString(); continue; } - if (property.NameEquals("addressType"u8)) + if (prop.NameEquals("country"u8)) { - addressType = property.Value.GetString(); + country = prop.Value.GetString(); continue; } - if (property.NameEquals("additionalShippingInformation"u8)) + if (prop.NameEquals("phone"u8)) { - additionalShippingInformation = property.Value.GetString(); + phone = prop.Value.GetString(); continue; } - if (property.NameEquals("datacenterAddressType"u8)) + if (prop.NameEquals("phoneExtension"u8)) { - datacenterAddressType = property.Value.GetString().ToDatacenterAddressType(); + phoneExtension = prop.Value.GetString(); continue; } - if (property.NameEquals("supportedCarriersForReturnShipment"u8)) + if (prop.NameEquals("addressType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - supportedCarriersForReturnShipment = array; + addressType = prop.Value.GetString(); continue; } - if (property.NameEquals("dataCenterAzureLocation"u8)) + if (prop.NameEquals("additionalShippingInformation"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dataCenterAzureLocation = new AzureLocation(property.Value.GetString()); + additionalShippingInformation = 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 DataCenterAddressLocationResult( datacenterAddressType, supportedCarriersForReturnShipment ?? new ChangeTrackingList(), dataCenterAzureLocation, - serializedAdditionalRawData, + additionalBinaryDataProperties, contactPersonName, company, street1, @@ -261,10 +272,13 @@ internal static DataCenterAddressLocationResult DeserializeDataCenterAddressLoca additionalShippingInformation); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -274,15 +288,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DataCenterAddressLocationResult 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. + DataCenterAddressLocationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataCenterAddressLocationResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataCenterAddressResult 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 DeserializeDataCenterAddressLocationResult(document.RootElement, options); } default: @@ -290,6 +309,7 @@ DataCenterAddressLocationResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.cs index 83d618e6576c..2ed8dcdc683e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressLocationResult.cs @@ -15,16 +15,15 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataCenterAddressLocationResult : DataCenterAddressResult { /// Initializes a new instance of . - internal DataCenterAddressLocationResult() + internal DataCenterAddressLocationResult() : base(DatacenterAddressType.DatacenterAddressLocation) { - DatacenterAddressType = DatacenterAddressType.DatacenterAddressLocation; } /// Initializes a new instance of . /// Data center address type. /// List of supported carriers for return shipment. /// Azure Location where the Data Center serves primarily. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Contact person name. /// Company name. /// Street address line 1. @@ -38,7 +37,7 @@ internal DataCenterAddressLocationResult() /// Phone extension. /// Address type. /// Special instruction for shipping. - internal DataCenterAddressLocationResult(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary serializedAdditionalRawData, string contactPersonName, string company, string street1, string street2, string street3, string city, string state, string zip, string country, string phone, string phoneExtension, string addressType, string additionalShippingInformation) : base(datacenterAddressType, supportedCarriersForReturnShipment, dataCenterAzureLocation, serializedAdditionalRawData) + internal DataCenterAddressLocationResult(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary additionalBinaryDataProperties, string contactPersonName, string company, string street1, string street2, string street3, string city, string state, string zip, string country, string phone, string phoneExtension, string addressType, string additionalShippingInformation) : base(datacenterAddressType, supportedCarriersForReturnShipment, dataCenterAzureLocation, additionalBinaryDataProperties) { ContactPersonName = contactPersonName; Company = company; @@ -53,33 +52,44 @@ internal DataCenterAddressLocationResult(DatacenterAddressType datacenterAddress PhoneExtension = phoneExtension; AddressType = addressType; AdditionalShippingInformation = additionalShippingInformation; - DatacenterAddressType = datacenterAddressType; } /// Contact person name. public string ContactPersonName { get; } + /// Company name. public string Company { get; } + /// Street address line 1. public string Street1 { get; } + /// Street address line 2. public string Street2 { get; } + /// Street address line 3. public string Street3 { get; } + /// City name. public string City { get; } + /// name of the state. public string State { get; } + /// Zip code. public string Zip { get; } + /// name of the country. public string Country { get; } + /// Phone number. public string Phone { get; } + /// Phone extension. public string PhoneExtension { get; } + /// Address type. public string AddressType { get; } + /// Special instruction for shipping. public string AdditionalShippingInformation { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.Serialization.cs index dba6ae0ef29d..45600853bbe1 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - [PersistableModelProxy(typeof(UnknownDataCenterAddressResponse))] - public partial class DataCenterAddressResult : IUtf8JsonSerializable, IJsonModel + /// + /// Datacenter address for given storage location. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + [PersistableModelProxy(typeof(UnknownDataCenterAddressResult))] + public abstract partial class DataCenterAddressResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataCenterAddressResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,20 +37,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// 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(DataCenterAddressResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("datacenterAddressType"u8); writer.WriteStringValue(DatacenterAddressType.ToSerialString()); if (options.Format != "W" && Optional.IsCollectionDefined(SupportedCarriersForReturnShipment)) { writer.WritePropertyName("supportedCarriersForReturnShipment"u8); writer.WriteStartArray(); - foreach (var item in SupportedCarriersForReturnShipment) + foreach (string item in SupportedCarriersForReturnShipment) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -51,15 +64,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("dataCenterAzureLocation"u8); writer.WriteStringValue(DataCenterAzureLocation.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); } @@ -68,41 +81,51 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataCenterAddressResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataCenterAddressResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataCenterAddressResult 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(DataCenterAddressResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataCenterAddressResult(document.RootElement, options); } - internal static DataCenterAddressResult DeserializeDataCenterAddressResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataCenterAddressResult DeserializeDataCenterAddressResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("datacenterAddressType", out JsonElement discriminator)) + if (element.TryGetProperty("datacenterAddressType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "DatacenterAddressInstruction": return DataCenterAddressInstructionResult.DeserializeDataCenterAddressInstructionResult(element, options); - case "DatacenterAddressLocation": return DataCenterAddressLocationResult.DeserializeDataCenterAddressLocationResult(element, options); + case "DatacenterAddressInstruction": + return DataCenterAddressInstructionResult.DeserializeDataCenterAddressInstructionResult(element, options); + case "DatacenterAddressLocation": + return DataCenterAddressLocationResult.DeserializeDataCenterAddressLocationResult(element, options); } } - return UnknownDataCenterAddressResponse.DeserializeUnknownDataCenterAddressResponse(element, options); + return UnknownDataCenterAddressResult.DeserializeUnknownDataCenterAddressResult(element, options); } - 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 +135,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - DataCenterAddressResult 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. + DataCenterAddressResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataCenterAddressResult 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 DeserializeDataCenterAddressResult(document.RootElement, options); } default: @@ -128,6 +156,7 @@ DataCenterAddressResult IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.cs index c6d9d2e15e17..7f878893329f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterAddressResult.cs @@ -8,51 +8,24 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// /// Datacenter address for given storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . /// public abstract partial class DataCenterAddressResult { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected DataCenterAddressResult() + /// Data center address type. + private protected DataCenterAddressResult(DatacenterAddressType datacenterAddressType) { + DatacenterAddressType = datacenterAddressType; SupportedCarriersForReturnShipment = new ChangeTrackingList(); } @@ -60,19 +33,21 @@ protected DataCenterAddressResult() /// Data center address type. /// List of supported carriers for return shipment. /// Azure Location where the Data Center serves primarily. - /// Keeps track of any properties unknown to the library. - internal DataCenterAddressResult(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataCenterAddressResult(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary additionalBinaryDataProperties) { DatacenterAddressType = datacenterAddressType; SupportedCarriersForReturnShipment = supportedCarriersForReturnShipment; DataCenterAzureLocation = dataCenterAzureLocation; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Data center address type. internal DatacenterAddressType DatacenterAddressType { get; set; } + /// List of supported carriers for return shipment. public IReadOnlyList SupportedCarriersForReturnShipment { get; } + /// Azure Location where the Data Center serves primarily. public AzureLocation? DataCenterAzureLocation { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterCode.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterCode.cs index 103f2b4a78aa..3cc549fc9a1f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterCode.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataCenterCode.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,14 +15,6 @@ namespace Azure.ResourceManager.DataBox.Models public readonly partial struct DataCenterCode : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DataCenterCode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - private const string InvalidValue = "Invalid"; private const string BY2Value = "BY2"; private const string BY1Value = "BY1"; @@ -82,7 +75,7 @@ public DataCenterCode(string value) private const string SN6Value = "SN6"; private const string BJS20Value = "BJS20"; private const string BL24Value = "BL24"; - private const string IdC5Value = "IDC5"; + private const string IDC5Value = "IDC5"; private const string TYO23Value = "TYO23"; private const string NTG20Value = "NTG20"; private const string DXB23Value = "DXB23"; @@ -91,159 +84,250 @@ public DataCenterCode(string value) private const string CPQ21Value = "CPQ21"; private const string OSA23Value = "OSA23"; - /// Invalid. + /// Initializes a new instance of . + /// The value. + /// is null. + public DataCenterCode(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Invalid. public static DataCenterCode Invalid { get; } = new DataCenterCode(InvalidValue); - /// BY2. + + /// Gets the BY2. public static DataCenterCode BY2 { get; } = new DataCenterCode(BY2Value); - /// BY1. + + /// Gets the BY1. public static DataCenterCode BY1 { get; } = new DataCenterCode(BY1Value); - /// ORK70. + + /// Gets the ORK70. public static DataCenterCode ORK70 { get; } = new DataCenterCode(ORK70Value); - /// AM2. + + /// Gets the AM2. public static DataCenterCode AM2 { get; } = new DataCenterCode(AM2Value); - /// AMS20. + + /// Gets the AMS20. public static DataCenterCode AMS20 { get; } = new DataCenterCode(AMS20Value); - /// BY21. + + /// Gets the BY21. public static DataCenterCode BY21 { get; } = new DataCenterCode(BY21Value); - /// BY24. + + /// Gets the BY24. public static DataCenterCode BY24 { get; } = new DataCenterCode(BY24Value); - /// MWH01. + + /// Gets the MWH01. public static DataCenterCode MWH01 { get; } = new DataCenterCode(MWH01Value); - /// AMS06. + + /// Gets the AMS06. public static DataCenterCode AMS06 { get; } = new DataCenterCode(AMS06Value); - /// SSE90. + + /// Gets the SSE90. public static DataCenterCode SSE90 { get; } = new DataCenterCode(SSE90Value); - /// SYD03. + + /// Gets the SYD03. public static DataCenterCode SYD03 { get; } = new DataCenterCode(SYD03Value); - /// SYD23. + + /// Gets the SYD23. public static DataCenterCode SYD23 { get; } = new DataCenterCode(SYD23Value); - /// CBR20. + + /// Gets the CBR20. public static DataCenterCode CBR20 { get; } = new DataCenterCode(CBR20Value); - /// YTO20. + + /// Gets the YTO20. public static DataCenterCode YTO20 { get; } = new DataCenterCode(YTO20Value); - /// CWL20. + + /// Gets the CWL20. public static DataCenterCode CWL20 { get; } = new DataCenterCode(CWL20Value); - /// LON24. + + /// Gets the LON24. public static DataCenterCode LON24 { get; } = new DataCenterCode(LON24Value); - /// BOM01. + + /// Gets the BOM01. public static DataCenterCode BOM01 { get; } = new DataCenterCode(BOM01Value); - /// BL20. + + /// Gets the BL20. public static DataCenterCode BL20 { get; } = new DataCenterCode(BL20Value); - /// BL7. + + /// Gets the BL7. public static DataCenterCode BL7 { get; } = new DataCenterCode(BL7Value); - /// SEL20. + + /// Gets the SEL20. public static DataCenterCode SEL20 { get; } = new DataCenterCode(SEL20Value); - /// TYO01. + + /// Gets the TYO01. public static DataCenterCode TYO01 { get; } = new DataCenterCode(TYO01Value); - /// BN1. + + /// Gets the BN1. public static DataCenterCode BN1 { get; } = new DataCenterCode(BN1Value); - /// SN5. + + /// Gets the SN5. public static DataCenterCode SN5 { get; } = new DataCenterCode(SN5Value); - /// CYS04. + + /// Gets the CYS04. public static DataCenterCode CYS04 { get; } = new DataCenterCode(CYS04Value); - /// TYO22. + + /// Gets the TYO22. public static DataCenterCode TYO22 { get; } = new DataCenterCode(TYO22Value); - /// YTO21. + + /// Gets the YTO21. public static DataCenterCode YTO21 { get; } = new DataCenterCode(YTO21Value); - /// YQB20. + + /// Gets the YQB20. public static DataCenterCode YQB20 { get; } = new DataCenterCode(YQB20Value); - /// FRA22. + + /// Gets the FRA22. public static DataCenterCode FRA22 { get; } = new DataCenterCode(FRA22Value); - /// MAA01. + + /// Gets the MAA01. public static DataCenterCode MAA01 { get; } = new DataCenterCode(MAA01Value); - /// CPQ02. + + /// Gets the CPQ02. public static DataCenterCode CPQ02 { get; } = new DataCenterCode(CPQ02Value); - /// CPQ20. + + /// Gets the CPQ20. public static DataCenterCode CPQ20 { get; } = new DataCenterCode(CPQ20Value); - /// SIN20. + + /// Gets the SIN20. public static DataCenterCode SIN20 { get; } = new DataCenterCode(SIN20Value); - /// HKG20. + + /// Gets the HKG20. public static DataCenterCode HKG20 { get; } = new DataCenterCode(HKG20Value); - /// SG2. + + /// Gets the SG2. public static DataCenterCode SG2 { get; } = new DataCenterCode(SG2Value); - /// MEL23. + + /// Gets the MEL23. public static DataCenterCode MEL23 { get; } = new DataCenterCode(MEL23Value); - /// SEL21. + + /// Gets the SEL21. public static DataCenterCode SEL21 { get; } = new DataCenterCode(SEL21Value); - /// OSA20. + + /// Gets the OSA20. public static DataCenterCode OSA20 { get; } = new DataCenterCode(OSA20Value); - /// SHA03. + + /// Gets the SHA03. public static DataCenterCode SHA03 { get; } = new DataCenterCode(SHA03Value); - /// BJB. + + /// Gets the BJB. public static DataCenterCode BJB { get; } = new DataCenterCode(BJBValue); - /// JNB22. + + /// Gets the JNB22. public static DataCenterCode JNB22 { get; } = new DataCenterCode(JNB22Value); - /// JNB21. + + /// Gets the JNB21. public static DataCenterCode JNB21 { get; } = new DataCenterCode(JNB21Value); - /// MNZ21. + + /// Gets the MNZ21. public static DataCenterCode MNZ21 { get; } = new DataCenterCode(MNZ21Value); - /// SN8. + + /// Gets the SN8. public static DataCenterCode SN8 { get; } = new DataCenterCode(SN8Value); - /// AUH20. + + /// Gets the AUH20. public static DataCenterCode AUH20 { get; } = new DataCenterCode(AUH20Value); - /// ZRH20. + + /// Gets the ZRH20. public static DataCenterCode ZRH20 { get; } = new DataCenterCode(ZRH20Value); - /// PUS20. + + /// Gets the PUS20. public static DataCenterCode PUS20 { get; } = new DataCenterCode(PUS20Value); - /// AdHoc. + + /// Gets the AdHoc. public static DataCenterCode AdHoc { get; } = new DataCenterCode(AdHocValue); - /// CH1. + + /// Gets the CH1. public static DataCenterCode CH1 { get; } = new DataCenterCode(CH1Value); - /// DSM05. + + /// Gets the DSM05. public static DataCenterCode DSM05 { get; } = new DataCenterCode(DSM05Value); - /// DUB07. + + /// Gets the DUB07. public static DataCenterCode DUB07 { get; } = new DataCenterCode(DUB07Value); - /// PNQ01. + + /// Gets the PNQ01. public static DataCenterCode PNQ01 { get; } = new DataCenterCode(PNQ01Value); - /// SVG20. + + /// Gets the SVG20. public static DataCenterCode SVG20 { get; } = new DataCenterCode(SVG20Value); - /// OSA02. + + /// Gets the OSA02. public static DataCenterCode OSA02 { get; } = new DataCenterCode(OSA02Value); - /// OSA22. + + /// Gets the OSA22. public static DataCenterCode OSA22 { get; } = new DataCenterCode(OSA22Value); - /// PAR22. + + /// Gets the PAR22. public static DataCenterCode PAR22 { get; } = new DataCenterCode(PAR22Value); - /// BN7. + + /// Gets the BN7. public static DataCenterCode BN7 { get; } = new DataCenterCode(BN7Value); - /// SN6. + + /// Gets the SN6. public static DataCenterCode SN6 { get; } = new DataCenterCode(SN6Value); - /// BJS20. + + /// Gets the BJS20. public static DataCenterCode BJS20 { get; } = new DataCenterCode(BJS20Value); - /// BL24. + + /// Gets the BL24. public static DataCenterCode BL24 { get; } = new DataCenterCode(BL24Value); - /// IDC5. - public static DataCenterCode IdC5 { get; } = new DataCenterCode(IdC5Value); - /// TYO23. + + /// Gets the IDC5. + public static DataCenterCode IDC5 { get; } = new DataCenterCode(IDC5Value); + + /// Gets the TYO23. public static DataCenterCode TYO23 { get; } = new DataCenterCode(TYO23Value); - /// NTG20. + + /// Gets the NTG20. public static DataCenterCode NTG20 { get; } = new DataCenterCode(NTG20Value); - /// DXB23. + + /// Gets the DXB23. public static DataCenterCode DXB23 { get; } = new DataCenterCode(DXB23Value); - /// DSM11. + + /// Gets the DSM11. public static DataCenterCode DSM11 { get; } = new DataCenterCode(DSM11Value); - /// AMS25. + + /// Gets the AMS25. public static DataCenterCode AMS25 { get; } = new DataCenterCode(AMS25Value); - /// CPQ21. + + /// Gets the CPQ21. public static DataCenterCode CPQ21 { get; } = new DataCenterCode(CPQ21Value); - /// OSA23. + + /// Gets the OSA23. public static DataCenterCode OSA23 { get; } = new DataCenterCode(OSA23Value); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DataCenterCode left, DataCenterCode 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 !=(DataCenterCode left, DataCenterCode right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DataCenterCode(string value) => new DataCenterCode(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DataCenterCode?(string value) => value == null ? null : new DataCenterCode(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DataCenterCode other && Equals(other); - /// + + /// public bool Equals(DataCenterCode 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.Serialization.cs index 89663e5ecc34..6ecb95607aab 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataExportDetails : IUtf8JsonSerializable, IJsonModel + /// Details of the data to be used for exporting data from azure. + public partial class DataExportDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataExportDetails() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(DataExportDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("transferConfiguration"u8); writer.WriteObjectValue(TransferConfiguration, options); if (Optional.IsDefined(LogCollectionLevel)) @@ -43,15 +48,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName("accountDetails"u8); writer.WriteObjectValue(AccountDetails, 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,22 +65,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataExportDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataExportDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataExportDetails 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(DataExportDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataExportDetails(document.RootElement, options); } - internal static DataExportDetails DeserializeDataExportDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataExportDetails DeserializeDataExportDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -83,42 +93,43 @@ internal static DataExportDetails DeserializeDataExportDetails(JsonElement eleme TransferConfiguration transferConfiguration = default; LogCollectionLevel? logCollectionLevel = default; DataAccountDetails accountDetails = 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("transferConfiguration"u8)) + if (prop.NameEquals("transferConfiguration"u8)) { - transferConfiguration = TransferConfiguration.DeserializeTransferConfiguration(property.Value, options); + transferConfiguration = TransferConfiguration.DeserializeTransferConfiguration(prop.Value, options); continue; } - if (property.NameEquals("logCollectionLevel"u8)) + if (prop.NameEquals("logCollectionLevel"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - logCollectionLevel = property.Value.GetString().ToLogCollectionLevel(); + logCollectionLevel = prop.Value.GetString().ToLogCollectionLevel(); continue; } - if (property.NameEquals("accountDetails"u8)) + if (prop.NameEquals("accountDetails"u8)) { - accountDetails = DataAccountDetails.DeserializeDataAccountDetails(property.Value, options); + accountDetails = DataAccountDetails.DeserializeDataAccountDetails(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 DataExportDetails(transferConfiguration, logCollectionLevel, accountDetails, serializedAdditionalRawData); + return new DataExportDetails(transferConfiguration, logCollectionLevel, accountDetails, 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 +139,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - DataExportDetails 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. + DataExportDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataExportDetails 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 DeserializeDataExportDetails(document.RootElement, options); } default: @@ -144,6 +160,7 @@ DataExportDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.cs index ada0ee9299d7..edba539085c9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataExportDetails.cs @@ -7,51 +7,19 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Details of the data to be used for exporting data from azure. public partial class DataExportDetails { - /// - /// 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 . /// Configuration for the data transfer. - /// - /// Account details of the data to be transferred - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Account details of the data to be transferred. /// or is null. public DataExportDetails(TransferConfiguration transferConfiguration, DataAccountDetails accountDetails) { @@ -65,34 +33,23 @@ public DataExportDetails(TransferConfiguration transferConfiguration, DataAccoun /// Initializes a new instance of . /// Configuration for the data transfer. /// Level of the logs to be collected. - /// - /// Account details of the data to be transferred - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// - /// Keeps track of any properties unknown to the library. - internal DataExportDetails(TransferConfiguration transferConfiguration, LogCollectionLevel? logCollectionLevel, DataAccountDetails accountDetails, IDictionary serializedAdditionalRawData) + /// Account details of the data to be transferred. + /// Keeps track of any properties unknown to the library. + internal DataExportDetails(TransferConfiguration transferConfiguration, LogCollectionLevel? logCollectionLevel, DataAccountDetails accountDetails, IDictionary additionalBinaryDataProperties) { TransferConfiguration = transferConfiguration; LogCollectionLevel = logCollectionLevel; AccountDetails = accountDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DataExportDetails() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Configuration for the data transfer. public TransferConfiguration TransferConfiguration { get; set; } + /// Level of the logs to be collected. public LogCollectionLevel? LogCollectionLevel { get; set; } - /// - /// Account details of the data to be transferred - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + + /// Account details of the data to be transferred. public DataAccountDetails AccountDetails { get; set; } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.Serialization.cs index 20600cd94ebc..be4293f05c62 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataImportDetails : IUtf8JsonSerializable, IJsonModel + /// Details of the data to be used for importing data to azure. + public partial class DataImportDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataImportDetails() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(DataImportDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("accountDetails"u8); writer.WriteObjectValue(AccountDetails, options); if (Optional.IsDefined(LogCollectionLevel)) @@ -41,15 +46,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("logCollectionLevel"u8); writer.WriteStringValue(LogCollectionLevel.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); } @@ -58,59 +63,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataImportDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataImportDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataImportDetails 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(DataImportDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataImportDetails(document.RootElement, options); } - internal static DataImportDetails DeserializeDataImportDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataImportDetails DeserializeDataImportDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataAccountDetails accountDetails = default; LogCollectionLevel? logCollectionLevel = 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("accountDetails"u8)) + if (prop.NameEquals("accountDetails"u8)) { - accountDetails = DataAccountDetails.DeserializeDataAccountDetails(property.Value, options); + accountDetails = DataAccountDetails.DeserializeDataAccountDetails(prop.Value, options); continue; } - if (property.NameEquals("logCollectionLevel"u8)) + if (prop.NameEquals("logCollectionLevel"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - logCollectionLevel = property.Value.GetString().ToLogCollectionLevel(); + logCollectionLevel = prop.Value.GetString().ToLogCollectionLevel(); 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 DataImportDetails(accountDetails, logCollectionLevel, serializedAdditionalRawData); + return new DataImportDetails(accountDetails, logCollectionLevel, 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": @@ -120,15 +131,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - DataImportDetails 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. + DataImportDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataImportDetails 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 DeserializeDataImportDetails(document.RootElement, options); } default: @@ -136,6 +152,7 @@ DataImportDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.cs index e7877d491611..26da12d1db77 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataImportDetails.cs @@ -7,50 +7,18 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Details of the data to be used for importing data to azure. public partial class DataImportDetails { - /// - /// 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 . - /// - /// Account details of the data to be transferred - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Account details of the data to be transferred. /// is null. public DataImportDetails(DataAccountDetails accountDetails) { @@ -60,31 +28,19 @@ public DataImportDetails(DataAccountDetails accountDetails) } /// Initializes a new instance of . - /// - /// Account details of the data to be transferred - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Account details of the data to be transferred. /// Level of the logs to be collected. - /// Keeps track of any properties unknown to the library. - internal DataImportDetails(DataAccountDetails accountDetails, LogCollectionLevel? logCollectionLevel, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataImportDetails(DataAccountDetails accountDetails, LogCollectionLevel? logCollectionLevel, IDictionary additionalBinaryDataProperties) { AccountDetails = accountDetails; LogCollectionLevel = logCollectionLevel; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// Initializes a new instance of for deserialization. - internal DataImportDetails() - { - } - - /// - /// Account details of the data to be transferred - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Account details of the data to be transferred. public DataAccountDetails AccountDetails { get; set; } + /// Level of the logs to be collected. public LogCollectionLevel? LogCollectionLevel { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.Serialization.cs index c3a94f839597..4e3622bf0589 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataLocationToServiceLocationMap : IUtf8JsonSerializable, IJsonModel + /// Map of data location to service location. + public partial class DataLocationToServiceLocationMap : 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, M /// 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(DataLocationToServiceLocationMap)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(DataLocation)) { writer.WritePropertyName("dataLocation"u8); @@ -44,15 +45,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("serviceLocation"u8); writer.WriteStringValue(ServiceLocation.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); } @@ -61,63 +62,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DataLocationToServiceLocationMap IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataLocationToServiceLocationMap IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataLocationToServiceLocationMap 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(DataLocationToServiceLocationMap)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataLocationToServiceLocationMap(document.RootElement, options); } - internal static DataLocationToServiceLocationMap DeserializeDataLocationToServiceLocationMap(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataLocationToServiceLocationMap DeserializeDataLocationToServiceLocationMap(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } AzureLocation? dataLocation = default; AzureLocation? serviceLocation = 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("dataLocation"u8)) + if (prop.NameEquals("dataLocation"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataLocation = new AzureLocation(property.Value.GetString()); + dataLocation = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("serviceLocation"u8)) + if (prop.NameEquals("serviceLocation"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - serviceLocation = new AzureLocation(property.Value.GetString()); + serviceLocation = 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 DataLocationToServiceLocationMap(dataLocation, serviceLocation, serializedAdditionalRawData); + return new DataLocationToServiceLocationMap(dataLocation, serviceLocation, 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": @@ -127,15 +134,20 @@ BinaryData IPersistableModel.Write(ModelReader } } - DataLocationToServiceLocationMap 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. + DataLocationToServiceLocationMap IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataLocationToServiceLocationMap 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 DeserializeDataLocationToServiceLocationMap(document.RootElement, options); } default: @@ -143,6 +155,7 @@ DataLocationToServiceLocationMap IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.cs index 1b40aed405e1..afe9df466064 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataLocationToServiceLocationMap.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Map of data location to service location. public partial class DataLocationToServiceLocationMap { - /// - /// 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 DataLocationToServiceLocationMap() @@ -54,16 +25,17 @@ internal DataLocationToServiceLocationMap() /// Initializes a new instance of . /// Location of the data. /// Location of the service. - /// Keeps track of any properties unknown to the library. - internal DataLocationToServiceLocationMap(AzureLocation? dataLocation, AzureLocation? serviceLocation, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DataLocationToServiceLocationMap(AzureLocation? dataLocation, AzureLocation? serviceLocation, IDictionary additionalBinaryDataProperties) { DataLocation = dataLocation; ServiceLocation = serviceLocation; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Location of the data. public AzureLocation? DataLocation { get; } + /// Location of the service. public AzureLocation? ServiceLocation { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.Serialization.cs index a51c0960baf3..b9921477bf69 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataTransferDetailsValidationContent : IUtf8JsonSerializable, IJsonModel + /// Request to validate export and import data details. + public partial class DataTransferDetailsValidationContent : DataBoxValidationInputContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DataTransferDetailsValidationContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,18 +34,17 @@ void IJsonModel.Write(Utf8JsonWriter write /// 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(DataTransferDetailsValidationContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(DataExportDetails)) { writer.WritePropertyName("dataExportDetails"u8); writer.WriteStartArray(); - foreach (var item in DataExportDetails) + foreach (DataExportDetails item in DataExportDetails) { writer.WriteObjectValue(item, options); } @@ -49,7 +54,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri { writer.WritePropertyName("dataImportDetails"u8); writer.WriteStartArray(); - foreach (var item in DataImportDetails) + foreach (DataImportDetails item in DataImportDetails) { writer.WriteObjectValue(item, options); } @@ -66,97 +71,100 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataTransferDetailsValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataTransferDetailsValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataTransferDetailsValidationContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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(DataTransferDetailsValidationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataTransferDetailsValidationContent(document.RootElement, options); } - internal static DataTransferDetailsValidationContent DeserializeDataTransferDetailsValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataTransferDetailsValidationContent DeserializeDataTransferDetailsValidationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxValidationInputDiscriminator validationType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); IList dataExportDetails = default; IList dataImportDetails = default; DataBoxSkuName deviceType = default; DataBoxJobTransferType transferType = default; DeviceModelName? model = default; - DataBoxValidationInputDiscriminator validationType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("dataExportDetails"u8)) + if (prop.NameEquals("validationType"u8)) + { + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); + continue; + } + if (prop.NameEquals("dataExportDetails"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(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); } dataExportDetails = array; continue; } - if (property.NameEquals("dataImportDetails"u8)) + if (prop.NameEquals("dataImportDetails"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(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); } dataImportDetails = array; continue; } - if (property.NameEquals("deviceType"u8)) + if (prop.NameEquals("deviceType"u8)) { - deviceType = property.Value.GetString().ToDataBoxSkuName(); + deviceType = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("transferType"u8)) + if (prop.NameEquals("transferType"u8)) { - transferType = property.Value.GetString().ToDataBoxJobTransferType(); + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); - continue; - } - if (property.NameEquals("validationType"u8)) - { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + model = prop.Value.GetString().ToDeviceModelName(); 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 DataTransferDetailsValidationContent( validationType, - serializedAdditionalRawData, + additionalBinaryDataProperties, dataExportDetails ?? new ChangeTrackingList(), dataImportDetails ?? new ChangeTrackingList(), deviceType, @@ -164,10 +172,13 @@ internal static DataTransferDetailsValidationContent DeserializeDataTransferDeta model); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -177,15 +188,20 @@ BinaryData IPersistableModel.Write(ModelRe } } - DataTransferDetailsValidationContent 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. + DataTransferDetailsValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataTransferDetailsValidationContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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 DeserializeDataTransferDetailsValidationContent(document.RootElement, options); } default: @@ -193,6 +209,7 @@ DataTransferDetailsValidationContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.cs index 7c038b25e854..cc10d585248b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationContent.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -16,46 +17,43 @@ public partial class DataTransferDetailsValidationContent : DataBoxValidationInp /// Initializes a new instance of . /// Device type. /// Type of the transfer. - public DataTransferDetailsValidationContent(DataBoxSkuName deviceType, DataBoxJobTransferType transferType) + public DataTransferDetailsValidationContent(DataBoxSkuName deviceType, DataBoxJobTransferType transferType) : base(DataBoxValidationInputDiscriminator.ValidateDataTransferDetails) { DataExportDetails = new ChangeTrackingList(); DataImportDetails = new ChangeTrackingList(); DeviceType = deviceType; TransferType = transferType; - ValidationType = DataBoxValidationInputDiscriminator.ValidateDataTransferDetails; } /// Initializes a new instance of . /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// List of DataTransfer details to be used to export data from azure. /// List of DataTransfer details to be used to import data to azure. /// Device type. /// Type of the transfer. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - internal DataTransferDetailsValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData, IList dataExportDetails, IList dataImportDetails, DataBoxSkuName deviceType, DataBoxJobTransferType transferType, DeviceModelName? model) : base(validationType, serializedAdditionalRawData) + internal DataTransferDetailsValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties, IList dataExportDetails, IList dataImportDetails, DataBoxSkuName deviceType, DataBoxJobTransferType transferType, DeviceModelName? model) : base(validationType, additionalBinaryDataProperties) { DataExportDetails = dataExportDetails; DataImportDetails = dataImportDetails; DeviceType = deviceType; TransferType = transferType; Model = model; - ValidationType = validationType; - } - - /// Initializes a new instance of for deserialization. - internal DataTransferDetailsValidationContent() - { } /// List of DataTransfer details to be used to export data from azure. public IList DataExportDetails { get; } + /// List of DataTransfer details to be used to import data to azure. public IList DataImportDetails { get; } + /// Device type. public DataBoxSkuName DeviceType { get; } + /// Type of the transfer. public DataBoxJobTransferType TransferType { get; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.Serialization.cs index 93848b662045..f4daf606945b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DataTransferDetailsValidationResult : IUtf8JsonSerializable, IJsonModel + /// Properties of data transfer details validation response. + public partial class DataTransferDetailsValidationResult : DataBoxValidationInputResult, 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(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8JsonWriter writer /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DataTransferDetailsValidationResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(Status)) { @@ -43,69 +44,75 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DataTransferDetailsValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataTransferDetailsValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DataTransferDetailsValidationResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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(DataTransferDetailsValidationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataTransferDetailsValidationResult(document.RootElement, options); } - internal static DataTransferDetailsValidationResult DeserializeDataTransferDetailsValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DataTransferDetailsValidationResult DeserializeDataTransferDetailsValidationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DataBoxValidationStatus? status = default; DataBoxValidationInputDiscriminator validationType = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DataBoxValidationStatus? status = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("validationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = property.Value.GetString().ToDataBoxValidationStatus(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("error"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + status = prop.Value.GetString().ToDataBoxValidationStatus(); 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 DataTransferDetailsValidationResult(validationType, error, serializedAdditionalRawData, status); + return new DataTransferDetailsValidationResult(validationType, error, additionalBinaryDataProperties, status); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +122,20 @@ BinaryData IPersistableModel.Write(ModelRea } } - DataTransferDetailsValidationResult 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. + DataTransferDetailsValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DataTransferDetailsValidationResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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 DeserializeDataTransferDetailsValidationResult(document.RootElement, options); } default: @@ -131,6 +143,7 @@ DataTransferDetailsValidationResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.cs index f3c709d3300f..489f89ab23ef 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DataTransferDetailsValidationResult.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { @@ -14,20 +15,18 @@ namespace Azure.ResourceManager.DataBox.Models public partial class DataTransferDetailsValidationResult : DataBoxValidationInputResult { /// Initializes a new instance of . - internal DataTransferDetailsValidationResult() + internal DataTransferDetailsValidationResult() : base(DataBoxValidationInputDiscriminator.ValidateDataTransferDetails) { - ValidationType = DataBoxValidationInputDiscriminator.ValidateDataTransferDetails; } /// Initializes a new instance of . /// Identifies the type of validation response. /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Data transfer details validation status. - internal DataTransferDetailsValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData, DataBoxValidationStatus? status) : base(validationType, error, serializedAdditionalRawData) + internal DataTransferDetailsValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties, DataBoxValidationStatus? status) : base(validationType, error, additionalBinaryDataProperties) { Status = status; - ValidationType = validationType; } /// Data transfer details validation status. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DatacenterAddressType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DatacenterAddressType.Serialization.cs index 431a3770e520..53cea7720fee 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DatacenterAddressType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DatacenterAddressType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DatacenterAddressTypeExtensions { + /// The value to serialize. public static string ToSerialString(this DatacenterAddressType value) => value switch { DatacenterAddressType.DatacenterAddressLocation => "DatacenterAddressLocation", @@ -18,10 +19,17 @@ internal static partial class DatacenterAddressTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DatacenterAddressType value.") }; + /// The value to deserialize. public static DatacenterAddressType ToDatacenterAddressType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DatacenterAddressLocation")) return DatacenterAddressType.DatacenterAddressLocation; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DatacenterAddressInstruction")) return DatacenterAddressType.DatacenterAddressInstruction; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DatacenterAddressLocation")) + { + return DatacenterAddressType.DatacenterAddressLocation; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DatacenterAddressInstruction")) + { + return DatacenterAddressType.DatacenterAddressInstruction; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DatacenterAddressType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DelayNotificationStatus.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DelayNotificationStatus.cs index 0c96fa00f72f..94e9c0bb35b2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DelayNotificationStatus.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DelayNotificationStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.DataBox.Models public readonly partial struct DelayNotificationStatus : IEquatable { private readonly string _value; + /// Delay is still active. + private const string ActiveValue = "Active"; + /// Delay has been resolved. + private const string ResolvedValue = "Resolved"; /// Initializes a new instance of . + /// The value. /// is null. public DelayNotificationStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string ActiveValue = "Active"; - private const string ResolvedValue = "Resolved"; + _value = value; + } /// Delay is still active. public static DelayNotificationStatus Active { get; } = new DelayNotificationStatus(ActiveValue); + /// Delay has been resolved. public static DelayNotificationStatus Resolved { get; } = new DelayNotificationStatus(ResolvedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DelayNotificationStatus left, DelayNotificationStatus 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 !=(DelayNotificationStatus left, DelayNotificationStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DelayNotificationStatus(string value) => new DelayNotificationStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DelayNotificationStatus?(string value) => value == null ? null : new DelayNotificationStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DelayNotificationStatus other && Equals(other); - /// + + /// public bool Equals(DelayNotificationStatus 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.Serialization.cs index 2e798afb3a56..f614e99f5acd 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DeviceCapabilityContent : IUtf8JsonSerializable, IJsonModel + /// Request body to get the device capabilities for given sku. + public partial class DeviceCapabilityContent : 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, ModelReade /// 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(DeviceCapabilityContent)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SkuName)) { writer.WritePropertyName("skuName"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("model"u8); writer.WriteStringValue(Model.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); } @@ -61,63 +61,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceCapabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceCapabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceCapabilityContent 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(DeviceCapabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceCapabilityContent(document.RootElement, options); } - internal static DeviceCapabilityContent DeserializeDeviceCapabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceCapabilityContent DeserializeDeviceCapabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxSkuName? skuName = default; DeviceModelName? model = 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("skuName"u8)) + if (prop.NameEquals("skuName"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - skuName = property.Value.GetString().ToDataBoxSkuName(); + skuName = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + model = prop.Value.GetString().ToDeviceModelName(); 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 DeviceCapabilityContent(skuName, model, serializedAdditionalRawData); + return new DeviceCapabilityContent(skuName, model, 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": @@ -127,15 +133,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - DeviceCapabilityContent 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. + DeviceCapabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceCapabilityContent 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 DeserializeDeviceCapabilityContent(document.RootElement, options); } default: @@ -143,6 +154,7 @@ DeviceCapabilityContent IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.cs index 62a007492b13..f7273cc9b611 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityContent.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Request body to get the device capabilities for given sku. public partial class DeviceCapabilityContent { - /// - /// 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 DeviceCapabilityContent() @@ -53,16 +24,17 @@ public DeviceCapabilityContent() /// Initializes a new instance of . /// Type of the device. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal DeviceCapabilityContent(DataBoxSkuName? skuName, DeviceModelName? model, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceCapabilityContent(DataBoxSkuName? skuName, DeviceModelName? model, IDictionary additionalBinaryDataProperties) { SkuName = skuName; Model = model; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of the device. public DataBoxSkuName? SkuName { get; set; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.Serialization.cs index 8c1b96296d05..81419ac7ce59 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DeviceCapabilityDetails : IUtf8JsonSerializable, IJsonModel + /// Device capability details for a given sku for a given region. + public partial class DeviceCapabilityDetails : 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 writer, ModelReade /// 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(DeviceCapabilityDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(HardwareEncryption)) { writer.WritePropertyName("hardwareEncryption"u8); writer.WriteStringValue(HardwareEncryption.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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceCapabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceCapabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceCapabilityDetails 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(DeviceCapabilityDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceCapabilityDetails(document.RootElement, options); } - internal static DeviceCapabilityDetails DeserializeDeviceCapabilityDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceCapabilityDetails DeserializeDeviceCapabilityDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } HardwareEncryption? hardwareEncryption = 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("hardwareEncryption"u8)) + if (prop.NameEquals("hardwareEncryption"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - hardwareEncryption = property.Value.GetString().ToHardwareEncryption(); + hardwareEncryption = prop.Value.GetString().ToHardwareEncryption(); 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 DeviceCapabilityDetails(hardwareEncryption, serializedAdditionalRawData); + return new DeviceCapabilityDetails(hardwareEncryption, 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(ModelReaderWriterOpt } } - DeviceCapabilityDetails 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. + DeviceCapabilityDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceCapabilityDetails 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 DeserializeDeviceCapabilityDetails(document.RootElement, options); } default: @@ -128,6 +139,7 @@ DeviceCapabilityDetails IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.cs index 27fe0bf1ea7d..3261fe56a1fc 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Device capability details for a given sku for a given region. public partial class DeviceCapabilityDetails { - /// - /// 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 DeviceCapabilityDetails() @@ -52,11 +23,11 @@ internal DeviceCapabilityDetails() /// Initializes a new instance of . /// Hardware encryption support for a given sku for a given region. - /// Keeps track of any properties unknown to the library. - internal DeviceCapabilityDetails(HardwareEncryption? hardwareEncryption, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceCapabilityDetails(HardwareEncryption? hardwareEncryption, IDictionary additionalBinaryDataProperties) { HardwareEncryption = hardwareEncryption; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Hardware encryption support for a given sku for a given region. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.Serialization.cs index 3d2872f8c3dd..ac57de571520 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class DeviceCapabilityResponse : IUtf8JsonSerializable, IJsonModel + /// Device capabilities for given sku in a region. + internal partial class DeviceCapabilityResponse : 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 +29,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// 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(DeviceCapabilityResponse)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsCollectionDefined(DeviceCapabilityDetails)) { writer.WritePropertyName("deviceCapabilityDetails"u8); writer.WriteStartArray(); - foreach (var item in DeviceCapabilityDetails) + foreach (DeviceCapabilityDetails item in DeviceCapabilityDetails) { 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 +61,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DeviceCapabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceCapabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceCapabilityResponse 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(DeviceCapabilityResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceCapabilityResponse(document.RootElement, options); } - internal static DeviceCapabilityResponse DeserializeDeviceCapabilityResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceCapabilityResponse DeserializeDeviceCapabilityResponse(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList deviceCapabilityDetails = 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("deviceCapabilityDetails"u8)) + if (prop.NameEquals("deviceCapabilityDetails"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(Models.DeviceCapabilityDetails.DeserializeDeviceCapabilityDetails(item, options)); } @@ -102,17 +106,19 @@ internal static DeviceCapabilityResponse DeserializeDeviceCapabilityResponse(Jso } 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 DeviceCapabilityResponse(deviceCapabilityDetails ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new DeviceCapabilityResponse(deviceCapabilityDetails ?? 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 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - DeviceCapabilityResponse 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. + DeviceCapabilityResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceCapabilityResponse 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 DeserializeDeviceCapabilityResponse(document.RootElement, options); } default: @@ -138,6 +149,7 @@ DeviceCapabilityResponse IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.cs index ce29981cea35..74ed118d8d08 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceCapabilityResponse.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Device capabilities for given sku in a region. internal partial class DeviceCapabilityResponse { - /// - /// 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 DeviceCapabilityResponse() @@ -53,11 +25,11 @@ internal DeviceCapabilityResponse() /// Initializes a new instance of . /// List of device capabilities available for a given region and a given sku. - /// Keeps track of any properties unknown to the library. - internal DeviceCapabilityResponse(IReadOnlyList deviceCapabilityDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceCapabilityResponse(IReadOnlyList deviceCapabilityDetails, IDictionary additionalBinaryDataProperties) { DeviceCapabilityDetails = deviceCapabilityDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// List of device capabilities available for a given region and a given sku. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.Serialization.cs index f7d2a5bf9c7a..5b57e2e98724 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DeviceErasureDetails : IUtf8JsonSerializable, IJsonModel + /// Device erasure details with erasure completion status, secure erasure sas key and erasureordestructionlog sas key. + public partial class DeviceErasureDetails : 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, 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(DeviceErasureDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(DeviceErasureStatus)) { writer.WritePropertyName("deviceErasureStatus"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("secureErasureCertificateSasKey"u8); writer.WriteStringValue(SecureErasureCertificateSasKey); } - 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 } } - DeviceErasureDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DeviceErasureDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeviceErasureDetails 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(DeviceErasureDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDeviceErasureDetails(document.RootElement, options); } - internal static DeviceErasureDetails DeserializeDeviceErasureDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeviceErasureDetails DeserializeDeviceErasureDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,42 +94,43 @@ internal static DeviceErasureDetails DeserializeDeviceErasureDetails(JsonElement DataBoxStageStatus? deviceErasureStatus = default; string erasureOrDestructionCertificateSasKey = default; string secureErasureCertificateSasKey = 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("deviceErasureStatus"u8)) + if (prop.NameEquals("deviceErasureStatus"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceErasureStatus = property.Value.GetString().ToDataBoxStageStatus(); + deviceErasureStatus = prop.Value.GetString().ToDataBoxStageStatus(); continue; } - if (property.NameEquals("erasureOrDestructionCertificateSasKey"u8)) + if (prop.NameEquals("erasureOrDestructionCertificateSasKey"u8)) { - erasureOrDestructionCertificateSasKey = property.Value.GetString(); + erasureOrDestructionCertificateSasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("secureErasureCertificateSasKey"u8)) + if (prop.NameEquals("secureErasureCertificateSasKey"u8)) { - secureErasureCertificateSasKey = property.Value.GetString(); + secureErasureCertificateSasKey = 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 DeviceErasureDetails(deviceErasureStatus, erasureOrDestructionCertificateSasKey, secureErasureCertificateSasKey, serializedAdditionalRawData); + return new DeviceErasureDetails(deviceErasureStatus, erasureOrDestructionCertificateSasKey, secureErasureCertificateSasKey, 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": @@ -134,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - DeviceErasureDetails 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. + DeviceErasureDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeviceErasureDetails 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 DeserializeDeviceErasureDetails(document.RootElement, options); } default: @@ -150,6 +161,7 @@ DeviceErasureDetails IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.cs index 1a8045e7a475..bb79fbfa9717 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceErasureDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Device erasure details with erasure completion status, secure erasure sas key and erasureordestructionlog sas key. public partial class DeviceErasureDetails { - /// - /// 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 DeviceErasureDetails() @@ -54,19 +25,21 @@ internal DeviceErasureDetails() /// Holds the device erasure completion status. /// Shared access key to download cleanup or destruction certificate for device. /// Shared access key to download secure erasure certificate for the device. - /// Keeps track of any properties unknown to the library. - internal DeviceErasureDetails(DataBoxStageStatus? deviceErasureStatus, string erasureOrDestructionCertificateSasKey, string secureErasureCertificateSasKey, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DeviceErasureDetails(DataBoxStageStatus? deviceErasureStatus, string erasureOrDestructionCertificateSasKey, string secureErasureCertificateSasKey, IDictionary additionalBinaryDataProperties) { DeviceErasureStatus = deviceErasureStatus; ErasureOrDestructionCertificateSasKey = erasureOrDestructionCertificateSasKey; SecureErasureCertificateSasKey = secureErasureCertificateSasKey; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Holds the device erasure completion status. public DataBoxStageStatus? DeviceErasureStatus { get; } + /// Shared access key to download cleanup or destruction certificate for device. public string ErasureOrDestructionCertificateSasKey { get; } + /// Shared access key to download secure erasure certificate for the device. public string SecureErasureCertificateSasKey { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceModelName.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceModelName.Serialization.cs index d3daf3d0df36..9b1de9e433d9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceModelName.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DeviceModelName.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class DeviceModelNameExtensions { + /// The value to serialize. public static string ToSerialString(this DeviceModelName value) => value switch { DeviceModelName.DataBox => "DataBox", @@ -22,14 +23,33 @@ internal static partial class DeviceModelNameExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DeviceModelName value.") }; + /// The value to deserialize. public static DeviceModelName ToDeviceModelName(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBox")) return DeviceModelName.DataBox; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxDisk")) return DeviceModelName.DataBoxDisk; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxHeavy")) return DeviceModelName.DataBoxHeavy; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxCustomerDisk")) return DeviceModelName.DataBoxCustomerDisk; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureDataBox120")) return DeviceModelName.AzureDataBox120; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureDataBox525")) return DeviceModelName.AzureDataBox525; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBox")) + { + return DeviceModelName.DataBox; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxDisk")) + { + return DeviceModelName.DataBoxDisk; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxHeavy")) + { + return DeviceModelName.DataBoxHeavy; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "DataBoxCustomerDisk")) + { + return DeviceModelName.DataBoxCustomerDisk; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureDataBox120")) + { + return DeviceModelName.AzureDataBox120; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureDataBox525")) + { + return DeviceModelName.AzureDataBox525; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown DeviceModelName value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.Serialization.cs index 13307b35f8e4..14bd92ca0f06 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class DiskScheduleAvailabilityContent : IUtf8JsonSerializable, IJsonModel + /// Request body to get the availability for scheduling disk orders. + public partial class DiskScheduleAvailabilityContent : ScheduleAvailabilityContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DiskScheduleAvailabilityContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,94 +35,99 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// 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(DiskScheduleAvailabilityContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("expectedDataSizeInTeraBytes"u8); writer.WriteNumberValue(ExpectedDataSizeInTerabytes); } - DiskScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DiskScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DiskScheduleAvailabilityContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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(DiskScheduleAvailabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDiskScheduleAvailabilityContent(document.RootElement, options); } - internal static DiskScheduleAvailabilityContent DeserializeDiskScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DiskScheduleAvailabilityContent DeserializeDiskScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - int expectedDataSizeInTeraBytes = default; AzureLocation storageLocation = default; DataBoxSkuName skuName = default; string country = default; DeviceModelName? model = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int expectedDataSizeInTerabytes = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("expectedDataSizeInTeraBytes"u8)) - { - expectedDataSizeInTeraBytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("storageLocation"u8)) + if (prop.NameEquals("storageLocation"u8)) { - storageLocation = new AzureLocation(property.Value.GetString()); + storageLocation = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("skuName"u8)) + if (prop.NameEquals("skuName"u8)) { - skuName = property.Value.GetString().ToDataBoxSkuName(); + skuName = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("country"u8)) { - country = property.Value.GetString(); + country = prop.Value.GetString(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + model = prop.Value.GetString().ToDeviceModelName(); + continue; + } + if (prop.NameEquals("expectedDataSizeInTeraBytes"u8)) + { + expectedDataSizeInTerabytes = prop.Value.GetInt32(); 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 DiskScheduleAvailabilityContent( storageLocation, skuName, country, model, - serializedAdditionalRawData, - expectedDataSizeInTeraBytes); + additionalBinaryDataProperties, + expectedDataSizeInTerabytes); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -125,15 +137,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DiskScheduleAvailabilityContent 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. + DiskScheduleAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DiskScheduleAvailabilityContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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 DeserializeDiskScheduleAvailabilityContent(document.RootElement, options); } default: @@ -141,6 +158,7 @@ DiskScheduleAvailabilityContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.cs index b1c8bf91f4c6..3c28e12a7844 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/DiskScheduleAvailabilityContent.cs @@ -17,10 +17,9 @@ public partial class DiskScheduleAvailabilityContent : ScheduleAvailabilityConte /// Initializes a new instance of . /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// The expected size of the data, which needs to be transferred in this job, in terabytes. - public DiskScheduleAvailabilityContent(AzureLocation storageLocation, int expectedDataSizeInTerabytes) : base(storageLocation) + public DiskScheduleAvailabilityContent(AzureLocation storageLocation, int expectedDataSizeInTerabytes) : base(storageLocation, DataBoxSkuName.DataBoxDisk) { ExpectedDataSizeInTerabytes = expectedDataSizeInTerabytes; - SkuName = DataBoxSkuName.DataBoxDisk; } /// Initializes a new instance of . @@ -28,17 +27,11 @@ public DiskScheduleAvailabilityContent(AzureLocation storageLocation, int expect /// Sku Name for which the order is to be scheduled. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The expected size of the data, which needs to be transferred in this job, in terabytes. - internal DiskScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary serializedAdditionalRawData, int expectedDataSizeInTerabytes) : base(storageLocation, skuName, country, model, serializedAdditionalRawData) + internal DiskScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary additionalBinaryDataProperties, int expectedDataSizeInTerabytes) : base(storageLocation, skuName, country, model, additionalBinaryDataProperties) { ExpectedDataSizeInTerabytes = expectedDataSizeInTerabytes; - SkuName = skuName; - } - - /// Initializes a new instance of for deserialization. - internal DiskScheduleAvailabilityContent() - { } /// The expected size of the data, which needs to be transferred in this job, in terabytes. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.Serialization.cs index ac87e9efc36d..997599baf5fb 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ExportDiskDetails : IUtf8JsonSerializable, IJsonModel + /// Export disk details. + public partial class ExportDiskDetails : 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, ModelReaderWrite /// 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(ExportDiskDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ManifestFile)) { writer.WritePropertyName("manifestFile"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("backupManifestCloudPath"u8); writer.WriteStringValue(BackupManifestCloudPath); } - 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 } } - ExportDiskDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ExportDiskDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ExportDiskDetails 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(ExportDiskDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeExportDiskDetails(document.RootElement, options); } - internal static ExportDiskDetails DeserializeExportDiskDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ExportDiskDetails DeserializeExportDiskDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,38 +94,39 @@ internal static ExportDiskDetails DeserializeExportDiskDetails(JsonElement eleme string manifestFile = default; string manifestHash = default; string backupManifestCloudPath = 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("manifestFile"u8)) + if (prop.NameEquals("manifestFile"u8)) { - manifestFile = property.Value.GetString(); + manifestFile = prop.Value.GetString(); continue; } - if (property.NameEquals("manifestHash"u8)) + if (prop.NameEquals("manifestHash"u8)) { - manifestHash = property.Value.GetString(); + manifestHash = prop.Value.GetString(); continue; } - if (property.NameEquals("backupManifestCloudPath"u8)) + if (prop.NameEquals("backupManifestCloudPath"u8)) { - backupManifestCloudPath = property.Value.GetString(); + backupManifestCloudPath = 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 ExportDiskDetails(manifestFile, manifestHash, backupManifestCloudPath, serializedAdditionalRawData); + return new ExportDiskDetails(manifestFile, manifestHash, backupManifestCloudPath, 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 +136,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - ExportDiskDetails 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. + ExportDiskDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ExportDiskDetails 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 DeserializeExportDiskDetails(document.RootElement, options); } default: @@ -146,6 +157,7 @@ ExportDiskDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.cs index 7816b1635aeb..3174750188ed 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ExportDiskDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Export disk details. public partial class ExportDiskDetails { - /// - /// 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 ExportDiskDetails() @@ -54,19 +25,21 @@ internal ExportDiskDetails() /// The relative path of the manifest file on the disk. /// The Base16-encoded MD5 hash of the manifest file on the disk. /// Path to backed up manifest, only returned if enableManifestBackup is true. - /// Keeps track of any properties unknown to the library. - internal ExportDiskDetails(string manifestFile, string manifestHash, string backupManifestCloudPath, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ExportDiskDetails(string manifestFile, string manifestHash, string backupManifestCloudPath, IDictionary additionalBinaryDataProperties) { ManifestFile = manifestFile; ManifestHash = manifestHash; BackupManifestCloudPath = backupManifestCloudPath; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The relative path of the manifest file on the disk. public string ManifestFile { get; } + /// The Base16-encoded MD5 hash of the manifest file on the disk. public string ManifestHash { get; } + /// Path to backed up manifest, only returned if enableManifestBackup is true. public string BackupManifestCloudPath { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.Serialization.cs index 5976fe775e18..12e2fe2e68e8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class FilterFileDetails : IUtf8JsonSerializable, IJsonModel + /// Details of the filter files to be used for data transfer. + public partial class FilterFileDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal FilterFileDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,25 +34,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(FilterFileDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("filterFileType"u8); writer.WriteStringValue(FilterFileType.ToSerialString()); writer.WritePropertyName("filterFilePath"u8); writer.WriteStringValue(FilterFilePath); - 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); } @@ -55,55 +60,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - FilterFileDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + FilterFileDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FilterFileDetails 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(FilterFileDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeFilterFileDetails(document.RootElement, options); } - internal static FilterFileDetails DeserializeFilterFileDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FilterFileDetails DeserializeFilterFileDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } FilterFileType filterFileType = default; string filterFilePath = 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("filterFileType"u8)) + if (prop.NameEquals("filterFileType"u8)) { - filterFileType = property.Value.GetString().ToFilterFileType(); + filterFileType = prop.Value.GetString().ToFilterFileType(); continue; } - if (property.NameEquals("filterFilePath"u8)) + if (prop.NameEquals("filterFilePath"u8)) { - filterFilePath = property.Value.GetString(); + filterFilePath = 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 FilterFileDetails(filterFileType, filterFilePath, serializedAdditionalRawData); + return new FilterFileDetails(filterFileType, filterFilePath, 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": @@ -113,15 +124,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - FilterFileDetails 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. + FilterFileDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FilterFileDetails 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 DeserializeFilterFileDetails(document.RootElement, options); } default: @@ -129,6 +145,7 @@ FilterFileDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.cs index 3492d3a2edbd..9af550696cba 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileDetails.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Details of the filter files to be used for data transfer. public partial class FilterFileDetails { - /// - /// 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 . /// Type of the filter file. @@ -60,21 +32,17 @@ public FilterFileDetails(FilterFileType filterFileType, string filterFilePath) /// Initializes a new instance of . /// Type of the filter file. /// Path of the file that contains the details of all items to transfer. - /// Keeps track of any properties unknown to the library. - internal FilterFileDetails(FilterFileType filterFileType, string filterFilePath, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal FilterFileDetails(FilterFileType filterFileType, string filterFilePath, IDictionary additionalBinaryDataProperties) { FilterFileType = filterFileType; FilterFilePath = filterFilePath; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal FilterFileDetails() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of the filter file. public FilterFileType FilterFileType { get; set; } + /// Path of the file that contains the details of all items to transfer. public string FilterFilePath { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileType.Serialization.cs index 1e2828d8631b..4f55b4e9f0e7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/FilterFileType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class FilterFileTypeExtensions { + /// The value to serialize. public static string ToSerialString(this FilterFileType value) => value switch { FilterFileType.AzureBlob => "AzureBlob", @@ -18,10 +19,17 @@ internal static partial class FilterFileTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown FilterFileType value.") }; + /// The value to deserialize. public static FilterFileType ToFilterFileType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureBlob")) return FilterFileType.AzureBlob; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureFile")) return FilterFileType.AzureFile; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureBlob")) + { + return FilterFileType.AzureBlob; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureFile")) + { + return FilterFileType.AzureFile; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown FilterFileType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.Serialization.cs index 1d45cd2959bc..01e7bc9e2a0e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { + /// + /// Granular Details for log generated during copy. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// [PersistableModelProxy(typeof(UnknownGranularCopyLogDetails))] - public partial class GranularCopyLogDetails : IUtf8JsonSerializable, IJsonModel + public abstract partial class GranularCopyLogDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal GranularCopyLogDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,23 +37,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(GranularCopyLogDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("copyLogDetailsType"u8); writer.WriteStringValue(CopyLogDetailsType.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); } @@ -53,40 +61,49 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GranularCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GranularCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GranularCopyLogDetails 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(GranularCopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGranularCopyLogDetails(document.RootElement, options); } - internal static GranularCopyLogDetails DeserializeGranularCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GranularCopyLogDetails DeserializeGranularCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("copyLogDetailsType", out JsonElement discriminator)) + if (element.TryGetProperty("copyLogDetailsType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "DataBoxCustomerDisk": return DataBoxDiskGranularCopyLogDetails.DeserializeDataBoxDiskGranularCopyLogDetails(element, options); + case "DataBoxCustomerDisk": + return DataBoxDiskGranularCopyLogDetails.DeserializeDataBoxDiskGranularCopyLogDetails(element, options); } } return UnknownGranularCopyLogDetails.DeserializeUnknownGranularCopyLogDetails(element, options); } - 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": @@ -96,15 +113,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - GranularCopyLogDetails 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. + GranularCopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GranularCopyLogDetails 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 DeserializeGranularCopyLogDetails(document.RootElement, options); } default: @@ -112,6 +134,7 @@ GranularCopyLogDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.cs index 112dcb20109e..4c3ab0cf5d41 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyLogDetails.cs @@ -12,55 +12,27 @@ namespace Azure.ResourceManager.DataBox.Models { /// /// Granular Details for log generated during copy. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include . + /// Please note this is the abstract base class. The derived classes available for instantiation are: . /// public abstract partial class GranularCopyLogDetails { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected GranularCopyLogDetails() + /// Indicates the type of job details. + private protected GranularCopyLogDetails(DataBoxOrderType copyLogDetailsType) { + CopyLogDetailsType = copyLogDetailsType; } /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. - internal GranularCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GranularCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties) { CopyLogDetailsType = copyLogDetailsType; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Indicates the type of job details. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.Serialization.cs index 6b60a6ad0f2e..b1cd1d3a2835 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.Serialization.cs @@ -10,14 +10,17 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class GranularCopyProgress : IUtf8JsonSerializable, IJsonModel + /// Granular Copy progress. + public partial class GranularCopyProgress : 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(); @@ -29,12 +32,11 @@ 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(GranularCopyProgress)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(StorageAccountName)) { writer.WritePropertyName("storageAccountName"u8); @@ -119,21 +121,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("actions"u8); writer.WriteStartArray(); - foreach (var item in Actions) + foreach (CustomerResolutionCode item in Actions) { writer.WriteStringValue(item.ToSerialString()); } 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); } @@ -142,22 +144,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - GranularCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GranularCopyProgress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GranularCopyProgress 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(GranularCopyProgress)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGranularCopyProgress(document.RootElement, options); } - internal static GranularCopyProgress DeserializeGranularCopyProgress(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GranularCopyProgress DeserializeGranularCopyProgress(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -179,158 +186,157 @@ internal static GranularCopyProgress DeserializeGranularCopyProgress(JsonElement bool? isEnumerationInProgress = default; ResponseError error = default; IReadOnlyList actions = 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("storageAccountName"u8)) + if (prop.NameEquals("storageAccountName"u8)) { - storageAccountName = property.Value.GetString(); + storageAccountName = prop.Value.GetString(); continue; } - if (property.NameEquals("transferType"u8)) + if (prop.NameEquals("transferType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferType = property.Value.GetString().ToDataBoxJobTransferType(); + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); continue; } - if (property.NameEquals("dataAccountType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataAccountType = property.Value.GetString().ToDataAccountType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("accountId"u8)) + if (prop.NameEquals("accountId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - accountId = new ResourceIdentifier(property.Value.GetString()); + accountId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("bytesProcessed"u8)) + if (prop.NameEquals("bytesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - bytesProcessed = property.Value.GetInt64(); + bytesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalBytesToProcess"u8)) + if (prop.NameEquals("totalBytesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalBytesToProcess = property.Value.GetInt64(); + totalBytesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesProcessed"u8)) + if (prop.NameEquals("filesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesProcessed = property.Value.GetInt64(); + filesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("totalFilesToProcess"u8)) + if (prop.NameEquals("totalFilesToProcess"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - totalFilesToProcess = property.Value.GetInt64(); + totalFilesToProcess = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFilesProcessed"u8)) + if (prop.NameEquals("invalidFilesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFilesProcessed = property.Value.GetInt64(); + invalidFilesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidFileBytesUploaded"u8)) + if (prop.NameEquals("invalidFileBytesUploaded"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidFileBytesUploaded = property.Value.GetInt64(); + invalidFileBytesUploaded = prop.Value.GetInt64(); continue; } - if (property.NameEquals("renamedContainerCount"u8)) + if (prop.NameEquals("renamedContainerCount"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - renamedContainerCount = property.Value.GetInt64(); + renamedContainerCount = prop.Value.GetInt64(); continue; } - if (property.NameEquals("filesErroredOut"u8)) + if (prop.NameEquals("filesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filesErroredOut = property.Value.GetInt64(); + filesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("directoriesErroredOut"u8)) + if (prop.NameEquals("directoriesErroredOut"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - directoriesErroredOut = property.Value.GetInt64(); + directoriesErroredOut = prop.Value.GetInt64(); continue; } - if (property.NameEquals("invalidDirectoriesProcessed"u8)) + if (prop.NameEquals("invalidDirectoriesProcessed"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - invalidDirectoriesProcessed = property.Value.GetInt64(); + invalidDirectoriesProcessed = prop.Value.GetInt64(); continue; } - if (property.NameEquals("isEnumerationInProgress"u8)) + if (prop.NameEquals("isEnumerationInProgress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isEnumerationInProgress = property.Value.GetBoolean(); + isEnumerationInProgress = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("actions"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().ToCustomerResolutionCode()); } @@ -339,10 +345,9 @@ internal static GranularCopyProgress DeserializeGranularCopyProgress(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 GranularCopyProgress( storageAccountName, transferType, @@ -361,13 +366,16 @@ internal static GranularCopyProgress DeserializeGranularCopyProgress(JsonElement isEnumerationInProgress, error, actions ?? new ChangeTrackingList(), - 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": @@ -377,15 +385,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - GranularCopyProgress 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. + GranularCopyProgress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GranularCopyProgress 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 DeserializeGranularCopyProgress(document.RootElement, options); } default: @@ -393,6 +406,7 @@ GranularCopyProgress IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.cs index 0e3c58b15472..5dfbc9339662 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/GranularCopyProgress.cs @@ -7,44 +7,17 @@ using System; using System.Collections.Generic; +using Azure; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Granular Copy progress. public partial class GranularCopyProgress { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal GranularCopyProgress() @@ -73,8 +46,8 @@ internal GranularCopyProgress() /// /// Error, if any, in the stage. /// Available actions on the job. - /// Keeps track of any properties unknown to the library. - internal GranularCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal GranularCopyProgress(string storageAccountName, DataBoxJobTransferType? transferType, DataAccountType? dataAccountType, ResourceIdentifier accountId, long? bytesProcessed, long? totalBytesToProcess, long? filesProcessed, long? totalFilesToProcess, long? invalidFilesProcessed, long? invalidFileBytesUploaded, long? renamedContainerCount, long? filesErroredOut, long? directoriesErroredOut, long? invalidDirectoriesProcessed, bool? isEnumerationInProgress, ResponseError error, IReadOnlyList actions, IDictionary additionalBinaryDataProperties) { StorageAccountName = storageAccountName; TransferType = transferType; @@ -93,44 +66,60 @@ internal GranularCopyProgress(string storageAccountName, DataBoxJobTransferType? IsEnumerationInProgress = isEnumerationInProgress; Error = error; Actions = actions; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the storage account. This will be empty for data account types other than storage account. public string StorageAccountName { get; } + /// Transfer type of data. public DataBoxJobTransferType? TransferType { get; } + /// Data Account Type. public DataAccountType? DataAccountType { get; } + /// Id of the account where the data needs to be uploaded. public ResourceIdentifier AccountId { get; } + /// To indicate bytes transferred. public long? BytesProcessed { get; } + /// Total amount of data to be processed by the job. public long? TotalBytesToProcess { get; } + /// Number of files processed. public long? FilesProcessed { get; } + /// Total files to process. public long? TotalFilesToProcess { get; } + /// Number of files not adhering to azure naming conventions which were processed by automatic renaming. public long? InvalidFilesProcessed { get; } + /// Total amount of data not adhering to azure naming conventions which were processed by automatic renaming. public long? InvalidFileBytesUploaded { get; } + /// Number of folders not adhering to azure naming conventions which were processed by automatic renaming. public long? RenamedContainerCount { get; } + /// Number of files which could not be copied. public long? FilesErroredOut { get; } + /// To indicate directories errored out in the job. public long? DirectoriesErroredOut { get; } + /// To indicate directories renamed. public long? InvalidDirectoriesProcessed { get; } + /// /// To indicate if enumeration of data is in progress. /// Until this is true, the TotalBytesToProcess may not be valid. /// public bool? IsEnumerationInProgress { get; } + /// Error, if any, in the stage. public ResponseError Error { get; } + /// Available actions on the job. public IReadOnlyList Actions { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HardwareEncryption.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HardwareEncryption.Serialization.cs index 0f27c2a3922f..a8760faff88f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HardwareEncryption.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HardwareEncryption.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class HardwareEncryptionExtensions { + /// The value to serialize. public static string ToSerialString(this HardwareEncryption value) => value switch { HardwareEncryption.Enabled => "Enabled", @@ -18,10 +19,17 @@ internal static partial class HardwareEncryptionExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown HardwareEncryption value.") }; + /// The value to deserialize. public static HardwareEncryption ToHardwareEncryption(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) return HardwareEncryption.Enabled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) return HardwareEncryption.Disabled; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) + { + return HardwareEncryption.Enabled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) + { + return HardwareEncryption.Disabled; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown HardwareEncryption value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.Serialization.cs index 8c5518714c1b..b92d7af86cff 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class HeavyScheduleAvailabilityContent : IUtf8JsonSerializable, IJsonModel + /// Request body to get the availability for scheduling heavy orders. + public partial class HeavyScheduleAvailabilityContent : ScheduleAvailabilityContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal HeavyScheduleAvailabilityContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +35,35 @@ void IJsonModel.Write(Utf8JsonWriter writer, M /// 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(HeavyScheduleAvailabilityContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - HeavyScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HeavyScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (HeavyScheduleAvailabilityContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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(HeavyScheduleAvailabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHeavyScheduleAvailabilityContent(document.RootElement, options); } - internal static HeavyScheduleAvailabilityContent DeserializeHeavyScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HeavyScheduleAvailabilityContent DeserializeHeavyScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -61,47 +72,48 @@ internal static HeavyScheduleAvailabilityContent DeserializeHeavyScheduleAvailab DataBoxSkuName skuName = default; string country = default; DeviceModelName? model = 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("storageLocation"u8)) + if (prop.NameEquals("storageLocation"u8)) { - storageLocation = new AzureLocation(property.Value.GetString()); + storageLocation = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("skuName"u8)) + if (prop.NameEquals("skuName"u8)) { - skuName = property.Value.GetString().ToDataBoxSkuName(); + skuName = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("country"u8)) { - country = property.Value.GetString(); + country = prop.Value.GetString(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + model = prop.Value.GetString().ToDeviceModelName(); 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 HeavyScheduleAvailabilityContent(storageLocation, skuName, country, model, serializedAdditionalRawData); + return new HeavyScheduleAvailabilityContent(storageLocation, skuName, country, model, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -111,15 +123,20 @@ BinaryData IPersistableModel.Write(ModelReader } } - HeavyScheduleAvailabilityContent 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. + HeavyScheduleAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (HeavyScheduleAvailabilityContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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 DeserializeHeavyScheduleAvailabilityContent(document.RootElement, options); } default: @@ -127,6 +144,7 @@ HeavyScheduleAvailabilityContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.cs index f91ec9308fa9..0df5b8b2f871 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/HeavyScheduleAvailabilityContent.cs @@ -16,9 +16,8 @@ public partial class HeavyScheduleAvailabilityContent : ScheduleAvailabilityCont { /// Initializes a new instance of . /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. - public HeavyScheduleAvailabilityContent(AzureLocation storageLocation) : base(storageLocation) + public HeavyScheduleAvailabilityContent(AzureLocation storageLocation) : base(storageLocation, DataBoxSkuName.DataBoxHeavy) { - SkuName = DataBoxSkuName.DataBoxHeavy; } /// Initializes a new instance of . @@ -26,14 +25,8 @@ public HeavyScheduleAvailabilityContent(AzureLocation storageLocation) : base(st /// Sku Name for which the order is to be scheduled. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal HeavyScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary serializedAdditionalRawData) : base(storageLocation, skuName, country, model, serializedAdditionalRawData) - { - SkuName = skuName; - } - - /// Initializes a new instance of for deserialization. - internal HeavyScheduleAvailabilityContent() + /// Keeps track of any properties unknown to the library. + internal HeavyScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary additionalBinaryDataProperties) : base(storageLocation, skuName, country, model, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.Serialization.cs index 23d6dc362ca0..7419a926980c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ImportDiskDetails : IUtf8JsonSerializable, IJsonModel + /// Import disk details. + public partial class ImportDiskDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ImportDiskDetails() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(ImportDiskDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("manifestFile"u8); writer.WriteStringValue(ManifestFile); writer.WritePropertyName("manifestHash"u8); @@ -45,15 +50,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("backupManifestCloudPath"u8); writer.WriteStringValue(BackupManifestCloudPath); } - 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 } } - ImportDiskDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ImportDiskDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ImportDiskDetails 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(ImportDiskDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeImportDiskDetails(document.RootElement, options); } - internal static ImportDiskDetails DeserializeImportDiskDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ImportDiskDetails DeserializeImportDiskDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -86,43 +96,44 @@ internal static ImportDiskDetails DeserializeImportDiskDetails(JsonElement eleme string manifestHash = default; string bitLockerKey = default; string backupManifestCloudPath = 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("manifestFile"u8)) + if (prop.NameEquals("manifestFile"u8)) { - manifestFile = property.Value.GetString(); + manifestFile = prop.Value.GetString(); continue; } - if (property.NameEquals("manifestHash"u8)) + if (prop.NameEquals("manifestHash"u8)) { - manifestHash = property.Value.GetString(); + manifestHash = prop.Value.GetString(); continue; } - if (property.NameEquals("bitLockerKey"u8)) + if (prop.NameEquals("bitLockerKey"u8)) { - bitLockerKey = property.Value.GetString(); + bitLockerKey = prop.Value.GetString(); continue; } - if (property.NameEquals("backupManifestCloudPath"u8)) + if (prop.NameEquals("backupManifestCloudPath"u8)) { - backupManifestCloudPath = property.Value.GetString(); + backupManifestCloudPath = 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 ImportDiskDetails(manifestFile, manifestHash, bitLockerKey, backupManifestCloudPath, serializedAdditionalRawData); + return new ImportDiskDetails(manifestFile, manifestHash, bitLockerKey, backupManifestCloudPath, 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": @@ -132,15 +143,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - ImportDiskDetails 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. + ImportDiskDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ImportDiskDetails 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 DeserializeImportDiskDetails(document.RootElement, options); } default: @@ -148,6 +164,7 @@ ImportDiskDetails IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.cs index 655781c0234a..580ad50da30c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ImportDiskDetails.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Import disk details. public partial class ImportDiskDetails { - /// - /// 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 relative path of the manifest file on the disk. @@ -66,27 +38,25 @@ public ImportDiskDetails(string manifestFile, string manifestHash, string bitLoc /// The Base16-encoded MD5 hash of the manifest file on the disk. /// BitLocker key used to encrypt the disk. /// Path to backed up manifest, only returned if enableManifestBackup is true. - /// Keeps track of any properties unknown to the library. - internal ImportDiskDetails(string manifestFile, string manifestHash, string bitLockerKey, string backupManifestCloudPath, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ImportDiskDetails(string manifestFile, string manifestHash, string bitLockerKey, string backupManifestCloudPath, IDictionary additionalBinaryDataProperties) { ManifestFile = manifestFile; ManifestHash = manifestHash; BitLockerKey = bitLockerKey; BackupManifestCloudPath = backupManifestCloudPath; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ImportDiskDetails() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The relative path of the manifest file on the disk. public string ManifestFile { get; set; } + /// The Base16-encoded MD5 hash of the manifest file on the disk. public string ManifestHash { get; set; } + /// BitLocker key used to encrypt the disk. public string BitLockerKey { get; set; } + /// Path to backed up manifest, only returned if enableManifestBackup is true. public string BackupManifestCloudPath { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.Serialization.cs index 839ce8e69f87..276403f5b565 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class JobDelayDetails : IUtf8JsonSerializable, IJsonModel + /// Job Delay Notification details. + public partial class JobDelayDetails : 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, ModelReaderWriterO /// 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(JobDelayDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -59,15 +59,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("resolutionTime"u8); writer.WriteStringValue(ResolutionOn.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); } @@ -76,22 +76,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - JobDelayDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + JobDelayDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual JobDelayDetails 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(JobDelayDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeJobDelayDetails(document.RootElement, options); } - internal static JobDelayDetails DeserializeJobDelayDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static JobDelayDetails DeserializeJobDelayDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -99,72 +104,73 @@ internal static JobDelayDetails DeserializeJobDelayDetails(JsonElement element, DelayNotificationStatus? status = default; PortalDelayErrorCode? errorCode = default; string description = default; - DateTimeOffset? startTime = default; - DateTimeOffset? resolutionTime = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DateTimeOffset? startOn = default; + DateTimeOffset? resolutionOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new DelayNotificationStatus(property.Value.GetString()); + status = new DelayNotificationStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("errorCode"u8)) + if (prop.NameEquals("errorCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - errorCode = new PortalDelayErrorCode(property.Value.GetString()); + errorCode = new PortalDelayErrorCode(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("startTime"u8)) + if (prop.NameEquals("startTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - startTime = property.Value.GetDateTimeOffset("O"); + startOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("resolutionTime"u8)) + if (prop.NameEquals("resolutionTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - resolutionTime = property.Value.GetDateTimeOffset("O"); + resolutionOn = 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 JobDelayDetails( status, errorCode, description, - startTime, - resolutionTime, - serializedAdditionalRawData); + startOn, + resolutionOn, + 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": @@ -174,15 +180,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - JobDelayDetails 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. + JobDelayDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual JobDelayDetails 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 DeserializeJobDelayDetails(document.RootElement, options); } default: @@ -190,6 +201,7 @@ JobDelayDetails IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.cs index 2c492af3e425..0c2369e3060f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDelayDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Job Delay Notification details. public partial class JobDelayDetails { - /// - /// 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 JobDelayDetails() @@ -56,25 +27,29 @@ internal JobDelayDetails() /// Description of the delay. /// Timestamp when the delay notification was created. /// Timestamp when the delay notification was resolved. - /// Keeps track of any properties unknown to the library. - internal JobDelayDetails(DelayNotificationStatus? status, PortalDelayErrorCode? errorCode, string description, DateTimeOffset? startOn, DateTimeOffset? resolutionOn, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal JobDelayDetails(DelayNotificationStatus? status, PortalDelayErrorCode? errorCode, string description, DateTimeOffset? startOn, DateTimeOffset? resolutionOn, IDictionary additionalBinaryDataProperties) { Status = status; ErrorCode = errorCode; Description = description; StartOn = startOn; ResolutionOn = resolutionOn; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Status of notification. public DelayNotificationStatus? Status { get; } + /// Delay Error code. public PortalDelayErrorCode? ErrorCode { get; } + /// Description of the delay. public string Description { get; } + /// Timestamp when the delay notification was created. public DateTimeOffset? StartOn { get; } + /// Timestamp when the delay notification was resolved. public DateTimeOffset? ResolutionOn { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.Serialization.cs index efc2ba2463a7..831b2b61abc8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class JobDeliveryInfo : IUtf8JsonSerializable, IJsonModel + /// Additional delivery info. + internal partial class JobDeliveryInfo : 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 writer, ModelReaderWriterO /// 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(JobDeliveryInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ScheduledOn)) { writer.WritePropertyName("scheduledDateTime"u8); writer.WriteStringValue(ScheduledOn.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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - JobDeliveryInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + JobDeliveryInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual JobDeliveryInfo 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(JobDeliveryInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeJobDeliveryInfo(document.RootElement, options); } - internal static JobDeliveryInfo DeserializeJobDeliveryInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static JobDeliveryInfo DeserializeJobDeliveryInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DateTimeOffset? scheduledDateTime = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DateTimeOffset? scheduledOn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("scheduledDateTime"u8)) + if (prop.NameEquals("scheduledDateTime"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - scheduledDateTime = property.Value.GetDateTimeOffset("O"); + scheduledOn = 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 JobDeliveryInfo(scheduledDateTime, serializedAdditionalRawData); + return new JobDeliveryInfo(scheduledOn, 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(ModelReaderWriterOptions opt } } - JobDeliveryInfo 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. + JobDeliveryInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual JobDeliveryInfo 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 DeserializeJobDeliveryInfo(document.RootElement, options); } default: @@ -128,6 +139,7 @@ JobDeliveryInfo IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.cs index df0c22909db0..776a026eb4b8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryInfo.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Additional delivery info. internal partial class JobDeliveryInfo { - /// - /// 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 JobDeliveryInfo() @@ -52,11 +23,11 @@ public JobDeliveryInfo() /// Initializes a new instance of . /// Scheduled date time. - /// Keeps track of any properties unknown to the library. - internal JobDeliveryInfo(DateTimeOffset? scheduledOn, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal JobDeliveryInfo(DateTimeOffset? scheduledOn, IDictionary additionalBinaryDataProperties) { ScheduledOn = scheduledOn; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Scheduled date time. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryType.Serialization.cs index 901772a6cf8a..e69e825802f7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobDeliveryType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class JobDeliveryTypeExtensions { + /// The value to serialize. public static string ToSerialString(this JobDeliveryType value) => value switch { JobDeliveryType.NonScheduled => "NonScheduled", @@ -18,10 +19,17 @@ internal static partial class JobDeliveryTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown JobDeliveryType value.") }; + /// The value to deserialize. public static JobDeliveryType ToJobDeliveryType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "NonScheduled")) return JobDeliveryType.NonScheduled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Scheduled")) return JobDeliveryType.Scheduled; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "NonScheduled")) + { + return JobDeliveryType.NonScheduled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Scheduled")) + { + return JobDeliveryType.Scheduled; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown JobDeliveryType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobProperties.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobProperties.Serialization.cs new file mode 100644 index 000000000000..b2b313360819 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobProperties.Serialization.cs @@ -0,0 +1,399 @@ +// 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; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Job Properties. + internal partial class JobProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal JobProperties() + { + } + + /// 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(JobProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("transferType"u8); + writer.WriteStringValue(TransferType.ToSerialString()); + if (options.Format != "W" && Optional.IsDefined(IsCancellable)) + { + writer.WritePropertyName("isCancellable"u8); + writer.WriteBooleanValue(IsCancellable.Value); + } + if (options.Format != "W" && Optional.IsDefined(IsDeletable)) + { + writer.WritePropertyName("isDeletable"u8); + writer.WriteBooleanValue(IsDeletable.Value); + } + if (options.Format != "W" && Optional.IsDefined(IsShippingAddressEditable)) + { + writer.WritePropertyName("isShippingAddressEditable"u8); + writer.WriteBooleanValue(IsShippingAddressEditable.Value); + } + if (options.Format != "W" && Optional.IsDefined(ReverseShippingDetailsUpdate)) + { + writer.WritePropertyName("reverseShippingDetailsUpdate"u8); + writer.WriteStringValue(ReverseShippingDetailsUpdate.Value.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(ReverseTransportPreferenceUpdate)) + { + writer.WritePropertyName("reverseTransportPreferenceUpdate"u8); + writer.WriteStringValue(ReverseTransportPreferenceUpdate.Value.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(IsPrepareToShipEnabled)) + { + writer.WritePropertyName("isPrepareToShipEnabled"u8); + writer.WriteBooleanValue(IsPrepareToShipEnabled.Value); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(DelayedStage)) + { + writer.WritePropertyName("delayedStage"u8); + writer.WriteStringValue(DelayedStage.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(StartOn)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + ((IJsonModel)Error).Write(writer, options); + } + if (Optional.IsDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteObjectValue(Details, options); + } + if (options.Format != "W" && Optional.IsDefined(CancellationReason)) + { + writer.WritePropertyName("cancellationReason"u8); + writer.WriteStringValue(CancellationReason); + } + if (Optional.IsDefined(DeliveryType)) + { + writer.WritePropertyName("deliveryType"u8); + writer.WriteStringValue(DeliveryType.Value.ToSerialString()); + } + if (Optional.IsDefined(DeliveryInfo)) + { + writer.WritePropertyName("deliveryInfo"u8); + writer.WriteObjectValue(DeliveryInfo, options); + } + if (options.Format != "W" && Optional.IsDefined(IsCancellableWithoutFee)) + { + writer.WritePropertyName("isCancellableWithoutFee"u8); + writer.WriteBooleanValue(IsCancellableWithoutFee.Value); + } + if (options.Format != "W" && Optional.IsDefined(AreAllDevicesLost)) + { + writer.WritePropertyName("allDevicesLost"u8); + writer.WriteBooleanValue(AreAllDevicesLost.Value); + } + 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. + JobProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual JobProperties 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(JobProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeJobProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static JobProperties DeserializeJobProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataBoxJobTransferType transferType = default; + bool? isCancellable = default; + bool? isDeletable = default; + bool? isShippingAddressEditable = default; + ReverseShippingDetailsEditStatus? reverseShippingDetailsUpdate = default; + ReverseTransportPreferenceEditStatus? reverseTransportPreferenceUpdate = default; + bool? isPrepareToShipEnabled = default; + DataBoxStageName? status = default; + DataBoxStageName? delayedStage = default; + DateTimeOffset? startOn = default; + ResponseError error = default; + DataBoxBasicJobDetails details = default; + string cancellationReason = default; + JobDeliveryType? deliveryType = default; + JobDeliveryInfo deliveryInfo = default; + bool? isCancellableWithoutFee = default; + bool? areAllDevicesLost = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("transferType"u8)) + { + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); + continue; + } + if (prop.NameEquals("isCancellable"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isCancellable = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("isDeletable"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isDeletable = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("isShippingAddressEditable"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isShippingAddressEditable = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("reverseShippingDetailsUpdate"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reverseShippingDetailsUpdate = prop.Value.GetString().ToReverseShippingDetailsEditStatus(); + continue; + } + if (prop.NameEquals("reverseTransportPreferenceUpdate"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reverseTransportPreferenceUpdate = prop.Value.GetString().ToReverseTransportPreferenceEditStatus(); + continue; + } + if (prop.NameEquals("isPrepareToShipEnabled"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isPrepareToShipEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new DataBoxStageName(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("delayedStage"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + delayedStage = new DataBoxStageName(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("startTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); + continue; + } + if (prop.NameEquals("details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + details = DataBoxBasicJobDetails.DeserializeDataBoxBasicJobDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("cancellationReason"u8)) + { + cancellationReason = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("deliveryType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deliveryType = prop.Value.GetString().ToJobDeliveryType(); + continue; + } + if (prop.NameEquals("deliveryInfo"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deliveryInfo = JobDeliveryInfo.DeserializeJobDeliveryInfo(prop.Value, options); + continue; + } + if (prop.NameEquals("isCancellableWithoutFee"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isCancellableWithoutFee = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("allDevicesLost"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + areAllDevicesLost = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new JobProperties( + transferType, + isCancellable, + isDeletable, + isShippingAddressEditable, + reverseShippingDetailsUpdate, + reverseTransportPreferenceUpdate, + isPrepareToShipEnabled, + status, + delayedStage, + startOn, + error, + details, + cancellationReason, + deliveryType, + deliveryInfo, + isCancellableWithoutFee, + areAllDevicesLost, + 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, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(JobProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + JobProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual JobProperties 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 DeserializeJobProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(JobProperties)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobProperties.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobProperties.cs new file mode 100644 index 000000000000..2dea5acf9a70 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobProperties.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Job Properties. + internal partial class JobProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Type of the data transfer. + public JobProperties(DataBoxJobTransferType transferType) + { + TransferType = transferType; + } + + /// Initializes a new instance of . + /// Type of the data transfer. + /// Describes whether the job is cancellable or not. + /// Describes whether the job is deletable or not. + /// Describes whether the shipping address is editable or not. + /// The Editable status for Reverse Shipping Address and Contact Info. + /// The Editable status for Reverse Transport preferences. + /// Is Prepare To Ship Enabled on this job. + /// Name of the stage which is in progress. + /// Name of the stage where delay might be present. + /// Time at which the job was started in UTC ISO 8601 format. + /// Top level error for the job. + /// Details of a job run. This field will only be sent for expand details filter. + /// Reason for cancellation. + /// Delivery type of Job. + /// Delivery Info of Job. + /// Flag to indicate cancellation of scheduled job. + /// Flag to indicate if all devices associated with the job are lost. + /// Keeps track of any properties unknown to the library. + internal JobProperties(DataBoxJobTransferType transferType, bool? isCancellable, bool? isDeletable, bool? isShippingAddressEditable, ReverseShippingDetailsEditStatus? reverseShippingDetailsUpdate, ReverseTransportPreferenceEditStatus? reverseTransportPreferenceUpdate, bool? isPrepareToShipEnabled, DataBoxStageName? status, DataBoxStageName? delayedStage, DateTimeOffset? startOn, ResponseError error, DataBoxBasicJobDetails details, string cancellationReason, JobDeliveryType? deliveryType, JobDeliveryInfo deliveryInfo, bool? isCancellableWithoutFee, bool? areAllDevicesLost, IDictionary additionalBinaryDataProperties) + { + TransferType = transferType; + IsCancellable = isCancellable; + IsDeletable = isDeletable; + IsShippingAddressEditable = isShippingAddressEditable; + ReverseShippingDetailsUpdate = reverseShippingDetailsUpdate; + ReverseTransportPreferenceUpdate = reverseTransportPreferenceUpdate; + IsPrepareToShipEnabled = isPrepareToShipEnabled; + Status = status; + DelayedStage = delayedStage; + StartOn = startOn; + Error = error; + Details = details; + CancellationReason = cancellationReason; + DeliveryType = deliveryType; + DeliveryInfo = deliveryInfo; + IsCancellableWithoutFee = isCancellableWithoutFee; + AreAllDevicesLost = areAllDevicesLost; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of the data transfer. + public DataBoxJobTransferType TransferType { get; set; } + + /// Describes whether the job is cancellable or not. + public bool? IsCancellable { get; } + + /// Describes whether the job is deletable or not. + public bool? IsDeletable { get; } + + /// Describes whether the shipping address is editable or not. + public bool? IsShippingAddressEditable { get; } + + /// The Editable status for Reverse Shipping Address and Contact Info. + public ReverseShippingDetailsEditStatus? ReverseShippingDetailsUpdate { get; } + + /// The Editable status for Reverse Transport preferences. + public ReverseTransportPreferenceEditStatus? ReverseTransportPreferenceUpdate { get; } + + /// Is Prepare To Ship Enabled on this job. + public bool? IsPrepareToShipEnabled { get; } + + /// Name of the stage which is in progress. + public DataBoxStageName? Status { get; } + + /// Name of the stage where delay might be present. + public DataBoxStageName? DelayedStage { get; } + + /// Time at which the job was started in UTC ISO 8601 format. + public DateTimeOffset? StartOn { get; } + + /// Top level error for the job. + public ResponseError Error { get; } + + /// Details of a job run. This field will only be sent for expand details filter. + public DataBoxBasicJobDetails Details { get; set; } + + /// Reason for cancellation. + public string CancellationReason { get; } + + /// Delivery type of Job. + public JobDeliveryType? DeliveryType { get; set; } + + /// Delivery Info of Job. + internal JobDeliveryInfo DeliveryInfo { get; set; } + + /// Flag to indicate cancellation of scheduled job. + public bool? IsCancellableWithoutFee { get; } + + /// Flag to indicate if all devices associated with the job are lost. + public bool? AreAllDevicesLost { get; } + + /// Scheduled date time. + public DateTimeOffset? DeliveryInfoScheduledOn + { + get + { + return DeliveryInfo is null ? default : DeliveryInfo.ScheduledOn; + } + set + { + if (DeliveryInfo is null) + { + DeliveryInfo = new JobDeliveryInfo(); + } + DeliveryInfo.ScheduledOn = value; + } + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.Serialization.cs index d1d2e5c4e4c5..ecfffce1a28b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.Serialization.cs @@ -8,15 +8,25 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { + /// + /// The base class for the secrets + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// [PersistableModelProxy(typeof(UnknownJobSecrets))] - public partial class JobSecrets : IUtf8JsonSerializable, IJsonModel + public abstract partial class JobSecrets : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal JobSecrets() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +38,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption /// 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(JobSecrets)} does not support writing '{format}' format."); } - writer.WritePropertyName("jobSecretsType"u8); writer.WriteStringValue(JobSecretsType.ToSerialString()); if (options.Format != "W" && Optional.IsDefined(DataCenterAccessSecurityCode)) @@ -46,15 +55,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("error"u8); ((IJsonModel)Error).Write(writer, 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); } @@ -63,43 +72,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - JobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + JobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual JobSecrets 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(JobSecrets)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeJobSecrets(document.RootElement, options); } - internal static JobSecrets DeserializeJobSecrets(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static JobSecrets DeserializeJobSecrets(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("jobSecretsType", out JsonElement discriminator)) + if (element.TryGetProperty("jobSecretsType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "DataBox": return DataBoxJobSecrets.DeserializeDataBoxJobSecrets(element, options); - case "DataBoxCustomerDisk": return CustomerDiskJobSecrets.DeserializeCustomerDiskJobSecrets(element, options); - case "DataBoxDisk": return DataBoxDiskJobSecrets.DeserializeDataBoxDiskJobSecrets(element, options); - case "DataBoxHeavy": return DataBoxHeavyJobSecrets.DeserializeDataBoxHeavyJobSecrets(element, options); + case "DataBoxCustomerDisk": + return CustomerDiskJobSecrets.DeserializeCustomerDiskJobSecrets(element, options); + case "DataBoxDisk": + return DataBoxDiskJobSecrets.DeserializeDataBoxDiskJobSecrets(element, options); + case "DataBoxHeavy": + return DataBoxHeavyJobSecrets.DeserializeDataBoxHeavyJobSecrets(element, options); + case "DataBox": + return DataBoxJobSecrets.DeserializeDataBoxJobSecrets(element, options); } } return UnknownJobSecrets.DeserializeUnknownJobSecrets(element, options); } - 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": @@ -109,15 +130,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) } } - JobSecrets 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. + JobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual JobSecrets 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 DeserializeJobSecrets(document.RootElement, options); } default: @@ -125,6 +151,7 @@ JobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWrit } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.cs index a0fe7dff294a..030844db72ea 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/JobSecrets.cs @@ -7,70 +7,45 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { /// /// The base class for the secrets - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . /// public abstract partial class JobSecrets { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - protected JobSecrets() + /// Used to indicate what type of job secrets object. + private protected JobSecrets(DataBoxOrderType jobSecretsType) { + JobSecretsType = jobSecretsType; } /// Initializes a new instance of . /// Used to indicate what type of job secrets object. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. - /// Keeps track of any properties unknown to the library. - internal JobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal JobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary additionalBinaryDataProperties) { JobSecretsType = jobSecretsType; DataCenterAccessSecurityCode = dataCenterAccessSecurityCode; Error = error; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Used to indicate what type of job secrets object. internal DataBoxOrderType JobSecretsType { get; set; } + /// Dc Access Security Code for Customer Managed Shipping. public DataCenterAccessSecurityCode DataCenterAccessSecurityCode { get; } + /// Error while fetching the secrets. public ResponseError Error { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.Serialization.cs index 3a7e1d9f9517..6d3d502a54f8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class LastMitigationActionOnJob : IUtf8JsonSerializable, IJsonModel + /// Last Mitigation Action Performed On Job. + public partial class LastMitigationActionOnJob : 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, ModelRea /// 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(LastMitigationActionOnJob)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ActionPerformedOn)) { writer.WritePropertyName("actionDateTimeInUtc"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("customerResolution"u8); writer.WriteStringValue(CustomerResolution.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); } @@ -66,73 +66,79 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - LastMitigationActionOnJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + LastMitigationActionOnJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LastMitigationActionOnJob 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(LastMitigationActionOnJob)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeLastMitigationActionOnJob(document.RootElement, options); } - internal static LastMitigationActionOnJob DeserializeLastMitigationActionOnJob(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LastMitigationActionOnJob DeserializeLastMitigationActionOnJob(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DateTimeOffset? actionDateTimeInUtc = default; + DateTimeOffset? actionPerformedOn = default; bool? isPerformedByCustomer = default; CustomerResolutionCode? customerResolution = 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("actionDateTimeInUtc"u8)) + if (prop.NameEquals("actionDateTimeInUtc"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - actionDateTimeInUtc = property.Value.GetDateTimeOffset("O"); + actionPerformedOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("isPerformedByCustomer"u8)) + if (prop.NameEquals("isPerformedByCustomer"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isPerformedByCustomer = property.Value.GetBoolean(); + isPerformedByCustomer = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("customerResolution"u8)) + if (prop.NameEquals("customerResolution"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - customerResolution = property.Value.GetString().ToCustomerResolutionCode(); + customerResolution = prop.Value.GetString().ToCustomerResolutionCode(); 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 LastMitigationActionOnJob(actionDateTimeInUtc, isPerformedByCustomer, customerResolution, serializedAdditionalRawData); + return new LastMitigationActionOnJob(actionPerformedOn, isPerformedByCustomer, customerResolution, 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": @@ -142,15 +148,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO } } - LastMitigationActionOnJob 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. + LastMitigationActionOnJob IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LastMitigationActionOnJob 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 DeserializeLastMitigationActionOnJob(document.RootElement, options); } default: @@ -158,6 +169,7 @@ LastMitigationActionOnJob IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.cs index 736d1d5872bc..63e8dd669f31 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LastMitigationActionOnJob.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Last Mitigation Action Performed On Job. public partial class LastMitigationActionOnJob { - /// - /// 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 LastMitigationActionOnJob() @@ -57,22 +28,24 @@ internal LastMitigationActionOnJob() /// possibility is that mitigation might happen by customer or service or by ops /// /// Resolution code provided by customer. - /// Keeps track of any properties unknown to the library. - internal LastMitigationActionOnJob(DateTimeOffset? actionPerformedOn, bool? isPerformedByCustomer, CustomerResolutionCode? customerResolution, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal LastMitigationActionOnJob(DateTimeOffset? actionPerformedOn, bool? isPerformedByCustomer, CustomerResolutionCode? customerResolution, IDictionary additionalBinaryDataProperties) { ActionPerformedOn = actionPerformedOn; IsPerformedByCustomer = isPerformedByCustomer; CustomerResolution = customerResolution; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Action performed date time. public DateTimeOffset? ActionPerformedOn { get; } + /// /// Action performed by customer, /// possibility is that mitigation might happen by customer or service or by ops /// public bool? IsPerformedByCustomer { get; } + /// Resolution code provided by customer. public CustomerResolutionCode? CustomerResolution { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LogCollectionLevel.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LogCollectionLevel.Serialization.cs index 2ee85014d022..a1e08275c7e4 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LogCollectionLevel.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/LogCollectionLevel.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class LogCollectionLevelExtensions { + /// The value to serialize. public static string ToSerialString(this LogCollectionLevel value) => value switch { LogCollectionLevel.Error => "Error", @@ -18,10 +19,17 @@ internal static partial class LogCollectionLevelExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown LogCollectionLevel value.") }; + /// The value to deserialize. public static LogCollectionLevel ToLogCollectionLevel(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Error")) return LogCollectionLevel.Error; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Verbose")) return LogCollectionLevel.Verbose; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Error")) + { + return LogCollectionLevel.Error; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Verbose")) + { + return LogCollectionLevel.Verbose; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown LogCollectionLevel value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.Serialization.cs index 91924bfb456f..e3762008d50f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ManagedDiskDetails : IUtf8JsonSerializable, IJsonModel + /// Details of the managed disks. + public partial class ManagedDiskDetails : DataAccountDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ManagedDiskDetails() + { + } + /// 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, ModelReaderWrit /// 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(ManagedDiskDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("resourceGroupId"u8); writer.WriteStringValue(ResourceGroupId); @@ -41,67 +47,73 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStringValue(StagingStorageAccountId); } - ManagedDiskDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ManagedDiskDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ManagedDiskDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataAccountDetails 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(ManagedDiskDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeManagedDiskDetails(document.RootElement, options); } - internal static ManagedDiskDetails DeserializeManagedDiskDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ManagedDiskDetails DeserializeManagedDiskDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier resourceGroupId = default; - ResourceIdentifier stagingStorageAccountId = default; DataAccountType dataAccountType = default; string sharePassword = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResourceIdentifier resourceGroupId = default; + ResourceIdentifier stagingStorageAccountId = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("resourceGroupId"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - resourceGroupId = new ResourceIdentifier(property.Value.GetString()); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("stagingStorageAccountId"u8)) + if (prop.NameEquals("sharePassword"u8)) { - stagingStorageAccountId = new ResourceIdentifier(property.Value.GetString()); + sharePassword = prop.Value.GetString(); continue; } - if (property.NameEquals("dataAccountType"u8)) + if (prop.NameEquals("resourceGroupId"u8)) { - dataAccountType = property.Value.GetString().ToDataAccountType(); + resourceGroupId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("sharePassword"u8)) + if (prop.NameEquals("stagingStorageAccountId"u8)) { - sharePassword = property.Value.GetString(); + stagingStorageAccountId = 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 ManagedDiskDetails(dataAccountType, sharePassword, serializedAdditionalRawData, resourceGroupId, stagingStorageAccountId); + return new ManagedDiskDetails(dataAccountType, sharePassword, additionalBinaryDataProperties, resourceGroupId, stagingStorageAccountId); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -111,15 +123,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - ManagedDiskDetails 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. + ManagedDiskDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ManagedDiskDetails)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataAccountDetails 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 DeserializeManagedDiskDetails(document.RootElement, options); } default: @@ -127,6 +144,7 @@ ManagedDiskDetails IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.cs index 90be31889bcd..0eaab1d91385 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ManagedDiskDetails.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -18,36 +19,30 @@ public partial class ManagedDiskDetails : DataAccountDetails /// Resource Group Id of the compute disks. /// Resource Id of the storage account that can be used to copy the vhd for staging. /// or is null. - public ManagedDiskDetails(ResourceIdentifier resourceGroupId, ResourceIdentifier stagingStorageAccountId) + public ManagedDiskDetails(ResourceIdentifier resourceGroupId, ResourceIdentifier stagingStorageAccountId) : base(DataAccountType.ManagedDisk) { Argument.AssertNotNull(resourceGroupId, nameof(resourceGroupId)); Argument.AssertNotNull(stagingStorageAccountId, nameof(stagingStorageAccountId)); ResourceGroupId = resourceGroupId; StagingStorageAccountId = stagingStorageAccountId; - DataAccountType = DataAccountType.ManagedDisk; } /// Initializes a new instance of . /// Account Type of the data to be transferred. /// Password for all the shares to be created on the device. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Resource Group Id of the compute disks. /// Resource Id of the storage account that can be used to copy the vhd for staging. - internal ManagedDiskDetails(DataAccountType dataAccountType, string sharePassword, IDictionary serializedAdditionalRawData, ResourceIdentifier resourceGroupId, ResourceIdentifier stagingStorageAccountId) : base(dataAccountType, sharePassword, serializedAdditionalRawData) + internal ManagedDiskDetails(DataAccountType dataAccountType, string sharePassword, IDictionary additionalBinaryDataProperties, ResourceIdentifier resourceGroupId, ResourceIdentifier stagingStorageAccountId) : base(dataAccountType, sharePassword, additionalBinaryDataProperties) { ResourceGroupId = resourceGroupId; StagingStorageAccountId = stagingStorageAccountId; - DataAccountType = dataAccountType; - } - - /// Initializes a new instance of for deserialization. - internal ManagedDiskDetails() - { } /// Resource Group Id of the compute disks. public ResourceIdentifier ResourceGroupId { get; set; } + /// Resource Id of the storage account that can be used to copy the vhd for staging. public ResourceIdentifier StagingStorageAccountId { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.Serialization.cs index 656d914ba3ab..896278b43a0c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class MarkDevicesShippedContent : IUtf8JsonSerializable, IJsonModel + /// The request body to provide the delivery package details of job. + public partial class MarkDevicesShippedContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal MarkDevicesShippedContent() + { + } + /// 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(Utf8JsonWriter writer, ModelRea /// 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(MarkDevicesShippedContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("deliverToDcPackageDetails"u8); writer.WriteObjectValue(DeliverToDataCenterPackageDetails, 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); } @@ -53,49 +59,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MarkDevicesShippedContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MarkDevicesShippedContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MarkDevicesShippedContent 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(MarkDevicesShippedContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeMarkDevicesShippedContent(document.RootElement, options); } - internal static MarkDevicesShippedContent DeserializeMarkDevicesShippedContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MarkDevicesShippedContent DeserializeMarkDevicesShippedContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - PackageCarrierInfo deliverToDcPackageDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + PackageCarrierInfo deliverToDataCenterPackageDetails = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("deliverToDcPackageDetails"u8)) + if (prop.NameEquals("deliverToDcPackageDetails"u8)) { - deliverToDcPackageDetails = PackageCarrierInfo.DeserializePackageCarrierInfo(property.Value, options); + deliverToDataCenterPackageDetails = PackageCarrierInfo.DeserializePackageCarrierInfo(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 MarkDevicesShippedContent(deliverToDcPackageDetails, serializedAdditionalRawData); + return new MarkDevicesShippedContent(deliverToDataCenterPackageDetails, 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.Write(ModelReaderWriterO } } - MarkDevicesShippedContent 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. + MarkDevicesShippedContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MarkDevicesShippedContent 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 DeserializeMarkDevicesShippedContent(document.RootElement, options); } default: @@ -121,6 +138,19 @@ MarkDevicesShippedContent IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(MarkDevicesShippedContent markDevicesShippedContent) + { + if (markDevicesShippedContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(markDevicesShippedContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.cs index ec7b70d3e8a9..7b7f8e7f46f2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MarkDevicesShippedContent.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// The request body to provide the delivery package details of job. public partial class MarkDevicesShippedContent { - /// - /// 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 . /// Delivery package details. @@ -57,16 +29,11 @@ public MarkDevicesShippedContent(PackageCarrierInfo deliverToDataCenterPackageDe /// Initializes a new instance of . /// Delivery package details. - /// Keeps track of any properties unknown to the library. - internal MarkDevicesShippedContent(PackageCarrierInfo deliverToDataCenterPackageDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal MarkDevicesShippedContent(PackageCarrierInfo deliverToDataCenterPackageDetails, IDictionary additionalBinaryDataProperties) { DeliverToDataCenterPackageDetails = deliverToDataCenterPackageDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal MarkDevicesShippedContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Delivery package details. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.Serialization.cs index 43a438a6d39a..291087ffd296 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class MitigateJobContent : IUtf8JsonSerializable, IJsonModel + /// The Mitigate Job captured from request body for Mitigate API. + public partial class MitigateJobContent : 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,14 +30,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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(MitigateJobContent)} does not support writing '{format}' format."); } - - writer.WritePropertyName("customerResolutionCode"u8); - writer.WriteStringValue(CustomerResolutionCode.ToSerialString()); + if (Optional.IsDefined(CustomerResolutionCode)) + { + writer.WritePropertyName("customerResolutionCode"u8); + writer.WriteStringValue(CustomerResolutionCode.Value.ToSerialString()); + } if (Optional.IsCollectionDefined(SerialNumberCustomerResolutionMap)) { writer.WritePropertyName("serialNumberCustomerResolutionMap"u8); @@ -47,15 +51,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } 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); } @@ -64,68 +68,74 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MitigateJobContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MitigateJobContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MitigateJobContent 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(MitigateJobContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeMitigateJobContent(document.RootElement, options); } - internal static MitigateJobContent DeserializeMitigateJobContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MitigateJobContent DeserializeMitigateJobContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - CustomerResolutionCode customerResolutionCode = default; + CustomerResolutionCode? customerResolutionCode = default; IDictionary serialNumberCustomerResolutionMap = 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("customerResolutionCode"u8)) + if (prop.NameEquals("customerResolutionCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - customerResolutionCode = property.Value.GetString().ToCustomerResolutionCode(); + customerResolutionCode = prop.Value.GetString().ToCustomerResolutionCode(); continue; } - if (property.NameEquals("serialNumberCustomerResolutionMap"u8)) + if (prop.NameEquals("serialNumberCustomerResolutionMap"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().ToCustomerResolutionCode()); + dictionary.Add(prop0.Name, prop0.Value.GetString().ToCustomerResolutionCode()); } serialNumberCustomerResolutionMap = 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 MitigateJobContent(customerResolutionCode, serialNumberCustomerResolutionMap ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new MitigateJobContent(customerResolutionCode, serialNumberCustomerResolutionMap ?? 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": @@ -135,15 +145,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - MitigateJobContent 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. + MitigateJobContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MitigateJobContent 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 DeserializeMitigateJobContent(document.RootElement, options); } default: @@ -151,6 +166,19 @@ MitigateJobContent IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(MitigateJobContent mitigateJobContent) + { + if (mitigateJobContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(mitigateJobContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.cs index 3cea7074f36a..7caa30d2342c 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/MitigateJobContent.cs @@ -13,48 +13,20 @@ namespace Azure.ResourceManager.DataBox.Models /// The Mitigate Job captured from request body for Mitigate API. public partial class MitigateJobContent { - /// - /// 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 . /// Resolution code for the job. /// Serial number and the customer resolution code corresponding to each serial number. - /// Keeps track of any properties unknown to the library. - internal MitigateJobContent(CustomerResolutionCode customerResolutionCode, IDictionary serialNumberCustomerResolutionMap, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal MitigateJobContent(CustomerResolutionCode? customerResolutionCode, IDictionary serialNumberCustomerResolutionMap, IDictionary additionalBinaryDataProperties) { CustomerResolutionCode = customerResolutionCode; SerialNumberCustomerResolutionMap = serialNumberCustomerResolutionMap; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + /// Serial number and the customer resolution code corresponding to each serial number. public IDictionary SerialNumberCustomerResolutionMap { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.Serialization.cs index 8b3c87eeba49..f90b896bbab8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class NotificationPreference : IUtf8JsonSerializable, IJsonModel + /// Notification preference for a job stage. + public partial class NotificationPreference : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal NotificationPreference() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,25 +34,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(NotificationPreference)} does not support writing '{format}' format."); } - writer.WritePropertyName("stageName"u8); writer.WriteStringValue(StageName.ToString()); writer.WritePropertyName("sendNotification"u8); writer.WriteBooleanValue(SendNotification); - 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); } @@ -55,55 +60,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - NotificationPreference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + NotificationPreference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual NotificationPreference 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(NotificationPreference)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeNotificationPreference(document.RootElement, options); } - internal static NotificationPreference DeserializeNotificationPreference(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static NotificationPreference DeserializeNotificationPreference(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } NotificationStageName stageName = default; bool sendNotification = 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("stageName"u8)) + if (prop.NameEquals("stageName"u8)) { - stageName = new NotificationStageName(property.Value.GetString()); + stageName = new NotificationStageName(prop.Value.GetString()); continue; } - if (property.NameEquals("sendNotification"u8)) + if (prop.NameEquals("sendNotification"u8)) { - sendNotification = property.Value.GetBoolean(); + sendNotification = prop.Value.GetBoolean(); 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 NotificationPreference(stageName, sendNotification, serializedAdditionalRawData); + return new NotificationPreference(stageName, sendNotification, 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": @@ -113,15 +124,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - NotificationPreference 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. + NotificationPreference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual NotificationPreference 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 DeserializeNotificationPreference(document.RootElement, options); } default: @@ -129,6 +145,7 @@ NotificationPreference IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.cs index 1734b5b9daaf..7d6a621e4406 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationPreference.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Notification preference for a job stage. public partial class NotificationPreference { - /// - /// 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 stage. @@ -57,21 +28,17 @@ public NotificationPreference(NotificationStageName stageName, bool sendNotifica /// Initializes a new instance of . /// Name of the stage. /// Notification is required or not. - /// Keeps track of any properties unknown to the library. - internal NotificationPreference(NotificationStageName stageName, bool sendNotification, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal NotificationPreference(NotificationStageName stageName, bool sendNotification, IDictionary additionalBinaryDataProperties) { StageName = stageName; SendNotification = sendNotification; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal NotificationPreference() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the stage. public NotificationStageName StageName { get; set; } + /// Notification is required or not. public bool SendNotification { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationStageName.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationStageName.cs index 60892465cf69..42789ed3fdc8 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationStageName.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/NotificationStageName.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,56 +15,87 @@ namespace Azure.ResourceManager.DataBox.Models public readonly partial struct NotificationStageName : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public NotificationStageName(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - + /// Notification at device prepared stage. private const string DevicePreparedValue = "DevicePrepared"; + /// Notification at device dispatched stage. private const string DispatchedValue = "Dispatched"; + /// Notification at device delivered stage. private const string DeliveredValue = "Delivered"; + /// Notification at device picked up from user stage. private const string PickedUpValue = "PickedUp"; + /// Notification at device received at Azure datacenter stage. private const string AtAzureDataCenterValue = "AtAzureDC"; + /// Notification at data copy started stage. private const string DataCopyValue = "DataCopy"; + /// Notification at job created stage. private const string CreatedValue = "Created"; + /// Notification at shipped devices to customer stage. private const string ShippedToCustomerValue = "ShippedToCustomer"; + /// Initializes a new instance of . + /// The value. + /// is null. + public NotificationStageName(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// Notification at device prepared stage. public static NotificationStageName DevicePrepared { get; } = new NotificationStageName(DevicePreparedValue); + /// Notification at device dispatched stage. public static NotificationStageName Dispatched { get; } = new NotificationStageName(DispatchedValue); + /// Notification at device delivered stage. public static NotificationStageName Delivered { get; } = new NotificationStageName(DeliveredValue); + /// Notification at device picked up from user stage. public static NotificationStageName PickedUp { get; } = new NotificationStageName(PickedUpValue); + /// Notification at device received at Azure datacenter stage. public static NotificationStageName AtAzureDataCenter { get; } = new NotificationStageName(AtAzureDataCenterValue); + /// Notification at data copy started stage. public static NotificationStageName DataCopy { get; } = new NotificationStageName(DataCopyValue); + /// Notification at job created stage. public static NotificationStageName Created { get; } = new NotificationStageName(CreatedValue); + /// Notification at shipped devices to customer stage. public static NotificationStageName ShippedToCustomer { get; } = new NotificationStageName(ShippedToCustomerValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(NotificationStageName left, NotificationStageName 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 !=(NotificationStageName left, NotificationStageName right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator NotificationStageName(string value) => new NotificationStageName(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator NotificationStageName?(string value) => value == null ? null : new NotificationStageName(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is NotificationStageName other && Equals(other); - /// + + /// public bool Equals(NotificationStageName 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/OverallValidationStatus.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/OverallValidationStatus.Serialization.cs index ecc74452c2a0..1f4b5b6d8be2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/OverallValidationStatus.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/OverallValidationStatus.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class OverallValidationStatusExtensions { + /// The value to serialize. public static string ToSerialString(this OverallValidationStatus value) => value switch { OverallValidationStatus.AllValidToProceed => "AllValidToProceed", @@ -19,11 +20,21 @@ internal static partial class OverallValidationStatusExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown OverallValidationStatus value.") }; + /// The value to deserialize. public static OverallValidationStatus ToOverallValidationStatus(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AllValidToProceed")) return OverallValidationStatus.AllValidToProceed; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "InputsRevisitRequired")) return OverallValidationStatus.InputsRevisitRequired; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CertainInputValidationsSkipped")) return OverallValidationStatus.CertainInputValidationsSkipped; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "AllValidToProceed")) + { + return OverallValidationStatus.AllValidToProceed; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "InputsRevisitRequired")) + { + return OverallValidationStatus.InputsRevisitRequired; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "CertainInputValidationsSkipped")) + { + return OverallValidationStatus.CertainInputValidationsSkipped; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown OverallValidationStatus value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.Serialization.cs index 44609a5ef541..089e75a1f0e5 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class PackageCarrierDetails : IUtf8JsonSerializable, IJsonModel + /// Package carrier details. + public partial class PackageCarrierDetails : 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, ModelReaderW /// 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(PackageCarrierDetails)} does not support writing '{format}' format."); } - if (Optional.IsDefined(CarrierAccountNumber)) { writer.WritePropertyName("carrierAccountNumber"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("trackingId"u8); writer.WriteStringValue(TrackingId); } - 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 } } - PackageCarrierDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PackageCarrierDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PackageCarrierDetails 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(PackageCarrierDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializePackageCarrierDetails(document.RootElement, options); } - internal static PackageCarrierDetails DeserializePackageCarrierDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PackageCarrierDetails DeserializePackageCarrierDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,38 +94,39 @@ internal static PackageCarrierDetails DeserializePackageCarrierDetails(JsonEleme string carrierAccountNumber = default; string carrierName = default; string trackingId = 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("carrierAccountNumber"u8)) + if (prop.NameEquals("carrierAccountNumber"u8)) { - carrierAccountNumber = property.Value.GetString(); + carrierAccountNumber = prop.Value.GetString(); continue; } - if (property.NameEquals("carrierName"u8)) + if (prop.NameEquals("carrierName"u8)) { - carrierName = property.Value.GetString(); + carrierName = prop.Value.GetString(); continue; } - if (property.NameEquals("trackingId"u8)) + if (prop.NameEquals("trackingId"u8)) { - trackingId = property.Value.GetString(); + trackingId = 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 PackageCarrierDetails(carrierAccountNumber, carrierName, trackingId, serializedAdditionalRawData); + return new PackageCarrierDetails(carrierAccountNumber, carrierName, trackingId, 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 +136,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - PackageCarrierDetails 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. + PackageCarrierDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PackageCarrierDetails 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 DeserializePackageCarrierDetails(document.RootElement, options); } default: @@ -146,6 +157,7 @@ PackageCarrierDetails IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.cs index d9ba727929fb..75ec7eb649ea 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Package carrier details. public partial class PackageCarrierDetails { - /// - /// 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 PackageCarrierDetails() @@ -54,19 +25,21 @@ public PackageCarrierDetails() /// Carrier Account Number of customer for customer disk. /// Name of the carrier. /// Tracking Id of shipment. - /// Keeps track of any properties unknown to the library. - internal PackageCarrierDetails(string carrierAccountNumber, string carrierName, string trackingId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal PackageCarrierDetails(string carrierAccountNumber, string carrierName, string trackingId, IDictionary additionalBinaryDataProperties) { CarrierAccountNumber = carrierAccountNumber; CarrierName = carrierName; TrackingId = trackingId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Carrier Account Number of customer for customer disk. public string CarrierAccountNumber { get; set; } + /// Name of the carrier. public string CarrierName { get; set; } + /// Tracking Id of shipment. public string TrackingId { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.Serialization.cs index 623f96b6e6ea..6eee437c099b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class PackageCarrierInfo : IUtf8JsonSerializable, IJsonModel + /// package carrier info. + public partial class PackageCarrierInfo : 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, ModelReaderWrit /// 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(PackageCarrierInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(CarrierName)) { writer.WritePropertyName("carrierName"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("trackingId"u8); writer.WriteStringValue(TrackingId); } - 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,55 +61,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - PackageCarrierInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PackageCarrierInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PackageCarrierInfo 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(PackageCarrierInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializePackageCarrierInfo(document.RootElement, options); } - internal static PackageCarrierInfo DeserializePackageCarrierInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PackageCarrierInfo DeserializePackageCarrierInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string carrierName = default; string trackingId = 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("carrierName"u8)) + if (prop.NameEquals("carrierName"u8)) { - carrierName = property.Value.GetString(); + carrierName = prop.Value.GetString(); continue; } - if (property.NameEquals("trackingId"u8)) + if (prop.NameEquals("trackingId"u8)) { - trackingId = property.Value.GetString(); + trackingId = 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 PackageCarrierInfo(carrierName, trackingId, serializedAdditionalRawData); + return new PackageCarrierInfo(carrierName, trackingId, 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": @@ -119,15 +125,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - PackageCarrierInfo 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. + PackageCarrierInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PackageCarrierInfo 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 DeserializePackageCarrierInfo(document.RootElement, options); } default: @@ -135,6 +146,7 @@ PackageCarrierInfo IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.cs index b40e5ed79b86..b461f7970aaa 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageCarrierInfo.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// package carrier info. public partial class PackageCarrierInfo { - /// - /// 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 PackageCarrierInfo() @@ -53,16 +24,17 @@ public PackageCarrierInfo() /// Initializes a new instance of . /// Name of the carrier. /// Tracking Id of shipment. - /// Keeps track of any properties unknown to the library. - internal PackageCarrierInfo(string carrierName, string trackingId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal PackageCarrierInfo(string carrierName, string trackingId, IDictionary additionalBinaryDataProperties) { CarrierName = carrierName; TrackingId = trackingId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the carrier. public string CarrierName { get; set; } + /// Tracking Id of shipment. public string TrackingId { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.Serialization.cs index 05a2e80527fd..45f9958c9e83 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class PackageShippingDetails : IUtf8JsonSerializable, IJsonModel + /// package shipping details. + public partial class PackageShippingDetails : 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, ModelReader /// 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(PackageShippingDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(TrackingUri)) { writer.WritePropertyName("trackingUrl"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("trackingId"u8); writer.WriteStringValue(TrackingId); } - 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,65 +66,71 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - PackageShippingDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PackageShippingDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PackageShippingDetails 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(PackageShippingDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializePackageShippingDetails(document.RootElement, options); } - internal static PackageShippingDetails DeserializePackageShippingDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PackageShippingDetails DeserializePackageShippingDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - Uri trackingUrl = default; + Uri trackingUri = default; string carrierName = default; string trackingId = 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("trackingUrl"u8)) + if (prop.NameEquals("trackingUrl"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - trackingUrl = new Uri(property.Value.GetString()); + trackingUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("carrierName"u8)) + if (prop.NameEquals("carrierName"u8)) { - carrierName = property.Value.GetString(); + carrierName = prop.Value.GetString(); continue; } - if (property.NameEquals("trackingId"u8)) + if (prop.NameEquals("trackingId"u8)) { - trackingId = property.Value.GetString(); + trackingId = 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 PackageShippingDetails(trackingUrl, carrierName, trackingId, serializedAdditionalRawData); + return new PackageShippingDetails(trackingUri, carrierName, trackingId, 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": @@ -134,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - PackageShippingDetails 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. + PackageShippingDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PackageShippingDetails 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 DeserializePackageShippingDetails(document.RootElement, options); } default: @@ -150,6 +161,7 @@ PackageShippingDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.cs index a5220bbb1bb4..fa864b6434f4 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PackageShippingDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// package shipping details. public partial class PackageShippingDetails { - /// - /// 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 PackageShippingDetails() @@ -54,19 +25,21 @@ internal PackageShippingDetails() /// Url where shipment can be tracked. /// Name of the carrier. /// Tracking Id of shipment. - /// Keeps track of any properties unknown to the library. - internal PackageShippingDetails(Uri trackingUri, string carrierName, string trackingId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal PackageShippingDetails(Uri trackingUri, string carrierName, string trackingId, IDictionary additionalBinaryDataProperties) { TrackingUri = trackingUri; CarrierName = carrierName; TrackingId = trackingId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Url where shipment can be tracked. public Uri TrackingUri { get; } + /// Name of the carrier. public string CarrierName { get; } + /// Tracking Id of shipment. public string TrackingId { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PortalDelayErrorCode.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PortalDelayErrorCode.cs index 8273282d0e0f..c90fb33b5721 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PortalDelayErrorCode.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PortalDelayErrorCode.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -14,44 +15,67 @@ namespace Azure.ResourceManager.DataBox.Models public readonly partial struct PortalDelayErrorCode : IEquatable { private readonly string _value; + /// Delay due to any internal reasons. + private const string InternalIssueDelayValue = "InternalIssueDelay"; + /// Active Order limit breached. + private const string ActiveOrderLimitBreachedDelayValue = "ActiveOrderLimitBreachedDelay"; + /// High demand. + private const string HighDemandDelayValue = "HighDemandDelay"; + /// Slow copy due to large number of files. + private const string LargeNumberOfFilesDelayValue = "LargeNumberOfFilesDelay"; /// Initializes a new instance of . + /// The value. /// is null. public PortalDelayErrorCode(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string InternalIssueDelayValue = "InternalIssueDelay"; - private const string ActiveOrderLimitBreachedDelayValue = "ActiveOrderLimitBreachedDelay"; - private const string HighDemandDelayValue = "HighDemandDelay"; - private const string LargeNumberOfFilesDelayValue = "LargeNumberOfFilesDelay"; + _value = value; + } /// Delay due to any internal reasons. public static PortalDelayErrorCode InternalIssueDelay { get; } = new PortalDelayErrorCode(InternalIssueDelayValue); + /// Active Order limit breached. public static PortalDelayErrorCode ActiveOrderLimitBreachedDelay { get; } = new PortalDelayErrorCode(ActiveOrderLimitBreachedDelayValue); + /// High demand. public static PortalDelayErrorCode HighDemandDelay { get; } = new PortalDelayErrorCode(HighDemandDelayValue); + /// Slow copy due to large number of files. public static PortalDelayErrorCode LargeNumberOfFilesDelay { get; } = new PortalDelayErrorCode(LargeNumberOfFilesDelayValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(PortalDelayErrorCode left, PortalDelayErrorCode 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 !=(PortalDelayErrorCode left, PortalDelayErrorCode right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator PortalDelayErrorCode(string value) => new PortalDelayErrorCode(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator PortalDelayErrorCode?(string value) => value == null ? null : new PortalDelayErrorCode(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is PortalDelayErrorCode other && Equals(other); - /// + + /// public bool Equals(PortalDelayErrorCode 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.Serialization.cs index 7983e8ac0539..86c050cda31d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class PreferencesValidationContent : IUtf8JsonSerializable, IJsonModel + /// Request to validate preference of transport and data center. + public partial class PreferencesValidationContent : DataBoxValidationInputContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal PreferencesValidationContent() + { + } + /// 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.Write(Utf8JsonWriter writer, Model /// 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(PreferencesValidationContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Preference)) { @@ -49,75 +54,81 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - PreferencesValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PreferencesValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (PreferencesValidationContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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(PreferencesValidationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializePreferencesValidationContent(document.RootElement, options); } - internal static PreferencesValidationContent DeserializePreferencesValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PreferencesValidationContent DeserializePreferencesValidationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxValidationInputDiscriminator validationType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); DataBoxOrderPreferences preference = default; DataBoxSkuName deviceType = default; DeviceModelName? model = default; - DataBoxValidationInputDiscriminator validationType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("preference"u8)) + if (prop.NameEquals("validationType"u8)) + { + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); + continue; + } + if (prop.NameEquals("preference"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - preference = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(property.Value, options); + preference = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(prop.Value, options); continue; } - if (property.NameEquals("deviceType"u8)) + if (prop.NameEquals("deviceType"u8)) { - deviceType = property.Value.GetString().ToDataBoxSkuName(); + deviceType = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); - continue; - } - if (property.NameEquals("validationType"u8)) - { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + model = prop.Value.GetString().ToDeviceModelName(); 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 PreferencesValidationContent(validationType, serializedAdditionalRawData, preference, deviceType, model); + return new PreferencesValidationContent(validationType, additionalBinaryDataProperties, preference, deviceType, model); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +138,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - PreferencesValidationContent 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. + PreferencesValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (PreferencesValidationContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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 DeserializePreferencesValidationContent(document.RootElement, options); } default: @@ -143,6 +159,7 @@ PreferencesValidationContent IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.cs index 8f561fb50823..d8abe71222c4 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationContent.cs @@ -15,35 +15,30 @@ public partial class PreferencesValidationContent : DataBoxValidationInputConten { /// Initializes a new instance of . /// Device type to be used for the job. - public PreferencesValidationContent(DataBoxSkuName deviceType) + public PreferencesValidationContent(DataBoxSkuName deviceType) : base(DataBoxValidationInputDiscriminator.ValidatePreferences) { DeviceType = deviceType; - ValidationType = DataBoxValidationInputDiscriminator.ValidatePreferences; } /// Initializes a new instance of . /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Preference of transport and data center. /// Device type to be used for the job. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - internal PreferencesValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData, DataBoxOrderPreferences preference, DataBoxSkuName deviceType, DeviceModelName? model) : base(validationType, serializedAdditionalRawData) + internal PreferencesValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties, DataBoxOrderPreferences preference, DataBoxSkuName deviceType, DeviceModelName? model) : base(validationType, additionalBinaryDataProperties) { Preference = preference; DeviceType = deviceType; Model = model; - ValidationType = validationType; - } - - /// Initializes a new instance of for deserialization. - internal PreferencesValidationContent() - { } /// Preference of transport and data center. public DataBoxOrderPreferences Preference { get; set; } + /// Device type to be used for the job. public DataBoxSkuName DeviceType { get; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.Serialization.cs index 6e729c3f8bd3..c2b0a186e184 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class PreferencesValidationResult : IUtf8JsonSerializable, IJsonModel + /// Properties of data center and transport preference validation response. + public partial class PreferencesValidationResult : DataBoxValidationInputResult, 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(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// 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(PreferencesValidationResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(Status)) { @@ -43,69 +44,75 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - PreferencesValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + PreferencesValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (PreferencesValidationResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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(PreferencesValidationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializePreferencesValidationResult(document.RootElement, options); } - internal static PreferencesValidationResult DeserializePreferencesValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PreferencesValidationResult DeserializePreferencesValidationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DataBoxValidationStatus? status = default; DataBoxValidationInputDiscriminator validationType = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DataBoxValidationStatus? status = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("validationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = property.Value.GetString().ToDataBoxValidationStatus(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("error"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + status = prop.Value.GetString().ToDataBoxValidationStatus(); 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 PreferencesValidationResult(validationType, error, serializedAdditionalRawData, status); + return new PreferencesValidationResult(validationType, error, additionalBinaryDataProperties, status); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +122,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - PreferencesValidationResult 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. + PreferencesValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (PreferencesValidationResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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 DeserializePreferencesValidationResult(document.RootElement, options); } default: @@ -131,6 +143,7 @@ PreferencesValidationResult IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.cs index 7e8d56d140a3..98a684635fe1 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/PreferencesValidationResult.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { @@ -14,20 +15,18 @@ namespace Azure.ResourceManager.DataBox.Models public partial class PreferencesValidationResult : DataBoxValidationInputResult { /// Initializes a new instance of . - internal PreferencesValidationResult() + internal PreferencesValidationResult() : base(DataBoxValidationInputDiscriminator.ValidatePreferences) { - ValidationType = DataBoxValidationInputDiscriminator.ValidatePreferences; } /// Initializes a new instance of . /// Identifies the type of validation response. /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Validation status of requested data center and transport. - internal PreferencesValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData, DataBoxValidationStatus? status) : base(validationType, error, serializedAdditionalRawData) + internal PreferencesValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties, DataBoxValidationStatus? status) : base(validationType, error, additionalBinaryDataProperties) { Status = status; - ValidationType = validationType; } /// Validation status of requested data center and transport. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.Serialization.cs index 83c4ba0a7115..393a4fa568cb 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class RegionConfigurationContent : IUtf8JsonSerializable, IJsonModel + /// Request body to get the configuration for the region. + public partial class RegionConfigurationContent : 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, 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(RegionConfigurationContent)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ScheduleAvailabilityRequest)) { writer.WritePropertyName("scheduleAvailabilityRequest"u8); @@ -54,15 +55,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("deviceCapabilityRequest"u8); writer.WriteObjectValue(DeviceCapabilityRequest, 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); } @@ -71,83 +72,89 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RegionConfigurationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + RegionConfigurationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RegionConfigurationContent 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(RegionConfigurationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeRegionConfigurationContent(document.RootElement, options); } - internal static RegionConfigurationContent DeserializeRegionConfigurationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RegionConfigurationContent DeserializeRegionConfigurationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ScheduleAvailabilityContent scheduleAvailabilityRequest = default; TransportAvailabilityContent transportAvailabilityRequest = default; - DataCenterAddressContent datacenterAddressRequest = default; + DataCenterAddressContent dataCenterAddressRequest = default; DeviceCapabilityContent deviceCapabilityRequest = 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("scheduleAvailabilityRequest"u8)) + if (prop.NameEquals("scheduleAvailabilityRequest"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - scheduleAvailabilityRequest = ScheduleAvailabilityContent.DeserializeScheduleAvailabilityContent(property.Value, options); + scheduleAvailabilityRequest = ScheduleAvailabilityContent.DeserializeScheduleAvailabilityContent(prop.Value, options); continue; } - if (property.NameEquals("transportAvailabilityRequest"u8)) + if (prop.NameEquals("transportAvailabilityRequest"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transportAvailabilityRequest = TransportAvailabilityContent.DeserializeTransportAvailabilityContent(property.Value, options); + transportAvailabilityRequest = TransportAvailabilityContent.DeserializeTransportAvailabilityContent(prop.Value, options); continue; } - if (property.NameEquals("datacenterAddressRequest"u8)) + if (prop.NameEquals("datacenterAddressRequest"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datacenterAddressRequest = DataCenterAddressContent.DeserializeDataCenterAddressContent(property.Value, options); + dataCenterAddressRequest = DataCenterAddressContent.DeserializeDataCenterAddressContent(prop.Value, options); continue; } - if (property.NameEquals("deviceCapabilityRequest"u8)) + if (prop.NameEquals("deviceCapabilityRequest"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceCapabilityRequest = DeviceCapabilityContent.DeserializeDeviceCapabilityContent(property.Value, options); + deviceCapabilityRequest = DeviceCapabilityContent.DeserializeDeviceCapabilityContent(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 RegionConfigurationContent(scheduleAvailabilityRequest, transportAvailabilityRequest, datacenterAddressRequest, deviceCapabilityRequest, serializedAdditionalRawData); + return new RegionConfigurationContent(scheduleAvailabilityRequest, transportAvailabilityRequest, dataCenterAddressRequest, deviceCapabilityRequest, 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": @@ -157,15 +164,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - RegionConfigurationContent 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. + RegionConfigurationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RegionConfigurationContent 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 DeserializeRegionConfigurationContent(document.RootElement, options); } default: @@ -173,6 +185,19 @@ RegionConfigurationContent IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(RegionConfigurationContent regionConfigurationContent) + { + if (regionConfigurationContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(regionConfigurationContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.cs index 0a1d4e187ecb..0245ca199a12 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationContent.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Request body to get the configuration for the region. public partial class RegionConfigurationContent { - /// - /// 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 RegionConfigurationContent() @@ -51,34 +22,29 @@ public RegionConfigurationContent() } /// Initializes a new instance of . - /// - /// Request body to get the availability for scheduling orders. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . - /// + /// Request body to get the availability for scheduling orders. /// Request body to get the transport availability for given sku. /// Request body to get the datacenter address for given sku. /// Request body to get the device capabilities for a given sku. - /// Keeps track of any properties unknown to the library. - internal RegionConfigurationContent(ScheduleAvailabilityContent scheduleAvailabilityRequest, TransportAvailabilityContent transportAvailabilityRequest, DataCenterAddressContent dataCenterAddressRequest, DeviceCapabilityContent deviceCapabilityRequest, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal RegionConfigurationContent(ScheduleAvailabilityContent scheduleAvailabilityRequest, TransportAvailabilityContent transportAvailabilityRequest, DataCenterAddressContent dataCenterAddressRequest, DeviceCapabilityContent deviceCapabilityRequest, IDictionary additionalBinaryDataProperties) { ScheduleAvailabilityRequest = scheduleAvailabilityRequest; TransportAvailabilityRequest = transportAvailabilityRequest; DataCenterAddressRequest = dataCenterAddressRequest; DeviceCapabilityRequest = deviceCapabilityRequest; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// - /// Request body to get the availability for scheduling orders. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . - /// + /// Request body to get the availability for scheduling orders. public ScheduleAvailabilityContent ScheduleAvailabilityRequest { get; set; } + /// Request body to get the transport availability for given sku. public TransportAvailabilityContent TransportAvailabilityRequest { get; set; } + /// Request body to get the datacenter address for given sku. public DataCenterAddressContent DataCenterAddressRequest { get; set; } + /// Request body to get the device capabilities for a given sku. public DeviceCapabilityContent DeviceCapabilityRequest { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.Serialization.cs index 414004212041..1ddb98015376 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.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.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class RegionConfigurationResult : IUtf8JsonSerializable, IJsonModel + /// Configuration response specific to a region. + public partial class RegionConfigurationResult : 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, ModelRea /// 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(RegionConfigurationResult)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ScheduleAvailabilityResponse)) { writer.WritePropertyName("scheduleAvailabilityResponse"u8); @@ -54,15 +55,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("deviceCapabilityResponse"u8); writer.WriteObjectValue(DeviceCapabilityResponse, 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); } @@ -71,83 +72,89 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RegionConfigurationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + RegionConfigurationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RegionConfigurationResult 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(RegionConfigurationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeRegionConfigurationResult(document.RootElement, options); } - internal static RegionConfigurationResult DeserializeRegionConfigurationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RegionConfigurationResult DeserializeRegionConfigurationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ScheduleAvailabilityResponse scheduleAvailabilityResponse = default; TransportAvailabilityResponse transportAvailabilityResponse = default; - DataCenterAddressResult datacenterAddressResponse = default; + DataCenterAddressResult dataCenterAddressResponse = default; DeviceCapabilityResponse deviceCapabilityResponse = 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("scheduleAvailabilityResponse"u8)) + if (prop.NameEquals("scheduleAvailabilityResponse"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - scheduleAvailabilityResponse = ScheduleAvailabilityResponse.DeserializeScheduleAvailabilityResponse(property.Value, options); + scheduleAvailabilityResponse = ScheduleAvailabilityResponse.DeserializeScheduleAvailabilityResponse(prop.Value, options); continue; } - if (property.NameEquals("transportAvailabilityResponse"u8)) + if (prop.NameEquals("transportAvailabilityResponse"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transportAvailabilityResponse = TransportAvailabilityResponse.DeserializeTransportAvailabilityResponse(property.Value, options); + transportAvailabilityResponse = TransportAvailabilityResponse.DeserializeTransportAvailabilityResponse(prop.Value, options); continue; } - if (property.NameEquals("datacenterAddressResponse"u8)) + if (prop.NameEquals("datacenterAddressResponse"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datacenterAddressResponse = DataCenterAddressResult.DeserializeDataCenterAddressResult(property.Value, options); + dataCenterAddressResponse = DataCenterAddressResult.DeserializeDataCenterAddressResult(prop.Value, options); continue; } - if (property.NameEquals("deviceCapabilityResponse"u8)) + if (prop.NameEquals("deviceCapabilityResponse"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceCapabilityResponse = DeviceCapabilityResponse.DeserializeDeviceCapabilityResponse(property.Value, options); + deviceCapabilityResponse = DeviceCapabilityResponse.DeserializeDeviceCapabilityResponse(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 RegionConfigurationResult(scheduleAvailabilityResponse, transportAvailabilityResponse, datacenterAddressResponse, deviceCapabilityResponse, serializedAdditionalRawData); + return new RegionConfigurationResult(scheduleAvailabilityResponse, transportAvailabilityResponse, dataCenterAddressResponse, deviceCapabilityResponse, 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": @@ -157,15 +164,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO } } - RegionConfigurationResult 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. + RegionConfigurationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RegionConfigurationResult 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 DeserializeRegionConfigurationResult(document.RootElement, options); } default: @@ -173,6 +185,14 @@ RegionConfigurationResult IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static RegionConfigurationResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRegionConfigurationResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.cs index 3eaffda864f2..b3e4f883dd35 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/RegionConfigurationResult.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Configuration response specific to a region. public partial class RegionConfigurationResult { - /// - /// 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 RegionConfigurationResult() @@ -53,50 +24,55 @@ internal RegionConfigurationResult() /// Initializes a new instance of . /// Schedule availability for given sku in a region. /// Transport options available for given sku in a region. - /// - /// Datacenter address for given sku in a region. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// + /// Datacenter address for given sku in a region. /// Device capabilities available for a given sku in a region. - /// Keeps track of any properties unknown to the library. - internal RegionConfigurationResult(ScheduleAvailabilityResponse scheduleAvailabilityResponse, TransportAvailabilityResponse transportAvailabilityResponse, DataCenterAddressResult dataCenterAddressResponse, DeviceCapabilityResponse deviceCapabilityResponse, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal RegionConfigurationResult(ScheduleAvailabilityResponse scheduleAvailabilityResponse, TransportAvailabilityResponse transportAvailabilityResponse, DataCenterAddressResult dataCenterAddressResponse, DeviceCapabilityResponse deviceCapabilityResponse, IDictionary additionalBinaryDataProperties) { ScheduleAvailabilityResponse = scheduleAvailabilityResponse; TransportAvailabilityResponse = transportAvailabilityResponse; DataCenterAddressResponse = dataCenterAddressResponse; DeviceCapabilityResponse = deviceCapabilityResponse; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Schedule availability for given sku in a region. internal ScheduleAvailabilityResponse ScheduleAvailabilityResponse { get; } + + /// Transport options available for given sku in a region. + internal TransportAvailabilityResponse TransportAvailabilityResponse { get; } + + /// Datacenter address for given sku in a region. + public DataCenterAddressResult DataCenterAddressResponse { get; } + + /// Device capabilities available for a given sku in a region. + internal DeviceCapabilityResponse DeviceCapabilityResponse { get; } + /// List of dates available to schedule. public IReadOnlyList ScheduleAvailabilityResponseAvailableDates { - get => ScheduleAvailabilityResponse?.AvailableDates; + get + { + return ScheduleAvailabilityResponse.AvailableDates; + } } - /// Transport options available for given sku in a region. - internal TransportAvailabilityResponse TransportAvailabilityResponse { get; } /// List of transport availability details for given region. public IReadOnlyList TransportAvailabilityDetails { - get => TransportAvailabilityResponse?.TransportAvailabilityDetails; + get + { + return TransportAvailabilityResponse.TransportAvailabilityDetails; + } } - /// - /// Datacenter address for given sku in a region. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// - public DataCenterAddressResult DataCenterAddressResponse { get; } - /// Device capabilities available for a given sku in a region. - internal DeviceCapabilityResponse DeviceCapabilityResponse { get; } /// List of device capabilities available for a given region and a given sku. public IReadOnlyList DeviceCapabilityDetails { - get => DeviceCapabilityResponse?.DeviceCapabilityDetails; + get + { + return DeviceCapabilityResponse.DeviceCapabilityDetails; + } } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ResourceIdentity.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ResourceIdentity.Serialization.cs new file mode 100644 index 000000000000..9666c4025ce6 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ResourceIdentity.Serialization.cs @@ -0,0 +1,203 @@ +// 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; +using System.Text.Json; +using Azure.ResourceManager.DataBox; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Msi identity details of the resource. + public partial class ResourceIdentity : 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(ResourceIdentity)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId); + } + if (Optional.IsCollectionDefined(UserAssignedIdentities)) + { + writer.WritePropertyName("userAssignedIdentities"u8); + writer.WriteStartObject(); + foreach (var item in UserAssignedIdentities) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + ((IJsonModel)item.Value).Write(writer, options); + } + writer.WriteEndObject(); + } + 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. + ResourceIdentity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceIdentity 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(ResourceIdentity)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceIdentity(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResourceIdentity DeserializeResourceIdentity(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + string principalId = default; + string tenantId = default; + IDictionary userAssignedIdentities = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("principalId"u8)) + { + principalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tenantId"u8)) + { + tenantId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("userAssignedIdentities"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default)); + } + } + userAssignedIdentities = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ResourceIdentity(@type, principalId, tenantId, userAssignedIdentities ?? new ChangeTrackingDictionary(), 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, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(ResourceIdentity)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResourceIdentity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceIdentity 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 DeserializeResourceIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceIdentity)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ResourceIdentity.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ResourceIdentity.cs new file mode 100644 index 000000000000..f8496021fdff --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ResourceIdentity.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.DataBox; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Msi identity details of the resource. + public partial class ResourceIdentity + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ResourceIdentity() + { + UserAssignedIdentities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Identity type. + /// Service Principal Id backing the Msi. + /// Home Tenant Id. + /// User Assigned Identities. + /// Keeps track of any properties unknown to the library. + internal ResourceIdentity(string @type, string principalId, string tenantId, IDictionary userAssignedIdentities, IDictionary additionalBinaryDataProperties) + { + Type = @type; + PrincipalId = principalId; + TenantId = tenantId; + UserAssignedIdentities = userAssignedIdentities; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Identity type. + public string Type { get; set; } + + /// Service Principal Id backing the Msi. + public string PrincipalId { get; } + + /// Home Tenant Id. + public string TenantId { get; } + + /// User Assigned Identities. + public IDictionary UserAssignedIdentities { get; } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.Serialization.cs index b78e929f5e1b..4f440cb0eb10 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ReverseShippingDetails : IUtf8JsonSerializable, IJsonModel + /// Reverse Shipping Address and contact details for a job. + public partial class ReverseShippingDetails : 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, ModelReader /// 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(ReverseShippingDetails)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ContactDetails)) { writer.WritePropertyName("contactDetails"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("isUpdated"u8); writer.WriteBooleanValue(IsUpdated.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 } } - ReverseShippingDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ReverseShippingDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ReverseShippingDetails 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(ReverseShippingDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeReverseShippingDetails(document.RootElement, options); } - internal static ReverseShippingDetails DeserializeReverseShippingDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ReverseShippingDetails DeserializeReverseShippingDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,50 +94,51 @@ internal static ReverseShippingDetails DeserializeReverseShippingDetails(JsonEle ContactInfo contactDetails = default; DataBoxShippingAddress shippingAddress = default; bool? isUpdated = 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("contactDetails"u8)) + if (prop.NameEquals("contactDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - contactDetails = ContactInfo.DeserializeContactInfo(property.Value, options); + contactDetails = ContactInfo.DeserializeContactInfo(prop.Value, options); continue; } - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("shippingAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("isUpdated"u8)) + if (prop.NameEquals("isUpdated"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isUpdated = property.Value.GetBoolean(); + isUpdated = prop.Value.GetBoolean(); 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 ReverseShippingDetails(contactDetails, shippingAddress, isUpdated, serializedAdditionalRawData); + return new ReverseShippingDetails(contactDetails, shippingAddress, isUpdated, 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": @@ -142,15 +148,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - ReverseShippingDetails 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. + ReverseShippingDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ReverseShippingDetails 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 DeserializeReverseShippingDetails(document.RootElement, options); } default: @@ -158,6 +169,7 @@ ReverseShippingDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.cs index 33c3ca3cca02..f90eb10ab9d1 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Reverse Shipping Address and contact details for a job. public partial class ReverseShippingDetails { - /// - /// 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 ReverseShippingDetails() @@ -57,19 +28,21 @@ public ReverseShippingDetails() /// A flag to indicate whether Reverse Shipping details are updated or not after device has been prepared. /// Read only field /// - /// Keeps track of any properties unknown to the library. - internal ReverseShippingDetails(ContactInfo contactDetails, DataBoxShippingAddress shippingAddress, bool? isUpdated, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ReverseShippingDetails(ContactInfo contactDetails, DataBoxShippingAddress shippingAddress, bool? isUpdated, IDictionary additionalBinaryDataProperties) { ContactDetails = contactDetails; ShippingAddress = shippingAddress; IsUpdated = isUpdated; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Contact Info. public ContactInfo ContactDetails { get; set; } + /// Shipping address where customer wishes to receive the device. public DataBoxShippingAddress ShippingAddress { get; set; } + /// /// A flag to indicate whether Reverse Shipping details are updated or not after device has been prepared. /// Read only field diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetailsEditStatus.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetailsEditStatus.Serialization.cs index ca88a957ab39..2201029e3fb1 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetailsEditStatus.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseShippingDetailsEditStatus.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class ReverseShippingDetailsEditStatusExtensions { + /// The value to serialize. public static string ToSerialString(this ReverseShippingDetailsEditStatus value) => value switch { ReverseShippingDetailsEditStatus.Enabled => "Enabled", @@ -19,11 +20,21 @@ internal static partial class ReverseShippingDetailsEditStatusExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ReverseShippingDetailsEditStatus value.") }; + /// The value to deserialize. public static ReverseShippingDetailsEditStatus ToReverseShippingDetailsEditStatus(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) return ReverseShippingDetailsEditStatus.Enabled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) return ReverseShippingDetailsEditStatus.Disabled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "NotSupported")) return ReverseShippingDetailsEditStatus.NotSupported; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) + { + return ReverseShippingDetailsEditStatus.Enabled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) + { + return ReverseShippingDetailsEditStatus.Disabled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "NotSupported")) + { + return ReverseShippingDetailsEditStatus.NotSupported; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ReverseShippingDetailsEditStatus value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseTransportPreferenceEditStatus.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseTransportPreferenceEditStatus.Serialization.cs index 111eef9202d2..a1d0523128b7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseTransportPreferenceEditStatus.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ReverseTransportPreferenceEditStatus.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class ReverseTransportPreferenceEditStatusExtensions { + /// The value to serialize. public static string ToSerialString(this ReverseTransportPreferenceEditStatus value) => value switch { ReverseTransportPreferenceEditStatus.Enabled => "Enabled", @@ -19,11 +20,21 @@ internal static partial class ReverseTransportPreferenceEditStatusExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ReverseTransportPreferenceEditStatus value.") }; + /// The value to deserialize. public static ReverseTransportPreferenceEditStatus ToReverseTransportPreferenceEditStatus(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) return ReverseTransportPreferenceEditStatus.Enabled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) return ReverseTransportPreferenceEditStatus.Disabled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "NotSupported")) return ReverseTransportPreferenceEditStatus.NotSupported; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Enabled")) + { + return ReverseTransportPreferenceEditStatus.Enabled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Disabled")) + { + return ReverseTransportPreferenceEditStatus.Disabled; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "NotSupported")) + { + return ReverseTransportPreferenceEditStatus.NotSupported; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ReverseTransportPreferenceEditStatus value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.Serialization.cs index 2cdf38a54203..06951531ccd4 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - [PersistableModelProxy(typeof(UnknownScheduleAvailabilityRequest))] - public partial class ScheduleAvailabilityContent : IUtf8JsonSerializable, IJsonModel + /// + /// Request body to get the availability for scheduling orders. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownScheduleAvailabilityContent))] + public abstract partial class ScheduleAvailabilityContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ScheduleAvailabilityContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +37,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(ScheduleAvailabilityContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("storageLocation"u8); writer.WriteStringValue(StorageLocation); writer.WritePropertyName("skuName"u8); @@ -48,15 +56,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("model"u8); writer.WriteStringValue(Model.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); } @@ -65,42 +73,53 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ScheduleAvailabilityContent 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(ScheduleAvailabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeScheduleAvailabilityContent(document.RootElement, options); } - internal static ScheduleAvailabilityContent DeserializeScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ScheduleAvailabilityContent DeserializeScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("skuName", out JsonElement discriminator)) + if (element.TryGetProperty("skuName"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "DataBox": return DataBoxScheduleAvailabilityContent.DeserializeDataBoxScheduleAvailabilityContent(element, options); - case "DataBoxDisk": return DiskScheduleAvailabilityContent.DeserializeDiskScheduleAvailabilityContent(element, options); - case "DataBoxHeavy": return HeavyScheduleAvailabilityContent.DeserializeHeavyScheduleAvailabilityContent(element, options); + case "DataBox": + return DataBoxScheduleAvailabilityContent.DeserializeDataBoxScheduleAvailabilityContent(element, options); + case "DataBoxDisk": + return DiskScheduleAvailabilityContent.DeserializeDiskScheduleAvailabilityContent(element, options); + case "DataBoxHeavy": + return HeavyScheduleAvailabilityContent.DeserializeHeavyScheduleAvailabilityContent(element, options); } } - return UnknownScheduleAvailabilityRequest.DeserializeUnknownScheduleAvailabilityRequest(element, options); + return UnknownScheduleAvailabilityContent.DeserializeUnknownScheduleAvailabilityContent(element, options); } - 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": @@ -110,15 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - ScheduleAvailabilityContent 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. + ScheduleAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ScheduleAvailabilityContent 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 DeserializeScheduleAvailabilityContent(document.RootElement, options); } default: @@ -126,6 +150,7 @@ ScheduleAvailabilityContent IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.cs index b20c404d6d43..7ac87529dcd9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityContent.cs @@ -13,48 +13,20 @@ namespace Azure.ResourceManager.DataBox.Models { /// /// Request body to get the availability for scheduling orders. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . /// public abstract partial class ScheduleAvailabilityContent { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. - protected ScheduleAvailabilityContent(AzureLocation storageLocation) + /// Sku Name for which the order is to be scheduled. + private protected ScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName) { StorageLocation = storageLocation; + SkuName = skuName; } /// Initializes a new instance of . @@ -62,27 +34,25 @@ protected ScheduleAvailabilityContent(AzureLocation storageLocation) /// Sku Name for which the order is to be scheduled. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal ScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary additionalBinaryDataProperties) { StorageLocation = storageLocation; SkuName = skuName; Country = country; Model = model; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ScheduleAvailabilityContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. public AzureLocation StorageLocation { get; } + /// Sku Name for which the order is to be scheduled. internal DataBoxSkuName SkuName { get; set; } + /// Country in which storage location should be supported. public string Country { get; set; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.Serialization.cs index b3c53b94dae6..f8d2cc78c16d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class ScheduleAvailabilityResponse : IUtf8JsonSerializable, IJsonModel + /// Schedule availability for given sku in a region. + internal partial class ScheduleAvailabilityResponse : 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 +29,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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(ScheduleAvailabilityResponse)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsCollectionDefined(AvailableDates)) { writer.WritePropertyName("availableDates"u8); writer.WriteStartArray(); - foreach (var item in AvailableDates) + foreach (DateTimeOffset item in AvailableDates) { writer.WriteStringValue(item, "O"); } 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 +61,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ScheduleAvailabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ScheduleAvailabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ScheduleAvailabilityResponse 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(ScheduleAvailabilityResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeScheduleAvailabilityResponse(document.RootElement, options); } - internal static ScheduleAvailabilityResponse DeserializeScheduleAvailabilityResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ScheduleAvailabilityResponse DeserializeScheduleAvailabilityResponse(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList availableDates = 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("availableDates"u8)) + if (prop.NameEquals("availableDates"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.GetDateTimeOffset("O")); } @@ -102,17 +106,19 @@ internal static ScheduleAvailabilityResponse DeserializeScheduleAvailabilityResp } 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 ScheduleAvailabilityResponse(availableDates ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new ScheduleAvailabilityResponse(availableDates ?? 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 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - ScheduleAvailabilityResponse 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. + ScheduleAvailabilityResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ScheduleAvailabilityResponse 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 DeserializeScheduleAvailabilityResponse(document.RootElement, options); } default: @@ -138,6 +149,7 @@ ScheduleAvailabilityResponse IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.cs index 7a15916276cf..2b126a148314 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ScheduleAvailabilityResponse.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Schedule availability for given sku in a region. internal partial class ScheduleAvailabilityResponse { - /// - /// 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 ScheduleAvailabilityResponse() @@ -53,11 +25,11 @@ internal ScheduleAvailabilityResponse() /// Initializes a new instance of . /// List of dates available to schedule. - /// Keeps track of any properties unknown to the library. - internal ScheduleAvailabilityResponse(IReadOnlyList availableDates, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ScheduleAvailabilityResponse(IReadOnlyList availableDates, IDictionary additionalBinaryDataProperties) { AvailableDates = availableDates; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// List of dates available to schedule. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.Serialization.cs index f99b5c623333..56129f496d8b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ShareCredentialDetails : IUtf8JsonSerializable, IJsonModel + /// Credential details of the shares in account. + public partial class ShareCredentialDetails : 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, ModelReader /// 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(ShareCredentialDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ShareName)) { writer.WritePropertyName("shareName"u8); @@ -58,21 +58,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("supportedAccessProtocols"u8); writer.WriteStartArray(); - foreach (var item in SupportedAccessProtocols) + foreach (DataBoxAccessProtocol item in SupportedAccessProtocols) { writer.WriteStringValue(item.ToSerialString()); } 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); } @@ -81,22 +81,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ShareCredentialDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ShareCredentialDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ShareCredentialDetails 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(ShareCredentialDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeShareCredentialDetails(document.RootElement, options); } - internal static ShareCredentialDetails DeserializeShareCredentialDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ShareCredentialDetails DeserializeShareCredentialDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -106,42 +111,41 @@ internal static ShareCredentialDetails DeserializeShareCredentialDetails(JsonEle string userName = default; string password = default; IReadOnlyList supportedAccessProtocols = 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("shareName"u8)) + if (prop.NameEquals("shareName"u8)) { - shareName = property.Value.GetString(); + shareName = prop.Value.GetString(); continue; } - if (property.NameEquals("shareType"u8)) + if (prop.NameEquals("shareType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shareType = property.Value.GetString().ToShareDestinationFormatType(); + shareType = prop.Value.GetString().ToShareDestinationFormatType(); continue; } - if (property.NameEquals("userName"u8)) + if (prop.NameEquals("userName"u8)) { - userName = property.Value.GetString(); + userName = prop.Value.GetString(); continue; } - if (property.NameEquals("password"u8)) + if (prop.NameEquals("password"u8)) { - password = property.Value.GetString(); + password = prop.Value.GetString(); continue; } - if (property.NameEquals("supportedAccessProtocols"u8)) + if (prop.NameEquals("supportedAccessProtocols"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().ToDataBoxAccessProtocol()); } @@ -150,23 +154,25 @@ internal static ShareCredentialDetails DeserializeShareCredentialDetails(JsonEle } 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 ShareCredentialDetails( shareName, shareType, userName, password, supportedAccessProtocols ?? new ChangeTrackingList(), - 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": @@ -176,15 +182,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - ShareCredentialDetails 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. + ShareCredentialDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ShareCredentialDetails 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 DeserializeShareCredentialDetails(document.RootElement, options); } default: @@ -192,6 +203,7 @@ ShareCredentialDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.cs index 1daec7a57641..68f4531e9b47 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareCredentialDetails.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Credential details of the shares in account. public partial class ShareCredentialDetails { - /// - /// 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 ShareCredentialDetails() @@ -57,25 +29,29 @@ internal ShareCredentialDetails() /// User name for the share. /// Password for the share. /// Access protocols supported on the device. - /// Keeps track of any properties unknown to the library. - internal ShareCredentialDetails(string shareName, ShareDestinationFormatType? shareType, string userName, string password, IReadOnlyList supportedAccessProtocols, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ShareCredentialDetails(string shareName, ShareDestinationFormatType? shareType, string userName, string password, IReadOnlyList supportedAccessProtocols, IDictionary additionalBinaryDataProperties) { ShareName = shareName; ShareType = shareType; UserName = userName; Password = password; SupportedAccessProtocols = supportedAccessProtocols; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the share. public string ShareName { get; } + /// Type of the share. public ShareDestinationFormatType? ShareType { get; } + /// User name for the share. public string UserName { get; } + /// Password for the share. public string Password { get; } + /// Access protocols supported on the device. public IReadOnlyList SupportedAccessProtocols { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareDestinationFormatType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareDestinationFormatType.Serialization.cs index b4d7724f074f..727a21510814 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareDestinationFormatType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShareDestinationFormatType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class ShareDestinationFormatTypeExtensions { + /// The value to serialize. public static string ToSerialString(this ShareDestinationFormatType value) => value switch { ShareDestinationFormatType.UnknownType => "UnknownType", @@ -22,14 +23,33 @@ internal static partial class ShareDestinationFormatTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ShareDestinationFormatType value.") }; + /// The value to deserialize. public static ShareDestinationFormatType ToShareDestinationFormatType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "UnknownType")) return ShareDestinationFormatType.UnknownType; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "HCS")) return ShareDestinationFormatType.Hcs; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "BlockBlob")) return ShareDestinationFormatType.BlockBlob; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "PageBlob")) return ShareDestinationFormatType.PageBlob; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureFile")) return ShareDestinationFormatType.AzureFile; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ManagedDisk")) return ShareDestinationFormatType.ManagedDisk; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "UnknownType")) + { + return ShareDestinationFormatType.UnknownType; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "HCS")) + { + return ShareDestinationFormatType.Hcs; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "BlockBlob")) + { + return ShareDestinationFormatType.BlockBlob; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "PageBlob")) + { + return ShareDestinationFormatType.PageBlob; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureFile")) + { + return ShareDestinationFormatType.AzureFile; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ManagedDisk")) + { + return ShareDestinationFormatType.ManagedDisk; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ShareDestinationFormatType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.Serialization.cs index 0633fd8170fa..2433a247203d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class ShipmentPickUpContent : IUtf8JsonSerializable, IJsonModel + /// Shipment pick up request details. + public partial class ShipmentPickUpContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ShipmentPickUpContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,27 +35,26 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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(ShipmentPickUpContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("startTime"u8); writer.WriteStringValue(StartOn, "O"); writer.WritePropertyName("endTime"u8); writer.WriteStringValue(EndOn, "O"); writer.WritePropertyName("shipmentLocation"u8); writer.WriteStringValue(ShipmentLocation); - 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); } @@ -57,61 +63,67 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ShipmentPickUpContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ShipmentPickUpContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ShipmentPickUpContent 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(ShipmentPickUpContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeShipmentPickUpContent(document.RootElement, options); } - internal static ShipmentPickUpContent DeserializeShipmentPickUpContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ShipmentPickUpContent DeserializeShipmentPickUpContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DateTimeOffset startTime = default; - DateTimeOffset endTime = default; + DateTimeOffset startOn = default; + DateTimeOffset endOn = default; string shipmentLocation = 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("startTime"u8)) + if (prop.NameEquals("startTime"u8)) { - startTime = property.Value.GetDateTimeOffset("O"); + startOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("endTime"u8)) + if (prop.NameEquals("endTime"u8)) { - endTime = property.Value.GetDateTimeOffset("O"); + endOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("shipmentLocation"u8)) + if (prop.NameEquals("shipmentLocation"u8)) { - shipmentLocation = property.Value.GetString(); + shipmentLocation = 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 ShipmentPickUpContent(startTime, endTime, shipmentLocation, serializedAdditionalRawData); + return new ShipmentPickUpContent(startOn, endOn, shipmentLocation, 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": @@ -121,15 +133,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - ShipmentPickUpContent 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. + ShipmentPickUpContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ShipmentPickUpContent 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 DeserializeShipmentPickUpContent(document.RootElement, options); } default: @@ -137,6 +154,19 @@ ShipmentPickUpContent IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ShipmentPickUpContent shipmentPickUpContent) + { + if (shipmentPickUpContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(shipmentPickUpContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.cs index a31226f9ee4c..8f00196bb4a2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ShipmentPickUpContent.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Shipment pick up request details. public partial class ShipmentPickUpContent { - /// - /// 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 . /// Minimum date after which the pick up should commence, this must be in local time of pick up area. @@ -63,24 +35,21 @@ public ShipmentPickUpContent(DateTimeOffset startOn, DateTimeOffset endOn, strin /// Minimum date after which the pick up should commence, this must be in local time of pick up area. /// Maximum date before which the pick up should commence, this must be in local time of pick up area. /// Shipment Location in the pickup place. Eg.front desk. - /// Keeps track of any properties unknown to the library. - internal ShipmentPickUpContent(DateTimeOffset startOn, DateTimeOffset endOn, string shipmentLocation, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ShipmentPickUpContent(DateTimeOffset startOn, DateTimeOffset endOn, string shipmentLocation, IDictionary additionalBinaryDataProperties) { StartOn = startOn; EndOn = endOn; ShipmentLocation = shipmentLocation; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ShipmentPickUpContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Minimum date after which the pick up should commence, this must be in local time of pick up area. public DateTimeOffset StartOn { get; } + /// Maximum date before which the pick up should commence, this must be in local time of pick up area. public DateTimeOffset EndOn { get; } + /// Shipment Location in the pickup place. Eg.front desk. public string ShipmentLocation { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.Serialization.cs index 94b0be8c7f88..722ead40cc00 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class SkuAvailabilityValidationContent : IUtf8JsonSerializable, IJsonModel + /// Request to validate sku availability. + public partial class SkuAvailabilityValidationContent : DataBoxValidationInputContent, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SkuAvailabilityValidationContent() + { + } + /// 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, M /// 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(SkuAvailabilityValidationContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("deviceType"u8); writer.WriteStringValue(DeviceType.ToSerialString()); @@ -50,79 +56,82 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - SkuAvailabilityValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SkuAvailabilityValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SkuAvailabilityValidationContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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(SkuAvailabilityValidationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSkuAvailabilityValidationContent(document.RootElement, options); } - internal static SkuAvailabilityValidationContent DeserializeSkuAvailabilityValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SkuAvailabilityValidationContent DeserializeSkuAvailabilityValidationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + DataBoxValidationInputDiscriminator validationType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); DataBoxSkuName deviceType = default; DataBoxJobTransferType transferType = default; string country = default; AzureLocation location = default; DeviceModelName? model = default; - DataBoxValidationInputDiscriminator validationType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("deviceType"u8)) + if (prop.NameEquals("validationType"u8)) { - deviceType = property.Value.GetString().ToDataBoxSkuName(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("transferType"u8)) + if (prop.NameEquals("deviceType"u8)) { - transferType = property.Value.GetString().ToDataBoxJobTransferType(); + deviceType = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("transferType"u8)) { - country = property.Value.GetString(); + transferType = prop.Value.GetString().ToDataBoxJobTransferType(); continue; } - if (property.NameEquals("location"u8)) + if (prop.NameEquals("country"u8)) { - location = new AzureLocation(property.Value.GetString()); + country = prop.Value.GetString(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("location"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - model = property.Value.GetString().ToDeviceModelName(); + location = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("model"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = prop.Value.GetString().ToDeviceModelName(); 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 SkuAvailabilityValidationContent( validationType, - serializedAdditionalRawData, + additionalBinaryDataProperties, deviceType, transferType, country, @@ -130,10 +139,13 @@ internal static SkuAvailabilityValidationContent DeserializeSkuAvailabilityValid model); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -143,15 +155,20 @@ BinaryData IPersistableModel.Write(ModelReader } } - SkuAvailabilityValidationContent 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. + SkuAvailabilityValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SkuAvailabilityValidationContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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 DeserializeSkuAvailabilityValidationContent(document.RootElement, options); } default: @@ -159,6 +176,7 @@ SkuAvailabilityValidationContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.cs index 034e4c382d69..19c8f597e6de 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationContent.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { @@ -20,7 +21,7 @@ public partial class SkuAvailabilityValidationContent : DataBoxValidationInputCo /// ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// is null. - public SkuAvailabilityValidationContent(DataBoxSkuName deviceType, DataBoxJobTransferType transferType, string country, AzureLocation location) + public SkuAvailabilityValidationContent(DataBoxSkuName deviceType, DataBoxJobTransferType transferType, string country, AzureLocation location) : base(DataBoxValidationInputDiscriminator.ValidateSkuAvailability) { Argument.AssertNotNull(country, nameof(country)); @@ -28,40 +29,37 @@ public SkuAvailabilityValidationContent(DataBoxSkuName deviceType, DataBoxJobTra TransferType = transferType; Country = country; Location = location; - ValidationType = DataBoxValidationInputDiscriminator.ValidateSkuAvailability; } /// Initializes a new instance of . /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Device type to be used for the job. /// Type of the transfer. /// ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements. /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - internal SkuAvailabilityValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData, DataBoxSkuName deviceType, DataBoxJobTransferType transferType, string country, AzureLocation location, DeviceModelName? model) : base(validationType, serializedAdditionalRawData) + internal SkuAvailabilityValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties, DataBoxSkuName deviceType, DataBoxJobTransferType transferType, string country, AzureLocation location, DeviceModelName? model) : base(validationType, additionalBinaryDataProperties) { DeviceType = deviceType; TransferType = transferType; Country = country; Location = location; Model = model; - ValidationType = validationType; - } - - /// Initializes a new instance of for deserialization. - internal SkuAvailabilityValidationContent() - { } /// Device type to be used for the job. public DataBoxSkuName DeviceType { get; } + /// Type of the transfer. public DataBoxJobTransferType TransferType { get; } + /// ISO country code. Country for hardware shipment. For codes check: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements. public string Country { get; } + /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. public AzureLocation Location { get; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.Serialization.cs index c0a951102fec..68e61c5ca34f 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class SkuAvailabilityValidationResult : IUtf8JsonSerializable, IJsonModel + /// Properties of sku availability validation response. + public partial class SkuAvailabilityValidationResult : DataBoxValidationInputResult, 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(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// 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(SkuAvailabilityValidationResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(Status)) { @@ -43,69 +44,75 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - SkuAvailabilityValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SkuAvailabilityValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SkuAvailabilityValidationResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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(SkuAvailabilityValidationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSkuAvailabilityValidationResult(document.RootElement, options); } - internal static SkuAvailabilityValidationResult DeserializeSkuAvailabilityValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SkuAvailabilityValidationResult DeserializeSkuAvailabilityValidationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DataBoxValidationStatus? status = default; DataBoxValidationInputDiscriminator validationType = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DataBoxValidationStatus? status = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("validationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = property.Value.GetString().ToDataBoxValidationStatus(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("error"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + status = prop.Value.GetString().ToDataBoxValidationStatus(); 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 SkuAvailabilityValidationResult(validationType, error, serializedAdditionalRawData, status); + return new SkuAvailabilityValidationResult(validationType, error, additionalBinaryDataProperties, status); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +122,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - SkuAvailabilityValidationResult 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. + SkuAvailabilityValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SkuAvailabilityValidationResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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 DeserializeSkuAvailabilityValidationResult(document.RootElement, options); } default: @@ -131,6 +143,7 @@ SkuAvailabilityValidationResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.cs index 5855077c5b79..630363d61545 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuAvailabilityValidationResult.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { @@ -14,20 +15,18 @@ namespace Azure.ResourceManager.DataBox.Models public partial class SkuAvailabilityValidationResult : DataBoxValidationInputResult { /// Initializes a new instance of . - internal SkuAvailabilityValidationResult() + internal SkuAvailabilityValidationResult() : base(DataBoxValidationInputDiscriminator.ValidateSkuAvailability) { - ValidationType = DataBoxValidationInputDiscriminator.ValidateSkuAvailability; } /// Initializes a new instance of . /// Identifies the type of validation response. /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Sku availability validation status. - internal SkuAvailabilityValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData, DataBoxValidationStatus? status) : base(validationType, error, serializedAdditionalRawData) + internal SkuAvailabilityValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties, DataBoxValidationStatus? status) : base(validationType, error, additionalBinaryDataProperties) { Status = status; - ValidationType = validationType; } /// Sku availability validation status. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuDisabledReason.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuDisabledReason.Serialization.cs index 6c9d2ffb92b4..315558a624cc 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuDisabledReason.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuDisabledReason.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class SkuDisabledReasonExtensions { + /// The value to serialize. public static string ToSerialString(this SkuDisabledReason value) => value switch { SkuDisabledReason.None => "None", @@ -22,14 +23,33 @@ internal static partial class SkuDisabledReasonExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown SkuDisabledReason value.") }; + /// The value to deserialize. public static SkuDisabledReason ToSkuDisabledReason(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) return SkuDisabledReason.None; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Country")) return SkuDisabledReason.Country; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Region")) return SkuDisabledReason.Region; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Feature")) return SkuDisabledReason.Feature; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "OfferType")) return SkuDisabledReason.OfferType; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "NoSubscriptionInfo")) return SkuDisabledReason.NoSubscriptionInfo; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "None")) + { + return SkuDisabledReason.None; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Country")) + { + return SkuDisabledReason.Country; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Region")) + { + return SkuDisabledReason.Region; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Feature")) + { + return SkuDisabledReason.Feature; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "OfferType")) + { + return SkuDisabledReason.OfferType; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "NoSubscriptionInfo")) + { + return SkuDisabledReason.NoSubscriptionInfo; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown SkuDisabledReason value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuProperties.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuProperties.Serialization.cs new file mode 100644 index 000000000000..5229605a3310 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuProperties.Serialization.cs @@ -0,0 +1,315 @@ +// 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.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Properties of the sku. + internal partial class SkuProperties : 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(SkuProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsCollectionDefined(DataLocationToServiceLocationMap)) + { + writer.WritePropertyName("dataLocationToServiceLocationMap"u8); + writer.WriteStartArray(); + foreach (DataLocationToServiceLocationMap item in DataLocationToServiceLocationMap) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(Capacity)) + { + writer.WritePropertyName("capacity"u8); + writer.WriteObjectValue(Capacity, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Costs)) + { + writer.WritePropertyName("costs"u8); + writer.WriteStartArray(); + foreach (DataBoxSkuCost item in Costs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ApiVersions)) + { + writer.WritePropertyName("apiVersions"u8); + writer.WriteStartArray(); + foreach (string item in ApiVersions) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(DisabledReason)) + { + writer.WritePropertyName("disabledReason"u8); + writer.WriteStringValue(DisabledReason.Value.ToSerialString()); + } + if (options.Format != "W" && Optional.IsDefined(DisabledReasonMessage)) + { + writer.WritePropertyName("disabledReasonMessage"u8); + writer.WriteStringValue(DisabledReasonMessage); + } + if (options.Format != "W" && Optional.IsDefined(RequiredFeature)) + { + writer.WritePropertyName("requiredFeature"u8); + writer.WriteStringValue(RequiredFeature); + } + if (options.Format != "W" && Optional.IsCollectionDefined(CountriesWithinCommerceBoundary)) + { + writer.WritePropertyName("countriesWithinCommerceBoundary"u8); + writer.WriteStartArray(); + foreach (string item in CountriesWithinCommerceBoundary) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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. + SkuProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SkuProperties 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(SkuProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSkuProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SkuProperties DeserializeSkuProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList dataLocationToServiceLocationMap = default; + DataBoxSkuCapacity capacity = default; + IReadOnlyList costs = default; + IReadOnlyList apiVersions = default; + SkuDisabledReason? disabledReason = default; + string disabledReasonMessage = default; + string requiredFeature = default; + IReadOnlyList countriesWithinCommerceBoundary = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("dataLocationToServiceLocationMap"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(Models.DataLocationToServiceLocationMap.DeserializeDataLocationToServiceLocationMap(item, options)); + } + dataLocationToServiceLocationMap = array; + continue; + } + if (prop.NameEquals("capacity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacity = DataBoxSkuCapacity.DeserializeDataBoxSkuCapacity(prop.Value, options); + continue; + } + if (prop.NameEquals("costs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxSkuCost.DeserializeDataBoxSkuCost(item, options)); + } + costs = array; + continue; + } + if (prop.NameEquals("apiVersions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + apiVersions = array; + continue; + } + if (prop.NameEquals("disabledReason"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + disabledReason = prop.Value.GetString().ToSkuDisabledReason(); + continue; + } + if (prop.NameEquals("disabledReasonMessage"u8)) + { + disabledReasonMessage = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("requiredFeature"u8)) + { + requiredFeature = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("countriesWithinCommerceBoundary"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + countriesWithinCommerceBoundary = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SkuProperties( + dataLocationToServiceLocationMap ?? new ChangeTrackingList(), + capacity, + costs ?? new ChangeTrackingList(), + apiVersions ?? new ChangeTrackingList(), + disabledReason, + disabledReasonMessage, + requiredFeature, + countriesWithinCommerceBoundary ?? new ChangeTrackingList(), + 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, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(SkuProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SkuProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SkuProperties 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 DeserializeSkuProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SkuProperties)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuProperties.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuProperties.cs new file mode 100644 index 000000000000..43e66232d669 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SkuProperties.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Properties of the sku. + internal partial class SkuProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal SkuProperties() + { + DataLocationToServiceLocationMap = new ChangeTrackingList(); + Costs = new ChangeTrackingList(); + ApiVersions = new ChangeTrackingList(); + CountriesWithinCommerceBoundary = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The map of data location to service location. + /// Capacity of the Sku. + /// Cost of the Sku. + /// Api versions that support this Sku. + /// Reason why the Sku is disabled. + /// Message for why the Sku is disabled. + /// Required feature to access the sku. + /// List of all the Countries in the SKU specific commerce boundary. + /// Keeps track of any properties unknown to the library. + internal SkuProperties(IReadOnlyList dataLocationToServiceLocationMap, DataBoxSkuCapacity capacity, IReadOnlyList costs, IReadOnlyList apiVersions, SkuDisabledReason? disabledReason, string disabledReasonMessage, string requiredFeature, IReadOnlyList countriesWithinCommerceBoundary, IDictionary additionalBinaryDataProperties) + { + DataLocationToServiceLocationMap = dataLocationToServiceLocationMap; + Capacity = capacity; + Costs = costs; + ApiVersions = apiVersions; + DisabledReason = disabledReason; + DisabledReasonMessage = disabledReasonMessage; + RequiredFeature = requiredFeature; + CountriesWithinCommerceBoundary = countriesWithinCommerceBoundary; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The map of data location to service location. + public IReadOnlyList DataLocationToServiceLocationMap { get; } = new ChangeTrackingList(); + + /// Capacity of the Sku. + public DataBoxSkuCapacity Capacity { get; } + + /// Cost of the Sku. + public IReadOnlyList Costs { get; } = new ChangeTrackingList(); + + /// Api versions that support this Sku. + public IReadOnlyList ApiVersions { get; } = new ChangeTrackingList(); + + /// Reason why the Sku is disabled. + public SkuDisabledReason? DisabledReason { get; } + + /// Message for why the Sku is disabled. + public string DisabledReasonMessage { get; } + + /// Required feature to access the sku. + public string RequiredFeature { get; } + + /// List of all the Countries in the SKU specific commerce boundary. + public IReadOnlyList CountriesWithinCommerceBoundary { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.Serialization.cs index f8d09451bfce..84b30231b520 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class SubscriptionIsAllowedToCreateJobValidationContent : IUtf8JsonSerializable, IJsonModel + /// Request to validate subscription permission to create jobs. + public partial class SubscriptionIsAllowedToCreateJobValidationContent : DataBoxValidationInputContent, 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,58 +29,63 @@ 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(SubscriptionIsAllowedToCreateJobValidationContent)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - SubscriptionIsAllowedToCreateJobValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SubscriptionIsAllowedToCreateJobValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SubscriptionIsAllowedToCreateJobValidationContent)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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(SubscriptionIsAllowedToCreateJobValidationContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSubscriptionIsAllowedToCreateJobValidationContent(document.RootElement, options); } - internal static SubscriptionIsAllowedToCreateJobValidationContent DeserializeSubscriptionIsAllowedToCreateJobValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SubscriptionIsAllowedToCreateJobValidationContent DeserializeSubscriptionIsAllowedToCreateJobValidationContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxValidationInputDiscriminator validationType = 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("validationType"u8)) + if (prop.NameEquals("validationType"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); 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 SubscriptionIsAllowedToCreateJobValidationContent(validationType, serializedAdditionalRawData); + return new SubscriptionIsAllowedToCreateJobValidationContent(validationType, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +95,20 @@ BinaryData IPersistableModel. } } - SubscriptionIsAllowedToCreateJobValidationContent 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. + SubscriptionIsAllowedToCreateJobValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SubscriptionIsAllowedToCreateJobValidationContent)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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 DeserializeSubscriptionIsAllowedToCreateJobValidationContent(document.RootElement, options); } default: @@ -105,6 +116,7 @@ SubscriptionIsAllowedToCreateJobValidationContent IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.cs index b62832ec19c1..2047058bcc3a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationContent.cs @@ -14,17 +14,15 @@ namespace Azure.ResourceManager.DataBox.Models public partial class SubscriptionIsAllowedToCreateJobValidationContent : DataBoxValidationInputContent { /// Initializes a new instance of . - public SubscriptionIsAllowedToCreateJobValidationContent() + public SubscriptionIsAllowedToCreateJobValidationContent() : base(DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob) { - ValidationType = DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob; } /// Initializes a new instance of . /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. - internal SubscriptionIsAllowedToCreateJobValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData) : base(validationType, serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SubscriptionIsAllowedToCreateJobValidationContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties) : base(validationType, additionalBinaryDataProperties) { - ValidationType = validationType; } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.Serialization.cs index 731a5597a33a..be64f2e85fe9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class SubscriptionIsAllowedToCreateJobValidationResult : IUtf8JsonSerializable, IJsonModel + /// Properties of subscription permission to create job validation response. + public partial class SubscriptionIsAllowedToCreateJobValidationResult : DataBoxValidationInputResult, 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(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8Json /// 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(SubscriptionIsAllowedToCreateJobValidationResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(Status)) { @@ -43,69 +44,75 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - SubscriptionIsAllowedToCreateJobValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SubscriptionIsAllowedToCreateJobValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SubscriptionIsAllowedToCreateJobValidationResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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(SubscriptionIsAllowedToCreateJobValidationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSubscriptionIsAllowedToCreateJobValidationResult(document.RootElement, options); } - internal static SubscriptionIsAllowedToCreateJobValidationResult DeserializeSubscriptionIsAllowedToCreateJobValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SubscriptionIsAllowedToCreateJobValidationResult DeserializeSubscriptionIsAllowedToCreateJobValidationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DataBoxValidationStatus? status = default; DataBoxValidationInputDiscriminator validationType = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + DataBoxValidationStatus? status = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("status"u8)) + if (prop.NameEquals("validationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - status = property.Value.GetString().ToDataBoxValidationStatus(); + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); continue; } - if (property.NameEquals("validationType"u8)) + if (prop.NameEquals("error"u8)) { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + status = prop.Value.GetString().ToDataBoxValidationStatus(); 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 SubscriptionIsAllowedToCreateJobValidationResult(validationType, error, serializedAdditionalRawData, status); + return new SubscriptionIsAllowedToCreateJobValidationResult(validationType, error, additionalBinaryDataProperties, status); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -115,15 +122,20 @@ BinaryData IPersistableModel.W } } - SubscriptionIsAllowedToCreateJobValidationResult 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. + SubscriptionIsAllowedToCreateJobValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SubscriptionIsAllowedToCreateJobValidationResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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 DeserializeSubscriptionIsAllowedToCreateJobValidationResult(document.RootElement, options); } default: @@ -131,6 +143,7 @@ SubscriptionIsAllowedToCreateJobValidationResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.cs index 1b66e731b003..19ff452beb1d 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/SubscriptionIsAllowedToCreateJobValidationResult.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { @@ -14,20 +15,18 @@ namespace Azure.ResourceManager.DataBox.Models public partial class SubscriptionIsAllowedToCreateJobValidationResult : DataBoxValidationInputResult { /// Initializes a new instance of . - internal SubscriptionIsAllowedToCreateJobValidationResult() + internal SubscriptionIsAllowedToCreateJobValidationResult() : base(DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob) { - ValidationType = DataBoxValidationInputDiscriminator.ValidateSubscriptionIsAllowedToCreateJob; } /// Initializes a new instance of . /// Identifies the type of validation response. /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Validation status of subscription permission to create job. - internal SubscriptionIsAllowedToCreateJobValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData, DataBoxValidationStatus? status) : base(validationType, error, serializedAdditionalRawData) + internal SubscriptionIsAllowedToCreateJobValidationResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties, DataBoxValidationStatus? status) : base(validationType, error, additionalBinaryDataProperties) { Status = status; - ValidationType = validationType; } /// Validation status of subscription permission to create job. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.Serialization.cs index 5f33d0ffd4df..53e03b28263b 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class TransferAllDetails : IUtf8JsonSerializable, IJsonModel + /// Details to transfer all data. + public partial class TransferAllDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TransferAllDetails() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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(TransferAllDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("dataAccountType"u8); writer.WriteStringValue(DataAccountType.ToSerialString()); if (Optional.IsDefined(TransferAllBlobs)) @@ -46,15 +51,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("transferAllFiles"u8); writer.WriteBooleanValue(TransferAllFiles.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); } @@ -63,22 +68,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransferAllDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransferAllDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransferAllDetails 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(TransferAllDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransferAllDetails(document.RootElement, options); } - internal static TransferAllDetails DeserializeTransferAllDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransferAllDetails DeserializeTransferAllDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -86,46 +96,47 @@ internal static TransferAllDetails DeserializeTransferAllDetails(JsonElement ele DataAccountType dataAccountType = default; bool? transferAllBlobs = default; bool? transferAllFiles = 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("dataAccountType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - dataAccountType = property.Value.GetString().ToDataAccountType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("transferAllBlobs"u8)) + if (prop.NameEquals("transferAllBlobs"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferAllBlobs = property.Value.GetBoolean(); + transferAllBlobs = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("transferAllFiles"u8)) + if (prop.NameEquals("transferAllFiles"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferAllFiles = property.Value.GetBoolean(); + transferAllFiles = prop.Value.GetBoolean(); 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 TransferAllDetails(dataAccountType, transferAllBlobs, transferAllFiles, serializedAdditionalRawData); + return new TransferAllDetails(dataAccountType, transferAllBlobs, transferAllFiles, 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 +146,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - TransferAllDetails 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. + TransferAllDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransferAllDetails 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 DeserializeTransferAllDetails(document.RootElement, options); } default: @@ -151,6 +167,7 @@ TransferAllDetails IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.cs index c5ec4beea043..94fde75299bd 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferAllDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Details to transfer all data. public partial class TransferAllDetails { - /// - /// 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 . /// Type of the account of data. @@ -56,24 +27,21 @@ public TransferAllDetails(DataAccountType dataAccountType) /// Type of the account of data. /// To indicate if all Azure blobs have to be transferred. /// To indicate if all Azure Files have to be transferred. - /// Keeps track of any properties unknown to the library. - internal TransferAllDetails(DataAccountType dataAccountType, bool? transferAllBlobs, bool? transferAllFiles, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransferAllDetails(DataAccountType dataAccountType, bool? transferAllBlobs, bool? transferAllFiles, IDictionary additionalBinaryDataProperties) { DataAccountType = dataAccountType; TransferAllBlobs = transferAllBlobs; TransferAllFiles = transferAllFiles; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TransferAllDetails() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of the account of data. public DataAccountType DataAccountType { get; set; } + /// To indicate if all Azure blobs have to be transferred. public bool? TransferAllBlobs { get; set; } + /// To indicate if all Azure Files have to be transferred. public bool? TransferAllFiles { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.Serialization.cs index 2eb6c48e45ff..cfca34a51da7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class TransferConfiguration : IUtf8JsonSerializable, IJsonModel + /// Configuration for defining the transfer of data. + public partial class TransferConfiguration : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TransferConfiguration() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderW /// 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(TransferConfiguration)} does not support writing '{format}' format."); } - writer.WritePropertyName("transferConfigurationType"u8); writer.WriteStringValue(TransferConfigurationType.ToSerialString()); if (Optional.IsDefined(TransferFilterDetails)) @@ -46,15 +51,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("transferAllDetails"u8); writer.WriteObjectValue(TransferAllDetails, 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); } @@ -63,22 +68,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransferConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransferConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransferConfiguration 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(TransferConfiguration)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransferConfiguration(document.RootElement, options); } - internal static TransferConfiguration DeserializeTransferConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransferConfiguration DeserializeTransferConfiguration(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -86,46 +96,47 @@ internal static TransferConfiguration DeserializeTransferConfiguration(JsonEleme TransferConfigurationType transferConfigurationType = default; TransferConfigurationTransferFilterDetails transferFilterDetails = default; TransferConfigurationTransferAllDetails transferAllDetails = 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("transferConfigurationType"u8)) + if (prop.NameEquals("transferConfigurationType"u8)) { - transferConfigurationType = property.Value.GetString().ToTransferConfigurationType(); + transferConfigurationType = prop.Value.GetString().ToTransferConfigurationType(); continue; } - if (property.NameEquals("transferFilterDetails"u8)) + if (prop.NameEquals("transferFilterDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferFilterDetails = TransferConfigurationTransferFilterDetails.DeserializeTransferConfigurationTransferFilterDetails(property.Value, options); + transferFilterDetails = TransferConfigurationTransferFilterDetails.DeserializeTransferConfigurationTransferFilterDetails(prop.Value, options); continue; } - if (property.NameEquals("transferAllDetails"u8)) + if (prop.NameEquals("transferAllDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - transferAllDetails = TransferConfigurationTransferAllDetails.DeserializeTransferConfigurationTransferAllDetails(property.Value, options); + transferAllDetails = TransferConfigurationTransferAllDetails.DeserializeTransferConfigurationTransferAllDetails(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 TransferConfiguration(transferConfigurationType, transferFilterDetails, transferAllDetails, serializedAdditionalRawData); + return new TransferConfiguration(transferConfigurationType, transferFilterDetails, transferAllDetails, 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 +146,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - TransferConfiguration 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. + TransferConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransferConfiguration 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 DeserializeTransferConfiguration(document.RootElement, options); } default: @@ -151,6 +167,7 @@ TransferConfiguration IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.cs index 93b5ecbe746f..ae432d5fcb08 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfiguration.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Configuration for defining the transfer of data. public partial class TransferConfiguration { - /// - /// 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 . /// Type of the configuration for transfer. @@ -56,46 +27,54 @@ public TransferConfiguration(TransferConfigurationType transferConfigurationType /// Type of the configuration for transfer. /// Map of filter type and the details to filter. This field is required only if the TransferConfigurationType is given as TransferUsingFilter. /// Map of filter type and the details to transfer all data. This field is required only if the TransferConfigurationType is given as TransferAll. - /// Keeps track of any properties unknown to the library. - internal TransferConfiguration(TransferConfigurationType transferConfigurationType, TransferConfigurationTransferFilterDetails transferFilterDetails, TransferConfigurationTransferAllDetails transferAllDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransferConfiguration(TransferConfigurationType transferConfigurationType, TransferConfigurationTransferFilterDetails transferFilterDetails, TransferConfigurationTransferAllDetails transferAllDetails, IDictionary additionalBinaryDataProperties) { TransferConfigurationType = transferConfigurationType; TransferFilterDetails = transferFilterDetails; TransferAllDetails = transferAllDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TransferConfiguration() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of the configuration for transfer. public TransferConfigurationType TransferConfigurationType { get; set; } + /// Map of filter type and the details to filter. This field is required only if the TransferConfigurationType is given as TransferUsingFilter. internal TransferConfigurationTransferFilterDetails TransferFilterDetails { get; set; } + + /// Map of filter type and the details to transfer all data. This field is required only if the TransferConfigurationType is given as TransferAll. + internal TransferConfigurationTransferAllDetails TransferAllDetails { get; set; } + /// Details of the filtering the transfer of data. public TransferFilterDetails TransferFilterDetailsInclude { - get => TransferFilterDetails is null ? default : TransferFilterDetails.Include; + get + { + return TransferFilterDetails is null ? default : TransferFilterDetails.Include; + } set { if (TransferFilterDetails is null) + { TransferFilterDetails = new TransferConfigurationTransferFilterDetails(); + } TransferFilterDetails.Include = value; } } - /// Map of filter type and the details to transfer all data. This field is required only if the TransferConfigurationType is given as TransferAll. - internal TransferConfigurationTransferAllDetails TransferAllDetails { get; set; } /// Details to transfer all data. public TransferAllDetails TransferAllDetailsInclude { - get => TransferAllDetails is null ? default : TransferAllDetails.Include; + get + { + return TransferAllDetails is null ? default : TransferAllDetails.Include; + } set { if (TransferAllDetails is null) + { TransferAllDetails = new TransferConfigurationTransferAllDetails(); + } TransferAllDetails.Include = value; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.Serialization.cs index 008267a3ff7a..e27b3c69b603 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class TransferConfigurationTransferAllDetails : IUtf8JsonSerializable, IJsonModel + /// Map of filter type and the details to transfer all data. This field is required only if the TransferConfigurationType is given as TransferAll. + internal partial class TransferConfigurationTransferAllDetails : 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(TransferConfigurationTransferAllDetails)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Include)) { writer.WritePropertyName("include"u8); writer.WriteObjectValue(Include, 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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransferConfigurationTransferAllDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransferConfigurationTransferAllDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransferConfigurationTransferAllDetails 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(TransferConfigurationTransferAllDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransferConfigurationTransferAllDetails(document.RootElement, options); } - internal static TransferConfigurationTransferAllDetails DeserializeTransferConfigurationTransferAllDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransferConfigurationTransferAllDetails DeserializeTransferConfigurationTransferAllDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } TransferAllDetails include = 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("include"u8)) + if (prop.NameEquals("include"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - include = TransferAllDetails.DeserializeTransferAllDetails(property.Value, options); + include = TransferAllDetails.DeserializeTransferAllDetails(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 TransferConfigurationTransferAllDetails(include, serializedAdditionalRawData); + return new TransferConfigurationTransferAllDetails(include, 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 } } - TransferConfigurationTransferAllDetails 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. + TransferConfigurationTransferAllDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransferConfigurationTransferAllDetails 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 DeserializeTransferConfigurationTransferAllDetails(document.RootElement, options); } default: @@ -128,6 +139,7 @@ TransferConfigurationTransferAllDetails IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.cs index 8a371c85b811..db086afb74cd 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferAllDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Map of filter type and the details to transfer all data. This field is required only if the TransferConfigurationType is given as TransferAll. internal partial class TransferConfigurationTransferAllDetails { - /// - /// 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 TransferConfigurationTransferAllDetails() @@ -52,11 +23,11 @@ public TransferConfigurationTransferAllDetails() /// Initializes a new instance of . /// Details to transfer all data. - /// Keeps track of any properties unknown to the library. - internal TransferConfigurationTransferAllDetails(TransferAllDetails include, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransferConfigurationTransferAllDetails(TransferAllDetails include, IDictionary additionalBinaryDataProperties) { Include = include; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Details to transfer all data. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.Serialization.cs index c8df71ab67b6..e0a1afad6abe 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class TransferConfigurationTransferFilterDetails : IUtf8JsonSerializable, IJsonModel + /// Map of filter type and the details to filter. This field is required only if the TransferConfigurationType is given as TransferUsingFilter. + internal partial class TransferConfigurationTransferFilterDetails : 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 /// 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(TransferConfigurationTransferFilterDetails)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Include)) { writer.WritePropertyName("include"u8); writer.WriteObjectValue(Include, 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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransferConfigurationTransferFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransferConfigurationTransferFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransferConfigurationTransferFilterDetails 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(TransferConfigurationTransferFilterDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransferConfigurationTransferFilterDetails(document.RootElement, options); } - internal static TransferConfigurationTransferFilterDetails DeserializeTransferConfigurationTransferFilterDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransferConfigurationTransferFilterDetails DeserializeTransferConfigurationTransferFilterDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } TransferFilterDetails include = 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("include"u8)) + if (prop.NameEquals("include"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - include = TransferFilterDetails.DeserializeTransferFilterDetails(property.Value, options); + include = TransferFilterDetails.DeserializeTransferFilterDetails(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 TransferConfigurationTransferFilterDetails(include, serializedAdditionalRawData); + return new TransferConfigurationTransferFilterDetails(include, 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(M } } - TransferConfigurationTransferFilterDetails 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. + TransferConfigurationTransferFilterDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransferConfigurationTransferFilterDetails 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 DeserializeTransferConfigurationTransferFilterDetails(document.RootElement, options); } default: @@ -128,6 +139,7 @@ TransferConfigurationTransferFilterDetails IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.cs index fe9ef7812a0b..bf4464c793cb 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationTransferFilterDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Map of filter type and the details to filter. This field is required only if the TransferConfigurationType is given as TransferUsingFilter. internal partial class TransferConfigurationTransferFilterDetails { - /// - /// 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 TransferConfigurationTransferFilterDetails() @@ -52,11 +23,11 @@ public TransferConfigurationTransferFilterDetails() /// Initializes a new instance of . /// Details of the filtering the transfer of data. - /// Keeps track of any properties unknown to the library. - internal TransferConfigurationTransferFilterDetails(TransferFilterDetails include, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransferConfigurationTransferFilterDetails(TransferFilterDetails include, IDictionary additionalBinaryDataProperties) { Include = include; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Details of the filtering the transfer of data. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationType.Serialization.cs index 52cf23a6f83f..2ecef19f3521 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferConfigurationType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class TransferConfigurationTypeExtensions { + /// The value to serialize. public static string ToSerialString(this TransferConfigurationType value) => value switch { TransferConfigurationType.TransferAll => "TransferAll", @@ -18,10 +19,17 @@ internal static partial class TransferConfigurationTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TransferConfigurationType value.") }; + /// The value to deserialize. public static TransferConfigurationType ToTransferConfigurationType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "TransferAll")) return TransferConfigurationType.TransferAll; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "TransferUsingFilter")) return TransferConfigurationType.TransferUsingFilter; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "TransferAll")) + { + return TransferConfigurationType.TransferAll; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "TransferUsingFilter")) + { + return TransferConfigurationType.TransferUsingFilter; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TransferConfigurationType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.Serialization.cs index 76dd47b92ddc..4e2cc849fd2e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class TransferFilterDetails : IUtf8JsonSerializable, IJsonModel + /// Details of the filtering the transfer of data. + public partial class TransferFilterDetails : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TransferFilterDetails() + { + } + /// 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.Write(Utf8JsonWriter writer, ModelReaderW /// 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(TransferFilterDetails)} does not support writing '{format}' format."); } - writer.WritePropertyName("dataAccountType"u8); writer.WriteStringValue(DataAccountType.ToSerialString()); if (Optional.IsDefined(BlobFilterDetails)) @@ -50,21 +55,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("filterFileDetails"u8); writer.WriteStartArray(); - foreach (var item in FilterFileDetails) + foreach (FilterFileDetails item in FilterFileDetails) { 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); } @@ -73,22 +78,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransferFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransferFilterDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransferFilterDetails 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(TransferFilterDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransferFilterDetails(document.RootElement, options); } - internal static TransferFilterDetails DeserializeTransferFilterDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransferFilterDetails DeserializeTransferFilterDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -97,41 +107,40 @@ internal static TransferFilterDetails DeserializeTransferFilterDetails(JsonEleme BlobFilterDetails blobFilterDetails = default; AzureFileFilterDetails azureFileFilterDetails = default; IList filterFileDetails = 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("dataAccountType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - dataAccountType = property.Value.GetString().ToDataAccountType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("blobFilterDetails"u8)) + if (prop.NameEquals("blobFilterDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - blobFilterDetails = BlobFilterDetails.DeserializeBlobFilterDetails(property.Value, options); + blobFilterDetails = BlobFilterDetails.DeserializeBlobFilterDetails(prop.Value, options); continue; } - if (property.NameEquals("azureFileFilterDetails"u8)) + if (prop.NameEquals("azureFileFilterDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - azureFileFilterDetails = AzureFileFilterDetails.DeserializeAzureFileFilterDetails(property.Value, options); + azureFileFilterDetails = AzureFileFilterDetails.DeserializeAzureFileFilterDetails(prop.Value, options); continue; } - if (property.NameEquals("filterFileDetails"u8)) + if (prop.NameEquals("filterFileDetails"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(Models.FilterFileDetails.DeserializeFilterFileDetails(item, options)); } @@ -140,17 +149,19 @@ internal static TransferFilterDetails DeserializeTransferFilterDetails(JsonEleme } 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 TransferFilterDetails(dataAccountType, blobFilterDetails, azureFileFilterDetails, filterFileDetails ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new TransferFilterDetails(dataAccountType, blobFilterDetails, azureFileFilterDetails, filterFileDetails ?? 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": @@ -160,15 +171,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - TransferFilterDetails 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. + TransferFilterDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransferFilterDetails 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 DeserializeTransferFilterDetails(document.RootElement, options); } default: @@ -176,6 +192,7 @@ TransferFilterDetails IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.cs index 047f263dc7b6..f4078102ed75 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransferFilterDetails.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Details of the filtering the transfer of data. public partial class TransferFilterDetails { - /// - /// 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 . /// Type of the account of data. @@ -58,27 +30,25 @@ public TransferFilterDetails(DataAccountType dataAccountType) /// Filter details to transfer blobs. /// Filter details to transfer Azure files. /// Details of the filter files to be used for data transfer. - /// Keeps track of any properties unknown to the library. - internal TransferFilterDetails(DataAccountType dataAccountType, BlobFilterDetails blobFilterDetails, AzureFileFilterDetails azureFileFilterDetails, IList filterFileDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransferFilterDetails(DataAccountType dataAccountType, BlobFilterDetails blobFilterDetails, AzureFileFilterDetails azureFileFilterDetails, IList filterFileDetails, IDictionary additionalBinaryDataProperties) { DataAccountType = dataAccountType; BlobFilterDetails = blobFilterDetails; AzureFileFilterDetails = azureFileFilterDetails; FilterFileDetails = filterFileDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TransferFilterDetails() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of the account of data. public DataAccountType DataAccountType { get; set; } + /// Filter details to transfer blobs. public BlobFilterDetails BlobFilterDetails { get; set; } + /// Filter details to transfer Azure files. public AzureFileFilterDetails AzureFileFilterDetails { get; set; } + /// Details of the filter files to be used for data transfer. public IList FilterFileDetails { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.Serialization.cs index d246101e17c3..2ebb60d3c115 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class TransportAvailabilityContent : IUtf8JsonSerializable, IJsonModel + /// Request body to get the transport availability for given sku. + public partial class TransportAvailabilityContent : 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, Model /// 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(TransportAvailabilityContent)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SkuName)) { writer.WritePropertyName("skuName"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("model"u8); writer.WriteStringValue(Model.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); } @@ -61,63 +61,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransportAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransportAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransportAvailabilityContent 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(TransportAvailabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransportAvailabilityContent(document.RootElement, options); } - internal static TransportAvailabilityContent DeserializeTransportAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransportAvailabilityContent DeserializeTransportAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxSkuName? skuName = default; DeviceModelName? model = 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("skuName"u8)) + if (prop.NameEquals("skuName"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - skuName = property.Value.GetString().ToDataBoxSkuName(); + skuName = prop.Value.GetString().ToDataBoxSkuName(); continue; } - if (property.NameEquals("model"u8)) + if (prop.NameEquals("model"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - model = property.Value.GetString().ToDeviceModelName(); + model = prop.Value.GetString().ToDeviceModelName(); 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 TransportAvailabilityContent(skuName, model, serializedAdditionalRawData); + return new TransportAvailabilityContent(skuName, model, 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": @@ -127,15 +133,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - TransportAvailabilityContent 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. + TransportAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransportAvailabilityContent 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 DeserializeTransportAvailabilityContent(document.RootElement, options); } default: @@ -143,6 +154,7 @@ TransportAvailabilityContent IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.cs index 9e67b125d31c..8ce53457bccb 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityContent.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Request body to get the transport availability for given sku. public partial class TransportAvailabilityContent { - /// - /// 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 TransportAvailabilityContent() @@ -53,16 +24,17 @@ public TransportAvailabilityContent() /// Initializes a new instance of . /// Type of the device. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal TransportAvailabilityContent(DataBoxSkuName? skuName, DeviceModelName? model, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransportAvailabilityContent(DataBoxSkuName? skuName, DeviceModelName? model, IDictionary additionalBinaryDataProperties) { SkuName = skuName; Model = model; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Type of the device. public DataBoxSkuName? SkuName { get; set; } + /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. public DeviceModelName? Model { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.Serialization.cs index 83a9e718b67e..4f3fd7a9bf2a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class TransportAvailabilityDetails : IUtf8JsonSerializable, IJsonModel + /// Transport options availability details for given region. + public partial class TransportAvailabilityDetails : 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 writer, Model /// 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(TransportAvailabilityDetails)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ShipmentType)) { writer.WritePropertyName("shipmentType"u8); writer.WriteStringValue(ShipmentType.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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransportAvailabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransportAvailabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransportAvailabilityDetails 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(TransportAvailabilityDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransportAvailabilityDetails(document.RootElement, options); } - internal static TransportAvailabilityDetails DeserializeTransportAvailabilityDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransportAvailabilityDetails DeserializeTransportAvailabilityDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } TransportShipmentType? shipmentType = 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("shipmentType"u8)) + if (prop.NameEquals("shipmentType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shipmentType = property.Value.GetString().ToTransportShipmentType(); + shipmentType = prop.Value.GetString().ToTransportShipmentType(); 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 TransportAvailabilityDetails(shipmentType, serializedAdditionalRawData); + return new TransportAvailabilityDetails(shipmentType, 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(ModelReaderWrit } } - TransportAvailabilityDetails 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. + TransportAvailabilityDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransportAvailabilityDetails 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 DeserializeTransportAvailabilityDetails(document.RootElement, options); } default: @@ -128,6 +139,7 @@ TransportAvailabilityDetails IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.cs index 29bfcd920701..6c8222d7f8f6 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Transport options availability details for given region. public partial class TransportAvailabilityDetails { - /// - /// 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 TransportAvailabilityDetails() @@ -52,11 +23,11 @@ internal TransportAvailabilityDetails() /// Initializes a new instance of . /// Transport Shipment Type supported for given region. - /// Keeps track of any properties unknown to the library. - internal TransportAvailabilityDetails(TransportShipmentType? shipmentType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransportAvailabilityDetails(TransportShipmentType? shipmentType, IDictionary additionalBinaryDataProperties) { ShipmentType = shipmentType; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Transport Shipment Type supported for given region. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.Serialization.cs index 601c432e7b30..9fbaf7258b21 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class TransportAvailabilityResponse : IUtf8JsonSerializable, IJsonModel + /// Transport options available for given sku in a region. + internal partial class TransportAvailabilityResponse : 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 +29,30 @@ 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(TransportAvailabilityResponse)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsCollectionDefined(TransportAvailabilityDetails)) { writer.WritePropertyName("transportAvailabilityDetails"u8); writer.WriteStartArray(); - foreach (var item in TransportAvailabilityDetails) + foreach (TransportAvailabilityDetails item in TransportAvailabilityDetails) { 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 +61,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransportAvailabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransportAvailabilityResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransportAvailabilityResponse 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(TransportAvailabilityResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransportAvailabilityResponse(document.RootElement, options); } - internal static TransportAvailabilityResponse DeserializeTransportAvailabilityResponse(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransportAvailabilityResponse DeserializeTransportAvailabilityResponse(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList transportAvailabilityDetails = 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("transportAvailabilityDetails"u8)) + if (prop.NameEquals("transportAvailabilityDetails"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(Models.TransportAvailabilityDetails.DeserializeTransportAvailabilityDetails(item, options)); } @@ -102,17 +106,19 @@ internal static TransportAvailabilityResponse DeserializeTransportAvailabilityRe } 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 TransportAvailabilityResponse(transportAvailabilityDetails ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new TransportAvailabilityResponse(transportAvailabilityDetails ?? 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 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - TransportAvailabilityResponse 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. + TransportAvailabilityResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransportAvailabilityResponse 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 DeserializeTransportAvailabilityResponse(document.RootElement, options); } default: @@ -138,6 +149,7 @@ TransportAvailabilityResponse IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.cs index e4698134b660..4b96009ebe30 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportAvailabilityResponse.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { /// Transport options available for given sku in a region. internal partial class TransportAvailabilityResponse { - /// - /// 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 TransportAvailabilityResponse() @@ -53,11 +25,11 @@ internal TransportAvailabilityResponse() /// Initializes a new instance of . /// List of transport availability details for given region. - /// Keeps track of any properties unknown to the library. - internal TransportAvailabilityResponse(IReadOnlyList transportAvailabilityDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransportAvailabilityResponse(IReadOnlyList transportAvailabilityDetails, IDictionary additionalBinaryDataProperties) { TransportAvailabilityDetails = transportAvailabilityDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// List of transport availability details for given region. diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.Serialization.cs index ba8de89791d4..b8df930926c6 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class TransportPreferences : IUtf8JsonSerializable, IJsonModel + /// Preferences related to the shipment logistics of the sku. + public partial class TransportPreferences : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TransportPreferences() + { + } + /// 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.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(TransportPreferences)} does not support writing '{format}' format."); } - writer.WritePropertyName("preferredShipmentType"u8); writer.WriteStringValue(PreferredShipmentType.ToSerialString()); if (options.Format != "W" && Optional.IsDefined(IsUpdated)) @@ -41,15 +46,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("isUpdated"u8); writer.WriteBooleanValue(IsUpdated.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); } @@ -58,59 +63,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TransportPreferences IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TransportPreferences IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TransportPreferences 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(TransportPreferences)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTransportPreferences(document.RootElement, options); } - internal static TransportPreferences DeserializeTransportPreferences(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TransportPreferences DeserializeTransportPreferences(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } TransportShipmentType preferredShipmentType = default; bool? isUpdated = 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("preferredShipmentType"u8)) + if (prop.NameEquals("preferredShipmentType"u8)) { - preferredShipmentType = property.Value.GetString().ToTransportShipmentType(); + preferredShipmentType = prop.Value.GetString().ToTransportShipmentType(); continue; } - if (property.NameEquals("isUpdated"u8)) + if (prop.NameEquals("isUpdated"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isUpdated = property.Value.GetBoolean(); + isUpdated = prop.Value.GetBoolean(); 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 TransportPreferences(preferredShipmentType, isUpdated, serializedAdditionalRawData); + return new TransportPreferences(preferredShipmentType, isUpdated, 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": @@ -120,15 +131,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - TransportPreferences 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. + TransportPreferences IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TransportPreferences 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 DeserializeTransportPreferences(document.RootElement, options); } default: @@ -136,6 +152,7 @@ TransportPreferences IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.cs index 9d3ee24353a6..80eefec719e9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportPreferences.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Preferences related to the shipment logistics of the sku. public partial class TransportPreferences { - /// - /// 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 . /// Indicates Shipment Logistics type that the customer preferred. @@ -55,21 +26,17 @@ public TransportPreferences(TransportShipmentType preferredShipmentType) /// Initializes a new instance of . /// Indicates Shipment Logistics type that the customer preferred. /// Read only property which indicates whether transport preferences has been updated or not after device is prepared. - /// Keeps track of any properties unknown to the library. - internal TransportPreferences(TransportShipmentType preferredShipmentType, bool? isUpdated, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TransportPreferences(TransportShipmentType preferredShipmentType, bool? isUpdated, IDictionary additionalBinaryDataProperties) { PreferredShipmentType = preferredShipmentType; IsUpdated = isUpdated; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TransportPreferences() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Indicates Shipment Logistics type that the customer preferred. public TransportShipmentType PreferredShipmentType { get; set; } + /// Read only property which indicates whether transport preferences has been updated or not after device is prepared. public bool? IsUpdated { get; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportShipmentType.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportShipmentType.Serialization.cs index beb9d1e15f27..7a310b87e6da 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportShipmentType.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/TransportShipmentType.Serialization.cs @@ -11,6 +11,7 @@ namespace Azure.ResourceManager.DataBox.Models { internal static partial class TransportShipmentTypeExtensions { + /// The value to serialize. public static string ToSerialString(this TransportShipmentType value) => value switch { TransportShipmentType.CustomerManaged => "CustomerManaged", @@ -18,10 +19,17 @@ internal static partial class TransportShipmentTypeExtensions _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TransportShipmentType value.") }; + /// The value to deserialize. public static TransportShipmentType ToTransportShipmentType(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerManaged")) return TransportShipmentType.CustomerManaged; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "MicrosoftManaged")) return TransportShipmentType.MicrosoftManaged; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomerManaged")) + { + return TransportShipmentType.CustomerManaged; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "MicrosoftManaged")) + { + return TransportShipmentType.MicrosoftManaged; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TransportShipmentType value."); } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.Serialization.cs index 429009c0470e..99dab5538d06 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class UnencryptedCredentials : IUtf8JsonSerializable, IJsonModel + /// Unencrypted credentials for accessing device. + public partial class UnencryptedCredentials : 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, ModelReader /// 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(UnencryptedCredentials)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(JobName)) { writer.WritePropertyName("jobName"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("jobSecrets"u8); writer.WriteObjectValue(JobSecrets, 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); } @@ -61,59 +61,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - UnencryptedCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + UnencryptedCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UnencryptedCredentials 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(UnencryptedCredentials)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeUnencryptedCredentials(document.RootElement, options); } - internal static UnencryptedCredentials DeserializeUnencryptedCredentials(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnencryptedCredentials DeserializeUnencryptedCredentials(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string jobName = default; JobSecrets jobSecrets = 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("jobName"u8)) + if (prop.NameEquals("jobName"u8)) { - jobName = property.Value.GetString(); + jobName = prop.Value.GetString(); continue; } - if (property.NameEquals("jobSecrets"u8)) + if (prop.NameEquals("jobSecrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - jobSecrets = JobSecrets.DeserializeJobSecrets(property.Value, options); + jobSecrets = JobSecrets.DeserializeJobSecrets(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 UnencryptedCredentials(jobName, jobSecrets, serializedAdditionalRawData); + return new UnencryptedCredentials(jobName, jobSecrets, 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 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - UnencryptedCredentials 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. + UnencryptedCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UnencryptedCredentials 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 DeserializeUnencryptedCredentials(document.RootElement, options); } default: @@ -139,6 +150,7 @@ UnencryptedCredentials IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.cs index 682e3570df8f..12ac77f36b06 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentials.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Unencrypted credentials for accessing device. public partial class UnencryptedCredentials { - /// - /// 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 UnencryptedCredentials() @@ -52,26 +23,19 @@ internal UnencryptedCredentials() /// Initializes a new instance of . /// Name of the job. - /// - /// Secrets related to this job. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// - /// Keeps track of any properties unknown to the library. - internal UnencryptedCredentials(string jobName, JobSecrets jobSecrets, IDictionary serializedAdditionalRawData) + /// Secrets related to this job. + /// Keeps track of any properties unknown to the library. + internal UnencryptedCredentials(string jobName, JobSecrets jobSecrets, IDictionary additionalBinaryDataProperties) { JobName = jobName; JobSecrets = jobSecrets; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the job. public string JobName { get; } - /// - /// Secrets related to this job. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// + + /// Secrets related to this job. public JobSecrets JobSecrets { get; } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.Serialization.cs index 788dc701b2e5..e9b829019cde 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.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.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class UnencryptedCredentialsList : IUtf8JsonSerializable, IJsonModel + /// List of unencrypted credentials for accessing device. + internal partial class UnencryptedCredentialsList : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnencryptedCredentialsList() + { + } + /// 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, 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(UnencryptedCredentialsList)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (UnencryptedCredentials 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 } } - UnencryptedCredentialsList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + UnencryptedCredentialsList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UnencryptedCredentialsList 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(UnencryptedCredentialsList)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeUnencryptedCredentialsList(document.RootElement, options); } - internal static UnencryptedCredentialsList DeserializeUnencryptedCredentialsList(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnencryptedCredentialsList DeserializeUnencryptedCredentialsList(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(UnencryptedCredentials.DeserializeUnencryptedCredentials(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 UnencryptedCredentialsList(value, nextLink, serializedAdditionalRawData); + return new UnencryptedCredentialsList(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(ModelReaderWriter } } - UnencryptedCredentialsList 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. + UnencryptedCredentialsList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UnencryptedCredentialsList 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 DeserializeUnencryptedCredentialsList(document.RootElement, options); } default: @@ -146,6 +163,14 @@ UnencryptedCredentialsList IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static UnencryptedCredentialsList FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnencryptedCredentialsList(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.cs index 6a58bdffb7e8..b0a062b6d38e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnencryptedCredentialsList.cs @@ -14,66 +14,30 @@ namespace Azure.ResourceManager.DataBox.Models /// List of unencrypted credentials for accessing device. internal partial class UnencryptedCredentialsList { - /// - /// 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 UnencryptedCredentials items on this page. - /// is null. internal UnencryptedCredentialsList(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The UnencryptedCredentials items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal UnencryptedCredentialsList(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal UnencryptedCredentialsList(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal UnencryptedCredentialsList() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The UnencryptedCredentials 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.Serialization.cs index e6bfb70bb09a..ba7968329304 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.Serialization.cs @@ -9,14 +9,19 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class UnknownCopyLogDetails : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownCopyLogDetails : CopyLogDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownCopyLogDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,58 +33,63 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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(CopyLogDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - CopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + CopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override CopyLogDetails 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(CopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeCopyLogDetails(document.RootElement, options); } - internal static UnknownCopyLogDetails DeserializeUnknownCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownCopyLogDetails DeserializeUnknownCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxOrderType copyLogDetailsType = 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("copyLogDetailsType"u8)) + if (prop.NameEquals("copyLogDetailsType"u8)) { - copyLogDetailsType = property.Value.GetString().ToDataBoxOrderType(); + copyLogDetailsType = prop.Value.GetString().ToDataBoxOrderType(); 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 UnknownCopyLogDetails(copyLogDetailsType, serializedAdditionalRawData); + return new UnknownCopyLogDetails(copyLogDetailsType, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +99,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - CopyLogDetails 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. + CopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override CopyLogDetails 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 DeserializeCopyLogDetails(document.RootElement, options); } default: @@ -105,6 +120,7 @@ CopyLogDetails IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.cs index a24f916c268d..1189fc39a338 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownCopyLogDetails.cs @@ -10,19 +10,12 @@ namespace Azure.ResourceManager.DataBox.Models { - /// Unknown version of CopyLogDetails. internal partial class UnknownCopyLogDetails : CopyLogDetails { /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. - internal UnknownCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData) : base(copyLogDetailsType, serializedAdditionalRawData) - { - CopyLogDetailsType = copyLogDetailsType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownCopyLogDetails() + /// Keeps track of any properties unknown to the library. + internal UnknownCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties) : base(copyLogDetailsType, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.Serialization.cs index 839879fbd6b6..73d9550480a9 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.Serialization.cs @@ -9,14 +9,19 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class UnknownDataAccountDetails : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownDataAccountDetails : DataAccountDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownDataAccountDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,64 +33,69 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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(DataAccountDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - DataAccountDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataAccountDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataAccountDetails 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(DataAccountDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataAccountDetails(document.RootElement, options); } - internal static UnknownDataAccountDetails DeserializeUnknownDataAccountDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownDataAccountDetails DeserializeUnknownDataAccountDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataAccountType dataAccountType = default; string sharePassword = 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("dataAccountType"u8)) + if (prop.NameEquals("dataAccountType"u8)) { - dataAccountType = property.Value.GetString().ToDataAccountType(); + dataAccountType = prop.Value.GetString().ToDataAccountType(); continue; } - if (property.NameEquals("sharePassword"u8)) + if (prop.NameEquals("sharePassword"u8)) { - sharePassword = property.Value.GetString(); + sharePassword = 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 UnknownDataAccountDetails(dataAccountType, sharePassword, serializedAdditionalRawData); + return new UnknownDataAccountDetails(dataAccountType, sharePassword, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -95,15 +105,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DataAccountDetails 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. + DataAccountDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataAccountDetails 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 DeserializeDataAccountDetails(document.RootElement, options); } default: @@ -111,6 +126,7 @@ DataAccountDetails IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.cs index ad971eb523e1..4bae5d0cbedf 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataAccountDetails.cs @@ -10,20 +10,13 @@ namespace Azure.ResourceManager.DataBox.Models { - /// Unknown version of DataAccountDetails. internal partial class UnknownDataAccountDetails : DataAccountDetails { /// Initializes a new instance of . /// Account Type of the data to be transferred. /// Password for all the shares to be created on the device. Should not be passed for TransferType:ExportFromAzure jobs. If this is not passed, the service will generate password itself. This will not be returned in Get Call. Password Requirements : Password must be minimum of 12 and maximum of 64 characters. Password must have at least one uppercase alphabet, one number and one special character. Password cannot have the following characters : IilLoO0 Password can have only alphabets, numbers and these characters : @#\-$%^!+=;:_()]+. - /// Keeps track of any properties unknown to the library. - internal UnknownDataAccountDetails(DataAccountType dataAccountType, string sharePassword, IDictionary serializedAdditionalRawData) : base(dataAccountType, sharePassword, serializedAdditionalRawData) - { - DataAccountType = dataAccountType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownDataAccountDetails() + /// Keeps track of any properties unknown to the library. + internal UnknownDataAccountDetails(DataAccountType dataAccountType, string sharePassword, IDictionary additionalBinaryDataProperties) : base(dataAccountType, sharePassword, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxBasicJobDetails.Serialization.cs similarity index 56% rename from sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobDetails.Serialization.cs rename to sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxBasicJobDetails.Serialization.cs index 2b2e5bc293f3..47ce23f7c19a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxBasicJobDetails.Serialization.cs @@ -9,14 +9,19 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class UnknownJobDetails : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownDataBoxBasicJobDetails : DataBoxBasicJobDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownDataBoxBasicJobDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +33,35 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(DataBoxBasicJobDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - DataBoxBasicJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxBasicJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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(DataBoxBasicJobDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataBoxBasicJobDetails(document.RootElement, options); } - internal static UnknownJobDetails DeserializeUnknownJobDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownDataBoxBasicJobDetails DeserializeUnknownDataBoxBasicJobDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -72,211 +81,209 @@ internal static UnknownJobDetails DeserializeUnknownJobDetails(JsonElement eleme string chainOfCustodySasKey = default; DeviceErasureDetails deviceErasureDetails = default; DataBoxKeyEncryptionKey keyEncryptionKey = default; - int? expectedDataSizeInTeraBytes = default; + int? expectedDataSizeInTerabytes = default; IReadOnlyList actions = default; LastMitigationActionOnJob lastMitigationActionOnJob = default; - DataCenterAddressResult datacenterAddress = default; + DataCenterAddressResult dataCenterAddress = default; DataCenterCode? dataCenterCode = 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("jobStages"u8)) + if (prop.NameEquals("jobStages"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(DataBoxJobStage.DeserializeDataBoxJobStage(item, options)); } jobStages = array; continue; } - if (property.NameEquals("contactDetails"u8)) + if (prop.NameEquals("contactDetails"u8)) { - contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(property.Value, options); + contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(prop.Value, options); continue; } - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("shippingAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("deliveryPackage"u8)) + if (prop.NameEquals("deliveryPackage"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + deliveryPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("returnPackage"u8)) + if (prop.NameEquals("returnPackage"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(property.Value, options); + returnPackage = PackageShippingDetails.DeserializePackageShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("dataImportDetails"u8)) + if (prop.NameEquals("dataImportDetails"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(Models.DataImportDetails.DeserializeDataImportDetails(item, options)); } dataImportDetails = array; continue; } - if (property.NameEquals("dataExportDetails"u8)) + if (prop.NameEquals("dataExportDetails"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(Models.DataExportDetails.DeserializeDataExportDetails(item, options)); } dataExportDetails = array; continue; } - if (property.NameEquals("jobDetailsType"u8)) + if (prop.NameEquals("jobDetailsType"u8)) { - jobDetailsType = property.Value.GetString().ToDataBoxOrderType(); + jobDetailsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("preferences"u8)) + if (prop.NameEquals("preferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(property.Value, options); + preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(prop.Value, options); continue; } - if (property.NameEquals("reverseShippingDetails"u8)) + if (prop.NameEquals("reverseShippingDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(property.Value, options); + reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("copyLogDetails"u8)) + if (prop.NameEquals("copyLogDetails"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(Models.CopyLogDetails.DeserializeCopyLogDetails(item, options)); } copyLogDetails = array; continue; } - if (property.NameEquals("reverseShipmentLabelSasKey"u8)) + if (prop.NameEquals("reverseShipmentLabelSasKey"u8)) { - reverseShipmentLabelSasKey = property.Value.GetString(); + reverseShipmentLabelSasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("chainOfCustodySasKey"u8)) + if (prop.NameEquals("chainOfCustodySasKey"u8)) { - chainOfCustodySasKey = property.Value.GetString(); + chainOfCustodySasKey = prop.Value.GetString(); continue; } - if (property.NameEquals("deviceErasureDetails"u8)) + if (prop.NameEquals("deviceErasureDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(property.Value, options); + deviceErasureDetails = DeviceErasureDetails.DeserializeDeviceErasureDetails(prop.Value, options); continue; } - if (property.NameEquals("keyEncryptionKey"u8)) + if (prop.NameEquals("keyEncryptionKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(property.Value, options); + keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(prop.Value, options); continue; } - if (property.NameEquals("expectedDataSizeInTeraBytes"u8)) + if (prop.NameEquals("expectedDataSizeInTeraBytes"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - expectedDataSizeInTeraBytes = property.Value.GetInt32(); + expectedDataSizeInTerabytes = prop.Value.GetInt32(); continue; } - if (property.NameEquals("actions"u8)) + if (prop.NameEquals("actions"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().ToCustomerResolutionCode()); } actions = array; continue; } - if (property.NameEquals("lastMitigationActionOnJob"u8)) + if (prop.NameEquals("lastMitigationActionOnJob"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(property.Value, options); + lastMitigationActionOnJob = LastMitigationActionOnJob.DeserializeLastMitigationActionOnJob(prop.Value, options); continue; } - if (property.NameEquals("datacenterAddress"u8)) + if (prop.NameEquals("datacenterAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datacenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(property.Value, options); + dataCenterAddress = DataCenterAddressResult.DeserializeDataCenterAddressResult(prop.Value, options); continue; } - if (property.NameEquals("dataCenterCode"u8)) + if (prop.NameEquals("dataCenterCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dataCenterCode = new DataCenterCode(property.Value.GetString()); + dataCenterCode = new DataCenterCode(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 UnknownJobDetails( + return new UnknownDataBoxBasicJobDetails( jobStages ?? new ChangeTrackingList(), contactDetails, shippingAddress, @@ -292,18 +299,21 @@ internal static UnknownJobDetails DeserializeUnknownJobDetails(JsonElement eleme chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, - expectedDataSizeInTeraBytes, + expectedDataSizeInTerabytes, actions ?? new ChangeTrackingList(), lastMitigationActionOnJob, - datacenterAddress, + dataCenterAddress, dataCenterCode, - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -313,15 +323,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - DataBoxBasicJobDetails 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. + DataBoxBasicJobDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxBasicJobDetails 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 DeserializeDataBoxBasicJobDetails(document.RootElement, options); } default: @@ -329,6 +344,7 @@ DataBoxBasicJobDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxBasicJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxBasicJobDetails.cs new file mode 100644 index 000000000000..4837d9f60d65 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxBasicJobDetails.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataBoxBasicJobDetails : DataBoxBasicJobDetails + { + /// Initializes a new instance of . + /// List of stages that run in the job. + /// Contact details for notification and shipping. + /// Shipping address of the customer. + /// Delivery package shipping details. + /// Return package shipping details. + /// Details of the data to be imported into azure. + /// Details of the data to be exported from azure. + /// Indicates the type of job details. + /// Preferences for the order. + /// Optional Reverse Shipping details for order. + /// List of copy log details. + /// Shared access key to download the return shipment label. + /// Shared access key to download the chain of custody logs. + /// Holds device data erasure details. + /// Details about which key encryption type is being used. + /// The expected size of the data, which needs to be transferred in this job, in terabytes. + /// Available actions on the job. + /// Last mitigation action performed on the job. + /// Datacenter address to ship to, for the given sku and storage location. + /// DataCenter code. + /// Keeps track of any properties unknown to the library. + internal UnknownDataBoxBasicJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary additionalBinaryDataProperties) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationContent.Serialization.cs new file mode 100644 index 000000000000..5aa4301774f2 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationContent.Serialization.cs @@ -0,0 +1,137 @@ +// 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.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataBoxValidationContent : DataBoxValidationContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownDataBoxValidationContent() + { + } + + /// 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 override 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(DataBoxValidationContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationContent 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(DataBoxValidationContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataBoxValidationContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownDataBoxValidationContent DeserializeUnknownDataBoxValidationContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string validationCategory = "unknown"; + IList individualRequestDetails = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("validationCategory"u8)) + { + validationCategory = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("individualRequestDetails"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxValidationInputContent.DeserializeDataBoxValidationInputContent(item, options)); + } + individualRequestDetails = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownDataBoxValidationContent(validationCategory, individualRequestDetails, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(DataBoxValidationContent)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DataBoxValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationContent 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 DeserializeDataBoxValidationContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataBoxValidationContent)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationContent.cs new file mode 100644 index 000000000000..156d0a695177 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationContent.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataBoxValidationContent : DataBoxValidationContent + { + /// Initializes a new instance of . + /// Identify the nature of validation. + /// List of request details contain validationType and its request as key and value respectively. + /// Keeps track of any properties unknown to the library. + internal UnknownDataBoxValidationContent(string validationCategory, IList individualRequestDetails, IDictionary additionalBinaryDataProperties) : base(validationCategory ?? "unknown", individualRequestDetails, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputContent.Serialization.cs new file mode 100644 index 000000000000..6264d929ac51 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputContent.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataBoxValidationInputContent : DataBoxValidationInputContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownDataBoxValidationInputContent() + { + } + + /// 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 override 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(DataBoxValidationInputContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidationInputContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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(DataBoxValidationInputContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataBoxValidationInputContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownDataBoxValidationInputContent DeserializeUnknownDataBoxValidationInputContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataBoxValidationInputDiscriminator validationType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("validationType"u8)) + { + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownDataBoxValidationInputContent(validationType, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(DataBoxValidationInputContent)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DataBoxValidationInputContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputContent 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 DeserializeDataBoxValidationInputContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataBoxValidationInputContent)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputContent.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputContent.cs new file mode 100644 index 000000000000..32894eae39b8 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputContent.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataBoxValidationInputContent : DataBoxValidationInputContent + { + /// Initializes a new instance of . + /// Identifies the type of validation request. + /// Keeps track of any properties unknown to the library. + internal UnknownDataBoxValidationInputContent(DataBoxValidationInputDiscriminator validationType, IDictionary additionalBinaryDataProperties) : base(validationType, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputResult.Serialization.cs new file mode 100644 index 000000000000..ab0123139e73 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputResult.Serialization.cs @@ -0,0 +1,138 @@ +// 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; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataBoxValidationInputResult : DataBoxValidationInputResult, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownDataBoxValidationInputResult() + { + } + + /// 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 override 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(DataBoxValidationInputResult)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + DataBoxValidationInputResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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(DataBoxValidationInputResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataBoxValidationInputResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownDataBoxValidationInputResult DeserializeUnknownDataBoxValidationInputResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataBoxValidationInputDiscriminator validationType = default; + ResponseError error = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("validationType"u8)) + { + validationType = prop.Value.GetString().ToDataBoxValidationInputDiscriminator(); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.Default); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownDataBoxValidationInputResult(validationType, error, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(DataBoxValidationInputResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DataBoxValidationInputResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override DataBoxValidationInputResult 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 DeserializeDataBoxValidationInputResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataBoxValidationInputResult)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputResult.cs new file mode 100644 index 000000000000..a9463976bcf4 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataBoxValidationInputResult.cs @@ -0,0 +1,24 @@ +// 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.DataBox.Models +{ + internal partial class UnknownDataBoxValidationInputResult : DataBoxValidationInputResult + { + /// Initializes a new instance of . + /// Identifies the type of validation response. + /// Error code and message of validation response. + /// Keeps track of any properties unknown to the library. + internal UnknownDataBoxValidationInputResult(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary additionalBinaryDataProperties) : base(validationType, error, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResponse.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResponse.Serialization.cs deleted file mode 100644 index d8582a80e345..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResponse.Serialization.cs +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.DataBox.Models -{ - internal partial class UnknownDataCenterAddressResponse : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataCenterAddressResult)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - DataCenterAddressResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataCenterAddressResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataCenterAddressResult(document.RootElement, options); - } - - internal static UnknownDataCenterAddressResponse DeserializeUnknownDataCenterAddressResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - DatacenterAddressType datacenterAddressType = default; - IReadOnlyList supportedCarriersForReturnShipment = default; - AzureLocation? dataCenterAzureLocation = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("datacenterAddressType"u8)) - { - datacenterAddressType = property.Value.GetString().ToDatacenterAddressType(); - continue; - } - if (property.NameEquals("supportedCarriersForReturnShipment"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - supportedCarriersForReturnShipment = array; - continue; - } - if (property.NameEquals("dataCenterAzureLocation"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dataCenterAzureLocation = new AzureLocation(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownDataCenterAddressResponse(datacenterAddressType, supportedCarriersForReturnShipment ?? new ChangeTrackingList(), dataCenterAzureLocation, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); - default: - throw new FormatException($"The model {nameof(DataCenterAddressResult)} does not support writing '{options.Format}' format."); - } - } - - DataCenterAddressResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDataCenterAddressResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DataCenterAddressResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResponse.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResponse.cs deleted file mode 100644 index 7aaf30c5650f..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResponse.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using Azure.Core; - -namespace Azure.ResourceManager.DataBox.Models -{ - /// Unknown version of DataCenterAddressResult. - internal partial class UnknownDataCenterAddressResponse : DataCenterAddressResult - { - /// Initializes a new instance of . - /// Data center address type. - /// List of supported carriers for return shipment. - /// Azure Location where the Data Center serves primarily. - /// Keeps track of any properties unknown to the library. - internal UnknownDataCenterAddressResponse(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary serializedAdditionalRawData) : base(datacenterAddressType, supportedCarriersForReturnShipment, dataCenterAzureLocation, serializedAdditionalRawData) - { - DatacenterAddressType = datacenterAddressType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownDataCenterAddressResponse() - { - } - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResult.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResult.Serialization.cs new file mode 100644 index 000000000000..7604b543921d --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResult.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataCenterAddressResult : DataCenterAddressResult, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownDataCenterAddressResult() + { + } + + /// 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 override 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(DataCenterAddressResult)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + DataCenterAddressResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DataCenterAddressResult 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(DataCenterAddressResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataCenterAddressResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownDataCenterAddressResult DeserializeUnknownDataCenterAddressResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DatacenterAddressType datacenterAddressType = default; + IReadOnlyList supportedCarriersForReturnShipment = default; + AzureLocation? dataCenterAzureLocation = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("datacenterAddressType"u8)) + { + datacenterAddressType = prop.Value.GetString().ToDatacenterAddressType(); + continue; + } + if (prop.NameEquals("supportedCarriersForReturnShipment"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + supportedCarriersForReturnShipment = array; + continue; + } + if (prop.NameEquals("dataCenterAzureLocation"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataCenterAzureLocation = new AzureLocation(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownDataCenterAddressResult(datacenterAddressType, supportedCarriersForReturnShipment ?? new ChangeTrackingList(), dataCenterAzureLocation, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(DataCenterAddressResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DataCenterAddressResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override DataCenterAddressResult 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 DeserializeDataCenterAddressResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataCenterAddressResult)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResult.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResult.cs new file mode 100644 index 000000000000..7597121f4514 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownDataCenterAddressResult.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownDataCenterAddressResult : DataCenterAddressResult + { + /// Initializes a new instance of . + /// Data center address type. + /// List of supported carriers for return shipment. + /// Azure Location where the Data Center serves primarily. + /// Keeps track of any properties unknown to the library. + internal UnknownDataCenterAddressResult(DatacenterAddressType datacenterAddressType, IReadOnlyList supportedCarriersForReturnShipment, AzureLocation? dataCenterAzureLocation, IDictionary additionalBinaryDataProperties) : base(datacenterAddressType, supportedCarriersForReturnShipment, dataCenterAzureLocation, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.Serialization.cs index 1b0c2258e57f..f30458360d7a 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.Serialization.cs @@ -9,14 +9,19 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class UnknownGranularCopyLogDetails : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownGranularCopyLogDetails : GranularCopyLogDetails, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownGranularCopyLogDetails() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,58 +33,63 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(GranularCopyLogDetails)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - GranularCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + GranularCopyLogDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override GranularCopyLogDetails 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(GranularCopyLogDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeGranularCopyLogDetails(document.RootElement, options); } - internal static UnknownGranularCopyLogDetails DeserializeUnknownGranularCopyLogDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownGranularCopyLogDetails DeserializeUnknownGranularCopyLogDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxOrderType copyLogDetailsType = 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("copyLogDetailsType"u8)) + if (prop.NameEquals("copyLogDetailsType"u8)) { - copyLogDetailsType = property.Value.GetString().ToDataBoxOrderType(); + copyLogDetailsType = prop.Value.GetString().ToDataBoxOrderType(); 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 UnknownGranularCopyLogDetails(copyLogDetailsType, serializedAdditionalRawData); + return new UnknownGranularCopyLogDetails(copyLogDetailsType, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -89,15 +99,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - GranularCopyLogDetails 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. + GranularCopyLogDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override GranularCopyLogDetails 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 DeserializeGranularCopyLogDetails(document.RootElement, options); } default: @@ -105,6 +120,7 @@ GranularCopyLogDetails IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.cs index d0706f7e27b8..37d30c357a71 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownGranularCopyLogDetails.cs @@ -10,19 +10,12 @@ namespace Azure.ResourceManager.DataBox.Models { - /// Unknown version of GranularCopyLogDetails. internal partial class UnknownGranularCopyLogDetails : GranularCopyLogDetails { /// Initializes a new instance of . /// Indicates the type of job details. - /// Keeps track of any properties unknown to the library. - internal UnknownGranularCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary serializedAdditionalRawData) : base(copyLogDetailsType, serializedAdditionalRawData) - { - CopyLogDetailsType = copyLogDetailsType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownGranularCopyLogDetails() + /// Keeps track of any properties unknown to the library. + internal UnknownGranularCopyLogDetails(DataBoxOrderType copyLogDetailsType, IDictionary additionalBinaryDataProperties) : base(copyLogDetailsType, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobDetails.cs deleted file mode 100644 index 58e7e59f2246..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobDetails.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.DataBox.Models -{ - /// Unknown version of DataBoxBasicJobDetails. - internal partial class UnknownJobDetails : DataBoxBasicJobDetails - { - /// Initializes a new instance of . - /// List of stages that run in the job. - /// Contact details for notification and shipping. - /// Shipping address of the customer. - /// Delivery package shipping details. - /// Return package shipping details. - /// Details of the data to be imported into azure. - /// Details of the data to be exported from azure. - /// Indicates the type of job details. - /// Preferences for the order. - /// Optional Reverse Shipping details for order. - /// - /// List of copy log details. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , and . - /// - /// Shared access key to download the return shipment label. - /// Shared access key to download the chain of custody logs. - /// Holds device data erasure details. - /// Details about which key encryption type is being used. - /// The expected size of the data, which needs to be transferred in this job, in terabytes. - /// Available actions on the job. - /// Last mitigation action performed on the job. - /// - /// Datacenter address to ship to, for the given sku and storage location. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include and . - /// - /// DataCenter code. - /// Keeps track of any properties unknown to the library. - internal UnknownJobDetails(IReadOnlyList jobStages, DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, PackageShippingDetails deliveryPackage, PackageShippingDetails returnPackage, IList dataImportDetails, IList dataExportDetails, DataBoxOrderType jobDetailsType, DataBoxOrderPreferences preferences, ReverseShippingDetails reverseShippingDetails, IReadOnlyList copyLogDetails, string reverseShipmentLabelSasKey, string chainOfCustodySasKey, DeviceErasureDetails deviceErasureDetails, DataBoxKeyEncryptionKey keyEncryptionKey, int? expectedDataSizeInTerabytes, IReadOnlyList actions, LastMitigationActionOnJob lastMitigationActionOnJob, DataCenterAddressResult dataCenterAddress, DataCenterCode? dataCenterCode, IDictionary serializedAdditionalRawData) : base(jobStages, contactDetails, shippingAddress, deliveryPackage, returnPackage, dataImportDetails, dataExportDetails, jobDetailsType, preferences, reverseShippingDetails, copyLogDetails, reverseShipmentLabelSasKey, chainOfCustodySasKey, deviceErasureDetails, keyEncryptionKey, expectedDataSizeInTerabytes, actions, lastMitigationActionOnJob, dataCenterAddress, dataCenterCode, serializedAdditionalRawData) - { - JobDetailsType = jobDetailsType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownJobDetails() - { - } - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.Serialization.cs index e05b991a074e..059b8005cc31 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.Serialization.cs @@ -10,14 +10,20 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - internal partial class UnknownJobSecrets : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownJobSecrets : JobSecrets, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownJobSecrets() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,78 +35,83 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption /// 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(JobSecrets)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - JobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + JobSecrets IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override JobSecrets 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(JobSecrets)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeJobSecrets(document.RootElement, options); } - internal static UnknownJobSecrets DeserializeUnknownJobSecrets(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownJobSecrets DeserializeUnknownJobSecrets(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DataBoxOrderType jobSecretsType = default; - DataCenterAccessSecurityCode dcAccessSecurityCode = default; + DataCenterAccessSecurityCode dataCenterAccessSecurityCode = default; ResponseError error = 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("jobSecretsType"u8)) + if (prop.NameEquals("jobSecretsType"u8)) { - jobSecretsType = property.Value.GetString().ToDataBoxOrderType(); + jobSecretsType = prop.Value.GetString().ToDataBoxOrderType(); continue; } - if (property.NameEquals("dcAccessSecurityCode"u8)) + if (prop.NameEquals("dcAccessSecurityCode"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dcAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(property.Value, options); + dataCenterAccessSecurityCode = DataCenterAccessSecurityCode.DeserializeDataCenterAccessSecurityCode(prop.Value, options); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDataBoxContext.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 UnknownJobSecrets(jobSecretsType, dcAccessSecurityCode, error, serializedAdditionalRawData); + return new UnknownJobSecrets(jobSecretsType, dataCenterAccessSecurityCode, error, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -110,15 +121,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) } } - JobSecrets 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. + JobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override JobSecrets 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 DeserializeJobSecrets(document.RootElement, options); } default: @@ -126,6 +142,7 @@ JobSecrets IPersistableModel.Create(BinaryData data, ModelReaderWrit } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.cs index afee0adc6850..8217339030b2 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownJobSecrets.cs @@ -7,24 +7,18 @@ using System; using System.Collections.Generic; +using Azure; namespace Azure.ResourceManager.DataBox.Models { - /// Unknown version of JobSecrets. internal partial class UnknownJobSecrets : JobSecrets { /// Initializes a new instance of . /// Used to indicate what type of job secrets object. /// Dc Access Security Code for Customer Managed Shipping. /// Error while fetching the secrets. - /// Keeps track of any properties unknown to the library. - internal UnknownJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary serializedAdditionalRawData) : base(jobSecretsType, dataCenterAccessSecurityCode, error, serializedAdditionalRawData) - { - JobSecretsType = jobSecretsType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownJobSecrets() + /// Keeps track of any properties unknown to the library. + internal UnknownJobSecrets(DataBoxOrderType jobSecretsType, DataCenterAccessSecurityCode dataCenterAccessSecurityCode, ResponseError error, IDictionary additionalBinaryDataProperties) : base(jobSecretsType, dataCenterAccessSecurityCode, error, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityContent.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityContent.Serialization.cs new file mode 100644 index 000000000000..ea541bd2b2a6 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityContent.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + internal partial class UnknownScheduleAvailabilityContent : ScheduleAvailabilityContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownScheduleAvailabilityContent() + { + } + + /// 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 override 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(ScheduleAvailabilityContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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(ScheduleAvailabilityContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScheduleAvailabilityContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownScheduleAvailabilityContent DeserializeUnknownScheduleAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureLocation storageLocation = default; + DataBoxSkuName skuName = default; + string country = default; + DeviceModelName? model = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("storageLocation"u8)) + { + storageLocation = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("skuName"u8)) + { + skuName = prop.Value.GetString().ToDataBoxSkuName(); + continue; + } + if (prop.NameEquals("country"u8)) + { + country = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("model"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = prop.Value.GetString().ToDeviceModelName(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownScheduleAvailabilityContent(storageLocation, skuName, country, model, 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(ScheduleAvailabilityContent)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ScheduleAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ScheduleAvailabilityContent 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 DeserializeScheduleAvailabilityContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScheduleAvailabilityContent)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityRequest.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityContent.cs similarity index 58% rename from sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityRequest.cs rename to sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityContent.cs index 99c764a389ad..2b0c66f3b172 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityRequest.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityContent.cs @@ -11,22 +11,15 @@ namespace Azure.ResourceManager.DataBox.Models { - /// Unknown version of ScheduleAvailabilityContent. - internal partial class UnknownScheduleAvailabilityRequest : ScheduleAvailabilityContent + internal partial class UnknownScheduleAvailabilityContent : ScheduleAvailabilityContent { - /// Initializes a new instance of . + /// Initializes a new instance of . /// Location for data transfer. For locations check: https://management.azure.com/subscriptions/SUBSCRIPTIONID/locations?api-version=2018-01-01. /// Sku Name for which the order is to be scheduled. /// Country in which storage location should be supported. /// The customer friendly name of the combination of version and capacity of the device. This field is necessary only at the time of ordering the newer generation device i.e. AzureDataBox120 and AzureDataBox525 as of Feb/2025. - /// Keeps track of any properties unknown to the library. - internal UnknownScheduleAvailabilityRequest(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary serializedAdditionalRawData) : base(storageLocation, skuName, country, model, serializedAdditionalRawData) - { - SkuName = skuName; - } - - /// Initializes a new instance of for deserialization. - internal UnknownScheduleAvailabilityRequest() + /// Keeps track of any properties unknown to the library. + internal UnknownScheduleAvailabilityContent(AzureLocation storageLocation, DataBoxSkuName skuName, string country, DeviceModelName? model, IDictionary additionalBinaryDataProperties) : base(storageLocation, skuName, country, model, additionalBinaryDataProperties) { } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityRequest.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityRequest.Serialization.cs deleted file mode 100644 index 595cdce5a777..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownScheduleAvailabilityRequest.Serialization.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.DataBox.Models -{ - internal partial class UnknownScheduleAvailabilityRequest : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ScheduleAvailabilityContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - ScheduleAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ScheduleAvailabilityContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeScheduleAvailabilityContent(document.RootElement, options); - } - - internal static UnknownScheduleAvailabilityRequest DeserializeUnknownScheduleAvailabilityRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - AzureLocation storageLocation = default; - DataBoxSkuName skuName = default; - string country = default; - DeviceModelName? model = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("storageLocation"u8)) - { - storageLocation = new AzureLocation(property.Value.GetString()); - continue; - } - if (property.NameEquals("skuName"u8)) - { - skuName = property.Value.GetString().ToDataBoxSkuName(); - continue; - } - if (property.NameEquals("country"u8)) - { - country = property.Value.GetString(); - continue; - } - if (property.NameEquals("model"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - model = property.Value.GetString().ToDeviceModelName(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownScheduleAvailabilityRequest(storageLocation, skuName, country, model, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); - default: - throw new FormatException($"The model {nameof(ScheduleAvailabilityContent)} does not support writing '{options.Format}' format."); - } - } - - ScheduleAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeScheduleAvailabilityContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ScheduleAvailabilityContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputRequest.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputRequest.Serialization.cs deleted file mode 100644 index 1e2a7b7cb07b..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputRequest.Serialization.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.DataBox.Models -{ - internal partial class UnknownValidationInputRequest : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataBoxValidationInputContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - DataBoxValidationInputContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataBoxValidationInputContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataBoxValidationInputContent(document.RootElement, options); - } - - internal static UnknownValidationInputRequest DeserializeUnknownValidationInputRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - DataBoxValidationInputDiscriminator validationType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("validationType"u8)) - { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownValidationInputRequest(validationType, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); - default: - throw new FormatException($"The model {nameof(DataBoxValidationInputContent)} does not support writing '{options.Format}' format."); - } - } - - DataBoxValidationInputContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDataBoxValidationInputContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DataBoxValidationInputContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputRequest.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputRequest.cs deleted file mode 100644 index 86ae09d9c33f..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputRequest.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.DataBox.Models -{ - /// Unknown version of DataBoxValidationInputContent. - internal partial class UnknownValidationInputRequest : DataBoxValidationInputContent - { - /// Initializes a new instance of . - /// Identifies the type of validation request. - /// Keeps track of any properties unknown to the library. - internal UnknownValidationInputRequest(DataBoxValidationInputDiscriminator validationType, IDictionary serializedAdditionalRawData) : base(validationType, serializedAdditionalRawData) - { - ValidationType = validationType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownValidationInputRequest() - { - } - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputResponse.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputResponse.Serialization.cs deleted file mode 100644 index f8bd29da8fb2..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputResponse.Serialization.cs +++ /dev/null @@ -1,121 +0,0 @@ -// 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; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.DataBox.Models -{ - internal partial class UnknownValidationInputResponse : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataBoxValidationInputResult)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - DataBoxValidationInputResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataBoxValidationInputResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataBoxValidationInputResult(document.RootElement, options); - } - - internal static UnknownValidationInputResponse DeserializeUnknownValidationInputResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - DataBoxValidationInputDiscriminator validationType = default; - ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("validationType"u8)) - { - validationType = property.Value.GetString().ToDataBoxValidationInputDiscriminator(); - continue; - } - if (property.NameEquals("error"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerDataBoxContext.Default); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownValidationInputResponse(validationType, error, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); - default: - throw new FormatException($"The model {nameof(DataBoxValidationInputResult)} does not support writing '{options.Format}' format."); - } - } - - DataBoxValidationInputResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDataBoxValidationInputResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DataBoxValidationInputResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputResponse.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputResponse.cs deleted file mode 100644 index b7cf97ec01ea..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationInputResponse.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.DataBox.Models -{ - /// Unknown version of DataBoxValidationInputResult. - internal partial class UnknownValidationInputResponse : DataBoxValidationInputResult - { - /// Initializes a new instance of . - /// Identifies the type of validation response. - /// Error code and message of validation response. - /// Keeps track of any properties unknown to the library. - internal UnknownValidationInputResponse(DataBoxValidationInputDiscriminator validationType, ResponseError error, IDictionary serializedAdditionalRawData) : base(validationType, error, serializedAdditionalRawData) - { - ValidationType = validationType; - } - - /// Initializes a new instance of for deserialization. - internal UnknownValidationInputResponse() - { - } - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationRequest.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationRequest.Serialization.cs deleted file mode 100644 index b20d68713ef6..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationRequest.Serialization.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.DataBox.Models -{ - internal partial class UnknownValidationRequest : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataBoxValidationContent)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - } - - DataBoxValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataBoxValidationContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataBoxValidationContent(document.RootElement, options); - } - - internal static UnknownValidationRequest DeserializeUnknownValidationRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string validationCategory = "Unknown"; - IList individualRequestDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("validationCategory"u8)) - { - validationCategory = property.Value.GetString(); - continue; - } - if (property.NameEquals("individualRequestDetails"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(DataBoxValidationInputContent.DeserializeDataBoxValidationInputContent(item, options)); - } - individualRequestDetails = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownValidationRequest(validationCategory, individualRequestDetails, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerDataBoxContext.Default); - default: - throw new FormatException($"The model {nameof(DataBoxValidationContent)} does not support writing '{options.Format}' format."); - } - } - - DataBoxValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDataBoxValidationContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DataBoxValidationContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationRequest.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationRequest.cs deleted file mode 100644 index 6331280a6888..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UnknownValidationRequest.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.DataBox.Models -{ - /// Unknown version of DataBoxValidationContent. - internal partial class UnknownValidationRequest : DataBoxValidationContent - { - /// Initializes a new instance of . - /// Identify the nature of validation. - /// - /// List of request details contain validationType and its request as key and value respectively. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , , and . - /// - /// Keeps track of any properties unknown to the library. - internal UnknownValidationRequest(string validationCategory, IList individualRequestDetails, IDictionary serializedAdditionalRawData) : base(validationCategory, individualRequestDetails, serializedAdditionalRawData) - { - ValidationCategory = validationCategory ?? "Unknown"; - } - - /// Initializes a new instance of for deserialization. - internal UnknownValidationRequest() - { - } - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.Serialization.cs index edc6a8a86cad..66e79842a5d7 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.Serialization.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DataBox; namespace Azure.ResourceManager.DataBox.Models { - public partial class UpdateJobDetails : IUtf8JsonSerializable, IJsonModel + /// Job details for update. + public partial class UpdateJobDetails : 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, ModelReaderWriter /// 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(UpdateJobDetails)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ContactDetails)) { writer.WritePropertyName("contactDetails"u8); @@ -64,15 +64,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("returnToCustomerPackageDetails"u8); writer.WriteObjectValue(ReturnToCustomerPackageDetails, 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); } @@ -81,22 +81,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - UpdateJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + UpdateJobDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpdateJobDetails 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(UpdateJobDetails)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeUpdateJobDetails(document.RootElement, options); } - internal static UpdateJobDetails DeserializeUpdateJobDetails(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpdateJobDetails DeserializeUpdateJobDetails(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -107,70 +112,68 @@ internal static UpdateJobDetails DeserializeUpdateJobDetails(JsonElement element DataBoxOrderPreferences preferences = default; DataBoxKeyEncryptionKey keyEncryptionKey = default; PackageCarrierDetails returnToCustomerPackageDetails = 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("contactDetails"u8)) + if (prop.NameEquals("contactDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(property.Value, options); + contactDetails = DataBoxContactDetails.DeserializeDataBoxContactDetails(prop.Value, options); continue; } - if (property.NameEquals("shippingAddress"u8)) + if (prop.NameEquals("shippingAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(property.Value, options); + shippingAddress = DataBoxShippingAddress.DeserializeDataBoxShippingAddress(prop.Value, options); continue; } - if (property.NameEquals("reverseShippingDetails"u8)) + if (prop.NameEquals("reverseShippingDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(property.Value, options); + reverseShippingDetails = ReverseShippingDetails.DeserializeReverseShippingDetails(prop.Value, options); continue; } - if (property.NameEquals("preferences"u8)) + if (prop.NameEquals("preferences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(property.Value, options); + preferences = DataBoxOrderPreferences.DeserializeDataBoxOrderPreferences(prop.Value, options); continue; } - if (property.NameEquals("keyEncryptionKey"u8)) + if (prop.NameEquals("keyEncryptionKey"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(property.Value, options); + keyEncryptionKey = DataBoxKeyEncryptionKey.DeserializeDataBoxKeyEncryptionKey(prop.Value, options); continue; } - if (property.NameEquals("returnToCustomerPackageDetails"u8)) + if (prop.NameEquals("returnToCustomerPackageDetails"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - returnToCustomerPackageDetails = PackageCarrierDetails.DeserializePackageCarrierDetails(property.Value, options); + returnToCustomerPackageDetails = PackageCarrierDetails.DeserializePackageCarrierDetails(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 UpdateJobDetails( contactDetails, shippingAddress, @@ -178,13 +181,16 @@ internal static UpdateJobDetails DeserializeUpdateJobDetails(JsonElement element preferences, keyEncryptionKey, returnToCustomerPackageDetails, - 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": @@ -194,15 +200,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - UpdateJobDetails 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. + UpdateJobDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpdateJobDetails 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 DeserializeUpdateJobDetails(document.RootElement, options); } default: @@ -210,6 +221,7 @@ UpdateJobDetails IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.cs index d6682f789855..22534bd9ecde 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobDetails.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.DataBox.Models /// Job details for update. public partial class UpdateJobDetails { - /// - /// 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 UpdateJobDetails() @@ -57,8 +28,8 @@ public UpdateJobDetails() /// Preferences related to the order. /// Key encryption key for the job. /// Return package details of job. - /// Keeps track of any properties unknown to the library. - internal UpdateJobDetails(DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, ReverseShippingDetails reverseShippingDetails, DataBoxOrderPreferences preferences, DataBoxKeyEncryptionKey keyEncryptionKey, PackageCarrierDetails returnToCustomerPackageDetails, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal UpdateJobDetails(DataBoxContactDetails contactDetails, DataBoxShippingAddress shippingAddress, ReverseShippingDetails reverseShippingDetails, DataBoxOrderPreferences preferences, DataBoxKeyEncryptionKey keyEncryptionKey, PackageCarrierDetails returnToCustomerPackageDetails, IDictionary additionalBinaryDataProperties) { ContactDetails = contactDetails; ShippingAddress = shippingAddress; @@ -66,19 +37,24 @@ internal UpdateJobDetails(DataBoxContactDetails contactDetails, DataBoxShippingA Preferences = preferences; KeyEncryptionKey = keyEncryptionKey; ReturnToCustomerPackageDetails = returnToCustomerPackageDetails; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Contact details for notification and shipping. public DataBoxContactDetails ContactDetails { get; set; } + /// Shipping address of the customer. public DataBoxShippingAddress ShippingAddress { get; set; } + /// Reverse Shipping Address and contact details for a job. public ReverseShippingDetails ReverseShippingDetails { get; set; } + /// Preferences related to the order. public DataBoxOrderPreferences Preferences { get; set; } + /// Key encryption key for the job. public DataBoxKeyEncryptionKey KeyEncryptionKey { get; set; } + /// Return package details of job. public PackageCarrierDetails ReturnToCustomerPackageDetails { get; set; } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobProperties.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobProperties.Serialization.cs new file mode 100644 index 000000000000..9bd244f60bd0 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobProperties.Serialization.cs @@ -0,0 +1,145 @@ +// 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.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Job Properties for update. + internal partial class UpdateJobProperties : 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(UpdateJobProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteObjectValue(Details, 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + UpdateJobProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpdateJobProperties 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(UpdateJobProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateJobProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpdateJobProperties DeserializeUpdateJobProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpdateJobDetails details = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + details = UpdateJobDetails.DeserializeUpdateJobDetails(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpdateJobProperties(details, 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, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(UpdateJobProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + UpdateJobProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpdateJobProperties 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 DeserializeUpdateJobProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateJobProperties)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobProperties.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobProperties.cs new file mode 100644 index 000000000000..9e1595cf2c1d --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/UpdateJobProperties.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.DataBox.Models +{ + /// Job Properties for update. + internal partial class UpdateJobProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public UpdateJobProperties() + { + } + + /// Initializes a new instance of . + /// Details of a job to be updated. + /// Keeps track of any properties unknown to the library. + internal UpdateJobProperties(UpdateJobDetails details, IDictionary additionalBinaryDataProperties) + { + Details = details; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Details of a job to be updated. + public UpdateJobDetails Details { get; set; } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ValidationResponseProperties.Serialization.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ValidationResponseProperties.Serialization.cs new file mode 100644 index 000000000000..baced4765066 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ValidationResponseProperties.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Properties of pre job creation validation response. + internal partial class ValidationResponseProperties : 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(ValidationResponseProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToSerialString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(IndividualResponseDetails)) + { + writer.WritePropertyName("individualResponseDetails"u8); + writer.WriteStartArray(); + foreach (DataBoxValidationInputResult item in IndividualResponseDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + 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. + ValidationResponseProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ValidationResponseProperties 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(ValidationResponseProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeValidationResponseProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ValidationResponseProperties DeserializeValidationResponseProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OverallValidationStatus? status = default; + IReadOnlyList individualResponseDetails = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = prop.Value.GetString().ToOverallValidationStatus(); + continue; + } + if (prop.NameEquals("individualResponseDetails"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DataBoxValidationInputResult.DeserializeDataBoxValidationInputResult(item, options)); + } + individualResponseDetails = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ValidationResponseProperties(status, individualResponseDetails ?? new ChangeTrackingList(), 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, AzureResourceManagerDataBoxContext.Default); + default: + throw new FormatException($"The model {nameof(ValidationResponseProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ValidationResponseProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ValidationResponseProperties 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 DeserializeValidationResponseProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ValidationResponseProperties)} 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/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ValidationResponseProperties.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ValidationResponseProperties.cs new file mode 100644 index 000000000000..0922c4c3fccb --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/Models/ValidationResponseProperties.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.DataBox; + +namespace Azure.ResourceManager.DataBox.Models +{ + /// Properties of pre job creation validation response. + internal partial class ValidationResponseProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal ValidationResponseProperties() + { + IndividualResponseDetails = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Overall validation status. + /// List of response details contain validationType and its response as key and value respectively. + /// Keeps track of any properties unknown to the library. + internal ValidationResponseProperties(OverallValidationStatus? status, IReadOnlyList individualResponseDetails, IDictionary additionalBinaryDataProperties) + { + Status = status; + IndividualResponseDetails = individualResponseDetails; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Overall validation status. + public OverallValidationStatus? Status { get; } + + /// List of response details contain validationType and its response as key and value respectively. + public IReadOnlyList IndividualResponseDetails { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ProviderConstants.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ProviderConstants.cs index 58bd8c57ab0d..2f1ac37514ec 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ProviderConstants.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.DataBox { - 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/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/DataBoxClientRestOperations.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/DataBoxClientRestOperations.cs new file mode 100644 index 000000000000..741bede8a817 --- /dev/null +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/DataBoxClientRestOperations.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DataBox +{ + internal partial class DataBoxClient + { + private readonly string _apiVersion; + private readonly Uri _endpoint; + + /// 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. + /// The API version to use for this client. + public DataBoxClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// Initializes a new instance of DataBoxClient for mocking. + protected DataBoxClient() + { + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateMitigateRequest(string subscriptionId, string resourceGroupName, string jobName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder 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.DataBox/jobs/", false); + uri.AppendPath(jobName, true); + uri.AppendPath("/mitigate", false); + uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Content = content; + return message; + } + } +} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/DataBoxRestOperations.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/DataBoxRestOperations.cs deleted file mode 100644 index b30cb27230d6..000000000000 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/DataBoxRestOperations.cs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.DataBox.Models; - -namespace Azure.ResourceManager.DataBox -{ - internal partial class DataBoxRestOperations - { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _apiVersion; - - /// Initializes a new instance of DataBoxRestOperations. - /// 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 DataBoxRestOperations(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-07-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateMitigateRequestUri(string subscriptionId, string resourceGroupName, string jobName, MitigateJobContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendPath("/mitigate", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateMitigateRequest(string subscriptionId, string resourceGroupName, string jobName, MitigateJobContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendPath("/mitigate", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// Request to mitigate for a given job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Mitigation Request. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task MitigateAsync(string subscriptionId, string resourceGroupName, string jobName, MitigateJobContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateMitigateRequest(subscriptionId, resourceGroupName, jobName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Request to mitigate for a given job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Mitigation Request. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Mitigate(string subscriptionId, string resourceGroupName, string jobName, MitigateJobContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateMitigateRequest(subscriptionId, resourceGroupName, jobName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/JobResourcesRestOperations.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/JobResourcesRestOperations.cs index c9c2b910462e..a549d68ae104 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/JobResourcesRestOperations.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/JobResourcesRestOperations.cs @@ -6,60 +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.DataBox.Models; namespace Azure.ResourceManager.DataBox { - internal partial class JobResourcesRestOperations + internal partial class JobResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of JobResourcesRestOperations. - /// 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 JobResourcesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of JobResources for mocking. + protected JobResources() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-07-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string jobName, string expand) + /// Initializes a new instance of JobResources. + /// 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 JobResources(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.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendQuery("api-version", _apiVersion, true); - if (expand != null) - { - uri.AppendQuery("$expand", expand, true); - } - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string jobName, string expand) + /// 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 jobName, string expand, 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); @@ -72,96 +56,17 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou { uri.AppendQuery("$expand", expand, 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 information about the specified job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// $expand is supported on details parameter for job, which provides details on the job stages. - /// 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 jobName, string expand = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, jobName, expand); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxJobData.DeserializeDataBoxJobData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DataBoxJobData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets information about the specified job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// $expand is supported on details parameter for job, which provides details on the job stages. - /// 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 jobName, string expand = null, CancellationToken cancellationToken = default) + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string jobName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, jobName, expand); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxJobData.DeserializeDataBoxJobData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DataBoxJobData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobData data) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobData data) - { - 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); @@ -170,90 +75,19 @@ internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); uri.AppendPath(jobName, 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; } - /// Creates a new job with the specified parameters. Existing job cannot be updated with this API and should instead be updated with the Update job API. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Job details from request body. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, jobName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Creates a new job with the specified parameters. Existing job cannot be updated with this API and should instead be updated with the Update job API. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Job details from request body. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Create(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, jobName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobPatch patch, 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.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobPatch patch, string ifMatch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string jobName, RequestContent content, ETag? ifMatch, RequestContext context) { - 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); @@ -262,96 +96,23 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); uri.AppendPath(jobName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; + request.Method = RequestMethod.Patch; 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(patch, ModelSerializationExtensions.WireOptions); + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Updates the properties of an existing job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Job update parameters from request body. - /// Defines the If-Match condition. The patch will be performed only if the ETag of the job on the server matches this value. - /// 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 jobName, DataBoxJobPatch patch, string ifMatch = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, jobName, patch, ifMatch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Updates the properties of an existing job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Job update parameters from request body. - /// Defines the If-Match condition. The patch will be performed only if the ETag of the job on the server matches this value. - /// 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 jobName, DataBoxJobPatch patch, string ifMatch = null, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string jobName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, jobName, patch, ifMatch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string jobName) - { - 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.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string jobName) - { - 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); @@ -360,86 +121,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); uri.AppendPath(jobName, 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 a job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// 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 jobName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, jobName); - 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); - } - } - - /// Deletes a job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// 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 jobName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, jobName); - _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 CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName, string skipToken) + internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, string resourceGroupName, string skipToken, 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.DataBox/jobs", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (skipToken != null) - { - uri.AppendQuery("$skipToken", skipToken, true); - } - return uri; - } - - internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName, string skipToken) - { - 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); @@ -451,89 +142,29 @@ internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, str { uri.AppendQuery("$skipToken", skipToken, 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; } - /// Lists all the jobs available under 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. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// 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, string skipToken = null, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string skipToken, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, skipToken); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists all the jobs available under 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. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// 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, string skipToken = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName, skipToken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string skipToken) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.DataBox/jobs", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (skipToken != null) - { - uri.AppendQuery("$skipToken", skipToken, 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 CreateListRequest(string subscriptionId, string skipToken) + internal HttpMessage CreateGetAllRequest(string subscriptionId, string skipToken, 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); @@ -543,85 +174,29 @@ internal HttpMessage CreateListRequest(string subscriptionId, string skipToken) { uri.AppendQuery("$skipToken", skipToken, 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; } - /// Lists all the jobs available under the subscription. - /// The ID of the target subscription. The value must be an UUID. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, string skipToken = null, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, string skipToken, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId, skipToken); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists all the jobs available under the subscription. - /// The ID of the target subscription. The value must be an UUID. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, string skipToken = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId, skipToken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateBookShipmentPickUpRequestUri(string subscriptionId, string resourceGroupName, string jobName, ShipmentPickUpContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendPath("/bookShipmentPickUp", 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 CreateBookShipmentPickUpRequest(string subscriptionId, string resourceGroupName, string jobName, ShipmentPickUpContent content) + internal HttpMessage CreateBookShipmentPickUpRequest(string subscriptionId, string resourceGroupName, string jobName, 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); @@ -631,99 +206,19 @@ internal HttpMessage CreateBookShipmentPickUpRequest(string subscriptionId, stri uri.AppendPath(jobName, true); uri.AppendPath("/bookShipmentPickUp", 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; } - /// Book shipment pick up. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Details of shipment pick up request. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> BookShipmentPickUpAsync(string subscriptionId, string resourceGroupName, string jobName, ShipmentPickUpContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateBookShipmentPickUpRequest(subscriptionId, resourceGroupName, jobName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxShipmentPickUpResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxShipmentPickUpResult.DeserializeDataBoxShipmentPickUpResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Book shipment pick up. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Details of shipment pick up request. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response BookShipmentPickUp(string subscriptionId, string resourceGroupName, string jobName, ShipmentPickUpContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateBookShipmentPickUpRequest(subscriptionId, resourceGroupName, jobName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxShipmentPickUpResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxShipmentPickUpResult.DeserializeDataBoxShipmentPickUpResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCancelRequestUri(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobCancellationReason cancellationReason) - { - 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.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendPath("/cancel", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCancelRequest(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobCancellationReason cancellationReason) + internal HttpMessage CreateCancelRequest(string subscriptionId, string resourceGroupName, string jobName, 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); @@ -733,88 +228,18 @@ internal HttpMessage CreateCancelRequest(string subscriptionId, string resourceG uri.AppendPath(jobName, true); uri.AppendPath("/cancel", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(cancellationReason, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// CancelJob. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Reason for cancellation. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task CancelAsync(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobCancellationReason cancellationReason, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(cancellationReason, nameof(cancellationReason)); - - using var message = CreateCancelRequest(subscriptionId, resourceGroupName, jobName, cancellationReason); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// CancelJob. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Reason for cancellation. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Cancel(string subscriptionId, string resourceGroupName, string jobName, DataBoxJobCancellationReason cancellationReason, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(cancellationReason, nameof(cancellationReason)); - - using var message = CreateCancelRequest(subscriptionId, resourceGroupName, jobName, cancellationReason); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListCredentialsRequestUri(string subscriptionId, string resourceGroupName, string jobName) + internal HttpMessage CreateGetCredentialsRequest(string subscriptionId, string resourceGroupName, string jobName, 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.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendPath("/listCredentials", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListCredentialsRequest(string subscriptionId, string resourceGroupName, string jobName) - { - 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); @@ -824,91 +249,29 @@ internal HttpMessage CreateListCredentialsRequest(string subscriptionId, string uri.AppendPath(jobName, true); uri.AppendPath("/listCredentials", 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; } - /// This method gets the unencrypted secrets related to the job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListCredentialsAsync(string subscriptionId, string resourceGroupName, string jobName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateListCredentialsRequest(subscriptionId, resourceGroupName, jobName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - UnencryptedCredentialsList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = UnencryptedCredentialsList.DeserializeUnencryptedCredentialsList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This method gets the unencrypted secrets related to the job. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListCredentials(string subscriptionId, string resourceGroupName, string jobName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetCredentialsRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string jobName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateListCredentialsRequest(subscriptionId, resourceGroupName, jobName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - UnencryptedCredentialsList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = UnencryptedCredentialsList.DeserializeUnencryptedCredentialsList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateMarkDevicesShippedRequestUri(string subscriptionId, string resourceGroupName, string jobName, MarkDevicesShippedContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DataBox/jobs/", false); - uri.AppendPath(jobName, true); - uri.AppendPath("/markDevicesShipped", 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 CreateMarkDevicesShippedRequest(string subscriptionId, string resourceGroupName, string jobName, MarkDevicesShippedContent content) + internal HttpMessage CreateMarkDevicesShippedRequest(string subscriptionId, string resourceGroupName, string jobName, 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); @@ -918,309 +281,13 @@ internal HttpMessage CreateMarkDevicesShippedRequest(string subscriptionId, stri uri.AppendPath(jobName, true); uri.AppendPath("/markDevicesShipped", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// Request to mark devices for a given job as shipped. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Mark Devices Shipped Request. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task MarkDevicesShippedAsync(string subscriptionId, string resourceGroupName, string jobName, MarkDevicesShippedContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateMarkDevicesShippedRequest(subscriptionId, resourceGroupName, jobName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Request to mark devices for a given job as shipped. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// Mark Devices Shipped Request. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response MarkDevicesShipped(string subscriptionId, string resourceGroupName, string jobName, MarkDevicesShippedContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateMarkDevicesShippedRequest(subscriptionId, resourceGroupName, jobName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string skipToken) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string skipToken) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists all the jobs available under 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. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// 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, string skipToken = null, 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, skipToken); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists all the jobs available under 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. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// 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, string skipToken = null, 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, skipToken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string skipToken) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string skipToken) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists all the jobs available under the subscription. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string skipToken = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, skipToken); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists all the jobs available under the subscription. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// $skipToken is supported on Get list of jobs, which provides the next page in the list of jobs. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, string skipToken = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId, skipToken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxJobListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxJobListResult.DeserializeDataBoxJobListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListCredentialsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string jobName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListCredentialsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string jobName) - { - 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("Content-Type", "application/json"); + request.Content = content; return message; } - - /// This method gets the unencrypted secrets related to the job. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListCredentialsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string jobName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateListCredentialsNextPageRequest(nextLink, subscriptionId, resourceGroupName, jobName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - UnencryptedCredentialsList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = UnencryptedCredentialsList.DeserializeUnencryptedCredentialsList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This method gets the unencrypted secrets related to the job. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the job Resource within the specified resource group. job names must be between 3 and 24 characters in length and use any alphanumeric and underscore only. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListCredentialsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string jobName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(jobName, nameof(jobName)); - - using var message = CreateListCredentialsNextPageRequest(nextLink, subscriptionId, resourceGroupName, jobName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - UnencryptedCredentialsList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = UnencryptedCredentialsList.DeserializeUnencryptedCredentialsList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/ServiceOperationGroupRestOperations.cs b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/ServiceOperationGroupRestOperations.cs index 3d9af51a5964..f5b39b46078e 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/ServiceOperationGroupRestOperations.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/src/Generated/RestOperations/ServiceOperationGroupRestOperations.cs @@ -6,696 +6,177 @@ #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.DataBox.Models; namespace Azure.ResourceManager.DataBox { - internal partial class ServiceOperationGroupRestOperations + internal partial class ServiceOperationGroup { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of ServiceOperationGroupRestOperations. - /// 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 ServiceOperationGroupRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of ServiceOperationGroup for mocking. + protected ServiceOperationGroup() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-07-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRegionConfigurationRequestUri(string subscriptionId, AzureLocation location, RegionConfigurationContent content) + /// Initializes a new instance of ServiceOperationGroup. + /// 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 ServiceOperationGroup(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.DataBox/locations/", false); - uri.AppendPath(location, true); - uri.AppendPath("/regionConfiguration", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRegionConfigurationRequest(string subscriptionId, AzureLocation location, RegionConfigurationContent 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 CreateGetRegionConfigurationRequest(string subscriptionId, AzureLocation location, 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.DataBox/locations/", false); - uri.AppendPath(location, true); + uri.AppendPath(location.ToString(), true); uri.AppendPath("/regionConfiguration", 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; } - /// This API provides configuration details specific to given region/location at Subscription level. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Azure region. - /// 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> GetRegionConfigurationAsync(string subscriptionId, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) + internal HttpMessage CreateValidateAddressRequest(string subscriptionId, AzureLocation location, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetRegionConfigurationRequest(subscriptionId, location, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - RegionConfigurationResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = RegionConfigurationResult.DeserializeRegionConfigurationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This API provides configuration details specific to given region/location at Subscription level. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Azure region. - /// The request body. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response GetRegionConfiguration(string subscriptionId, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetRegionConfigurationRequest(subscriptionId, location, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - RegionConfigurationResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = RegionConfigurationResult.DeserializeRegionConfigurationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateValidateAddressRequestUri(string subscriptionId, AzureLocation location, DataBoxValidateAddressContent content) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/providers/Microsoft.DataBox/locations/", false); - uri.AppendPath(location, true); - uri.AppendPath("/validateAddress", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateValidateAddressRequest(string subscriptionId, AzureLocation location, DataBoxValidateAddressContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.DataBox/locations/", false); - uri.AppendPath(location, true); + uri.AppendPath(location.ToString(), true); uri.AppendPath("/validateAddress", 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; } - /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Azure region. - /// 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> ValidateAddressAsync(string subscriptionId, AzureLocation location, DataBoxValidateAddressContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateAddressRequest(subscriptionId, location, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AddressValidationOutput value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AddressValidationOutput.DeserializeAddressValidationOutput(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// [DEPRECATED NOTICE: This operation will soon be removed]. This method validates the customer shipping address and provide alternate addresses if any. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Azure region. - /// The request body. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ValidateAddress(string subscriptionId, AzureLocation location, DataBoxValidateAddressContent content, CancellationToken cancellationToken = default) + internal HttpMessage CreateValidateInputsRequest(string subscriptionId, AzureLocation location, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateAddressRequest(subscriptionId, location, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AddressValidationOutput value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AddressValidationOutput.DeserializeAddressValidationOutput(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateValidateInputsRequestUri(string subscriptionId, AzureLocation location, DataBoxValidationContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.DataBox/locations/", false); - uri.AppendPath(location, true); - uri.AppendPath("/validateInputs", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateValidateInputsRequest(string subscriptionId, AzureLocation location, DataBoxValidationContent content) - { - 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.DataBox/locations/", false); - uri.AppendPath(location, true); + uri.AppendPath(location.ToString(), true); uri.AppendPath("/validateInputs", 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; } - /// This method does all necessary pre-job creation validation under subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Azure region. - /// 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> ValidateInputsAsync(string subscriptionId, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetAvailableSkusRequest(string subscriptionId, string resourceGroupName, AzureLocation location, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateInputsRequest(subscriptionId, location, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxValidationResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxValidationResult.DeserializeDataBoxValidationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This method does all necessary pre-job creation validation under subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Azure region. - /// The request body. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ValidateInputs(string subscriptionId, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateInputsRequest(subscriptionId, location, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxValidationResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxValidationResult.DeserializeDataBoxValidationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetAvailableSkusRequestUri(string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DataBox/locations/", false); - uri.AppendPath(location, true); - uri.AppendPath("/availableSkus", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetAvailableSkusRequest(string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content) - { - 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("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DataBox/locations/", false); - uri.AppendPath(location, true); + uri.AppendPath(location.ToString(), true); uri.AppendPath("/availableSkus", 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; } - /// This method provides the list of available skus for the given subscription, resource group and location. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure region. - /// Filters for showing the available skus. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> GetAvailableSkusAsync(string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetAvailableSkusRequest(subscriptionId, resourceGroupName, location, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AvailableSkusResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AvailableSkusResult.DeserializeAvailableSkusResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This method provides the list of available skus for the given subscription, resource group and location. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure region. - /// Filters for showing the available skus. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response GetAvailableSkus(string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetAvailableSkusRequest(subscriptionId, resourceGroupName, location, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AvailableSkusResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AvailableSkusResult.DeserializeAvailableSkusResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetRegionConfigurationRequestUri(string subscriptionId, string resourceGroupName, AzureLocation location, RegionConfigurationContent content) + internal HttpMessage CreateNextGetAvailableSkusRequest(Uri nextPage, string subscriptionId, string resourceGroupName, AzureLocation location, 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.DataBox/locations/", false); - uri.AppendPath(location, true); - uri.AppendPath("/regionConfiguration", 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 CreateGetRegionConfigurationRequest(string subscriptionId, string resourceGroupName, AzureLocation location, RegionConfigurationContent content) + internal HttpMessage CreateGetRegionConfigurationRequest(string subscriptionId, string resourceGroupName, AzureLocation location, 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("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DataBox/locations/", false); - uri.AppendPath(location, true); + uri.AppendPath(location.ToString(), true); uri.AppendPath("/regionConfiguration", 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; } - /// This API provides configuration details specific to given region/location at Resource group level. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure region. - /// Request body to get the configuration for the region at resource group level. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> GetRegionConfigurationAsync(string subscriptionId, string resourceGroupName, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) + internal HttpMessage CreateValidateInputsRequest(string subscriptionId, string resourceGroupName, AzureLocation location, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetRegionConfigurationRequest(subscriptionId, resourceGroupName, location, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - RegionConfigurationResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = RegionConfigurationResult.DeserializeRegionConfigurationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This API provides configuration details specific to given region/location at Resource group level. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure region. - /// Request body to get the configuration for the region at resource group level. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response GetRegionConfiguration(string subscriptionId, string resourceGroupName, AzureLocation location, RegionConfigurationContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetRegionConfigurationRequest(subscriptionId, resourceGroupName, location, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - RegionConfigurationResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = RegionConfigurationResult.DeserializeRegionConfigurationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateValidateInputsRequestUri(string subscriptionId, string resourceGroupName, AzureLocation location, DataBoxValidationContent content) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder 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.DataBox/locations/", false); - uri.AppendPath(location, true); + uri.AppendPath(location.ToString(), true); uri.AppendPath("/validateInputs", false); uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateValidateInputsRequest(string subscriptionId, string resourceGroupName, AzureLocation location, DataBoxValidationContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DataBox/locations/", false); - uri.AppendPath(location, true); - uri.AppendPath("/validateInputs", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// This method does all necessary pre-job creation validation under 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 name of the Azure region. - /// Inputs of the customer. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ValidateInputsAsync(string subscriptionId, string resourceGroupName, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateInputsRequest(subscriptionId, resourceGroupName, location, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DataBoxValidationResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DataBoxValidationResult.DeserializeDataBoxValidationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This method does all necessary pre-job creation validation under 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 name of the Azure region. - /// Inputs of the customer. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ValidateInputs(string subscriptionId, string resourceGroupName, AzureLocation location, DataBoxValidationContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateInputsRequest(subscriptionId, resourceGroupName, location, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DataBoxValidationResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DataBoxValidationResult.DeserializeDataBoxValidationResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetAvailableSkusNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateGetAvailableSkusNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + 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("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; return message; } - - /// This method provides the list of available skus for the given subscription, resource group and location. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure region. - /// Filters for showing the available skus. - /// The cancellation token to use. - /// , , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> GetAvailableSkusNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetAvailableSkusNextPageRequest(nextLink, subscriptionId, resourceGroupName, location, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AvailableSkusResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AvailableSkusResult.DeserializeAvailableSkusResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This method provides the list of available skus for the given subscription, resource group and location. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Azure region. - /// Filters for showing the available skus. - /// The cancellation token to use. - /// , , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response GetAvailableSkusNextPage(string nextLink, string subscriptionId, string resourceGroupName, AzureLocation location, AvailableSkusContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateGetAvailableSkusNextPageRequest(nextLink, subscriptionId, resourceGroupName, location, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AvailableSkusResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AvailableSkusResult.DeserializeAvailableSkusResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/tsp-location.yaml b/sdk/databox/Azure.ResourceManager.DataBox/tsp-location.yaml index ae34152df7f6..58666ce2f9d5 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/tsp-location.yaml +++ b/sdk/databox/Azure.ResourceManager.DataBox/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/databox/resource-manager/Microsoft.DataBox/DataBox -commit: c07353d57c4fbbf71dbca35ca187dd9951a99631 +commit: a3f78812e18619f7d92f1430ccb01be4ffec32de repo: Azure/azure-rest-api-specs +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json" \ No newline at end of file