diff --git a/sdk/storage/azure-storage-files-shares/CHANGELOG.md b/sdk/storage/azure-storage-files-shares/CHANGELOG.md index 09a34f107..1f35aad10 100644 --- a/sdk/storage/azure-storage-files-shares/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-shares/CHANGELOG.md @@ -10,6 +10,8 @@ ### Other Changes +- Deprecated enum `LeaseDuration`, use `LeaseDurationType` instead. + ## 12.2.0 (2021-09-08) ### Breaking Changes diff --git a/sdk/storage/azure-storage-files-shares/CMakeLists.txt b/sdk/storage/azure-storage-files-shares/CMakeLists.txt index f7a4df569..a6d92db5f 100644 --- a/sdk/storage/azure-storage-files-shares/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-shares/CMakeLists.txt @@ -40,12 +40,11 @@ endif() set( AZURE_STORAGE_FILES_SHARES_HEADER - inc/azure/storage/files/shares/protocol/share_rest_client.hpp inc/azure/storage/files/shares/dll_import_export.hpp + inc/azure/storage/files/shares/rest_client.hpp inc/azure/storage/files/shares/share_client.hpp inc/azure/storage/files/shares/share_constants.hpp inc/azure/storage/files/shares/share_directory_client.hpp - inc/azure/storage/files/shares/share_file_attributes.hpp inc/azure/storage/files/shares/share_file_client.hpp inc/azure/storage/files/shares/share_lease_client.hpp inc/azure/storage/files/shares/share_options.hpp @@ -58,13 +57,12 @@ set( set( AZURE_STORAGE_FILES_SHARES_SOURCE src/private/package_version.hpp + src/rest_client.cpp src/share_client.cpp src/share_directory_client.cpp - src/share_file_attributes.cpp src/share_file_client.cpp src/share_lease_client.cpp src/share_responses.cpp - src/share_rest_client.cpp src/share_sas_builder.cpp src/share_service_client.cpp ) diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp index 296c16098..497856650 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp @@ -8,6 +8,7 @@ #pragma once +#include "azure/storage/common/storage_exception.hpp" #include "azure/storage/files/shares/dll_import_export.hpp" #include "azure/storage/files/shares/share_client.hpp" #include "azure/storage/files/shares/share_directory_client.hpp" diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/protocol/share_rest_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/protocol/share_rest_client.hpp deleted file mode 100644 index 177c7a9fc..000000000 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/protocol/share_rest_client.hpp +++ /dev/null @@ -1,8334 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#pragma once - -#include "azure/storage/files/shares/dll_import_export.hpp" -#include "azure/storage/files/shares/share_file_attributes.hpp" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* cSpell:disable */ - -namespace Azure { namespace Storage { namespace Files { namespace Shares { - - namespace Models { - - /** - * @brief The common HTTP headers. - */ - struct FileHttpHeaders final - { - - /** - * The cache control of the content. - */ - std::string CacheControl; - - /** - * The disposition of the content. - */ - std::string ContentDisposition; - - /** - * The encoding of the content. - */ - std::string ContentEncoding; - - /** - * The language of the content. - */ - std::string ContentLanguage; - - /** - * The type of the content. - */ - std::string ContentType; - - /** - * The hash of the content. - */ - Storage::ContentHash ContentHash; - }; - - /** - * @brief The SMB related properties of the file. - */ - struct FileSmbProperties final - { - /** - * Permission key of the directory or file. - */ - Azure::Nullable PermissionKey; - - /** - * If specified, the provided file attributes shall be set. Default value: - * FileAttribute::Archive for file and FileAttribute::Directory for directory. - * FileAttribute::None can also be specified as default. - */ - FileAttributes Attributes; - - /** - * Creation time for the file/directory. - */ - Azure::Nullable CreatedOn; - - /** - * Last write time for the file/directory. - */ - Azure::Nullable LastWrittenOn; - - /** - * Changed time for the file/directory. - */ - Azure::Nullable ChangedOn; - - /** - * The fileId of the file. - */ - std::string FileId; - - /** - * The parentId of the file - */ - std::string ParentFileId; - }; - - /** - * @brief Specifies the access tier of the share. - */ - class AccessTier final { - public: - AccessTier() = default; - explicit AccessTier(std::string value) : m_value(std::move(value)) {} - bool operator==(const AccessTier& other) const { return m_value == other.m_value; } - bool operator!=(const AccessTier& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier TransactionOptimized; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier Hot; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier Cool; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier Premium; - - private: - std::string m_value; - }; // extensible enum AccessTier - - /** - * @brief Specifies the option to copy file security descriptor from source file or to set it - * using the value which is defined by the header value of x-ms-file-permission or - * x-ms-file-permission-key. - */ - class PermissionCopyMode final { - public: - PermissionCopyMode() = default; - explicit PermissionCopyMode(std::string value) : m_value(std::move(value)) {} - bool operator==(const PermissionCopyMode& other) const { return m_value == other.m_value; } - bool operator!=(const PermissionCopyMode& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static PermissionCopyMode Source; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static PermissionCopyMode Override; - - private: - std::string m_value; - }; // extensible enum PermissionCopyMode - - /** - * @brief Specifies the option include to delete the base share and all of its snapshots. - */ - class DeleteSnapshotsOption final { - public: - DeleteSnapshotsOption() = default; - explicit DeleteSnapshotsOption(std::string value) : m_value(std::move(value)) {} - bool operator==(const DeleteSnapshotsOption& other) const { return m_value == other.m_value; } - bool operator!=(const DeleteSnapshotsOption& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static DeleteSnapshotsOption Include; - - private: - std::string m_value; - }; // extensible enum DeleteSnapshotsOption - - /** - * @brief An Access policy. - */ - struct AccessPolicy final - { - /** - * The date-time the policy is active. - */ - Azure::Nullable StartsOn; - - /** - * The date-time the policy expires. - */ - Azure::Nullable ExpiresOn; - - /** - * The permissions for the ACL policy. - */ - std::string Permission; - }; - - /** - * @brief CORS is an HTTP feature that enables a web application running under one domain to - * access resources in another domain. Web browsers implement a security restriction known as - * same-origin policy that prevents a web page from calling APIs in a different domain; CORS - * provides a secure way to allow one domain (the origin domain) to call APIs in another domain. - */ - struct CorsRule final - { - /** - * The origin domains that are permitted to make a request against the storage service via - * CORS. The origin domain is the domain from which the request originates. Note that the - * origin must be an exact case-sensitive match with the origin that the user age sends to the - * service. You can also use the wildcard character '*' to allow all origin domains to make - * requests via CORS. - */ - std::string AllowedOrigins; - - /** - * The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma - * separated) - */ - std::string AllowedMethods; - - /** - * The request headers that the origin domain may specify on the CORS request. - */ - std::string AllowedHeaders; - - /** - * The response headers that may be sent in the response to the CORS request and exposed by - * the browser to the request issuer. - */ - std::string ExposedHeaders; - - /** - * The maximum amount time that a browser should cache the preflight OPTIONS request. - */ - int32_t MaxAgeInSeconds = int32_t(); - }; - - /** - * @brief A listed directory item. - */ - struct DirectoryItem final - { - /** - * The name of the directory. - */ - std::string Name; - }; - - /** - * @brief The detailed information of the file. - */ - struct FileItemDetails final - { - /** - * Content length of the file. This value may not be up-to-date since an SMB client may have - * modified the file locally. The value of Content-Length may not reflect that fact until the - * handle is closed or the op-lock is broken. To retrieve current property values, call Get - * File Properties. - */ - int64_t FileSize = int64_t(); - }; - - /** - * @brief A listed file item. - */ - struct FileItem final - { - /** - * The name of the file. - */ - std::string Name; - - /** - * The detailed information of the file. - */ - FileItemDetails Details; - }; - - /** - * @brief A listed Azure Storage handle item. - */ - struct HandleItem final - { - /** - * XSMB service handle ID - */ - std::string HandleId; - - /** - * File or directory name including full path starting from share root - */ - std::string Path; - - /** - * FileId uniquely identifies the file or directory. - */ - std::string FileId; - - /** - * ParentId uniquely identifies the parent directory of the object. - */ - std::string ParentId; - - /** - * SMB session ID in context of which the file handle was opened - */ - std::string SessionId; - - /** - * Client IP that opened the handle - */ - std::string ClientIp; - - /** - * Time when the session that previously opened the handle has last been reconnected. (UTC) - */ - DateTime OpenedOn; - - /** - * Time handle was last connected to (UTC) - */ - DateTime LastReconnectedOn; - }; - - /** - * @brief When a file or share is leased, specifies whether the lease is of infinite or fixed - * duration. - */ - class LeaseDuration final { - public: - LeaseDuration() = default; - explicit LeaseDuration(std::string value) : m_value(std::move(value)) {} - bool operator==(const LeaseDuration& other) const { return m_value == other.m_value; } - bool operator!=(const LeaseDuration& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseDuration Infinite; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseDuration Fixed; - - private: - std::string m_value; - }; // extensible enum LeaseDuration - - /** - * @brief Lease state of the file or share. - */ - class LeaseState final { - public: - LeaseState() = default; - explicit LeaseState(std::string value) : m_value(std::move(value)) {} - bool operator==(const LeaseState& other) const { return m_value == other.m_value; } - bool operator!=(const LeaseState& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Available; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Leased; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Expired; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Breaking; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Broken; - - private: - std::string m_value; - }; // extensible enum LeaseState - - /** - * @brief The current lease status of the file or share. - */ - class LeaseStatus final { - public: - LeaseStatus() = default; - explicit LeaseStatus(std::string value) : m_value(std::move(value)) {} - bool operator==(const LeaseStatus& other) const { return m_value == other.m_value; } - bool operator!=(const LeaseStatus& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseStatus Locked; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseStatus Unlocked; - - private: - std::string m_value; - }; // extensible enum LeaseStatus - - /** - * @brief Details of the share properties. - */ - struct ShareItemDetails final - { - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties or metadata updates the last modified time. Operations on files do - * not affect the last modified time of the share. - */ - DateTime LastModified; - - /** - * The ETag contains a value which represents the version of the share, in quotes. - */ - Azure::ETag Etag; - - /** - * The quota of the share in GB - */ - int64_t Quota = int64_t(); - - /** - * Returns the current share provisioned ipos. - */ - Azure::Nullable ProvisionedIops; - - /** - * Returns the current share provisioned ingress in megabytes per second. - */ - Azure::Nullable ProvisionedIngressMBps; - - /** - * Returns the current share provisioned egress in megabytes per second. - */ - Azure::Nullable ProvisionedEgressMBps; - - /** - * Returns the current share next allowed quota downgrade time. - */ - Azure::Nullable NextAllowedQuotaDowngradeTime; - - /** - * The time on which the share was deleted. - */ - Azure::Nullable DeletedOn; - - /** - * The remaining retention days of the share. - */ - int32_t RemainingRetentionDays = int32_t(); - - /** - * The access tier of the share. - */ - Azure::Nullable AccessTier; - - /** - * Returns the last modified time (in UTC) of the access tier of the share. - */ - Azure::Nullable AccessTierChangedOn; - - /** - * Returns the transition state betweeen access tiers, when present. - */ - Azure::Nullable AccessTierTransitionState; - - /** - * The current lease status of the file or share. - */ - Models::LeaseStatus LeaseStatus; - - /** - * Lease state of the file or share. - */ - Models::LeaseState LeaseState; - - /** - * When a file or share is leased, specifies whether the lease is of infinite or fixed - * duration. - */ - Models::LeaseDuration LeaseDuration; - }; - - /** - * @brief A listed Azure Storage share item. - */ - struct ShareItem final - { - /** - * The name of the share. - */ - std::string Name; - - /** - * The snapshot of the share. - */ - std::string Snapshot; - - /** - * If the share is deleted. - */ - bool Deleted = bool(); - - /** - * The version string. - */ - std::string Version; - - /** - * Details of the share properties. - */ - ShareItemDetails Details; - - /** - * The metadata of the share. - */ - Storage::Metadata Metadata; - }; - - /** - * @brief The retention policy. - */ - struct RetentionPolicy final - { - /** - * Indicates whether a retention policy is enabled for the File service. If false, metrics - * data is retained, and the user is responsible for deleting it. - */ - bool Enabled = bool(); - - /** - * Indicates the number of days that metrics data should be retained. All data older than this - * value will be deleted. Metrics data is deleted on a best-effort basis after the retention - * period expires. - */ - Azure::Nullable Days; - }; - - /** - * @brief Storage Analytics metrics for file service. - */ - struct Metrics final - { - /** - * The version of Storage Analytics to configure. - */ - std::string Version; - - /** - * Indicates whether metrics are enabled for the File service. - */ - bool Enabled = bool(); - - /** - * Indicates whether metrics should generate summary statistics for called API operations. - */ - Azure::Nullable IncludeApis; - - /** - * The retention policy. - */ - Models::RetentionPolicy RetentionPolicy; - }; - - /** - * @brief Settings for SMB multichannel - */ - struct SmbMultichannel final - { - /** - * If SMB multichannel is enabled. - */ - bool Enabled = bool(); - }; - - /** - * @brief Settings for SMB protocol. - */ - struct SmbSettings final - { - /** - * Settings for SMB Multichannel. - */ - SmbMultichannel Multichannel; - }; - - /** - * @brief Protocol settings - */ - struct ProtocolSettings final - { - /** - * Settings for SMB protocol. - */ - SmbSettings Settings; - }; - - /** - * @brief Signed identifier. - */ - struct SignedIdentifier final - { - /** - * A unique ID. - */ - std::string Id; - - /** - * The access policy. - */ - AccessPolicy Policy; - }; - - /** - * @brief Storage service properties. - */ - struct ShareServiceProperties final - { - /** - * A summary of request statistics grouped by API in hourly aggregates for files. - */ - Metrics HourMetrics; - - /** - * A summary of request statistics grouped by API in minute aggregates for files. - */ - Metrics MinuteMetrics; - - /** - * The set of CORS rules. - */ - std::vector Cors; - - /** - * Protocol settings - */ - Azure::Nullable Protocol; - }; - - /** - * @brief State of the copy operation identified by 'x-ms-copy-id'. - */ - class CopyStatus final { - public: - CopyStatus() = default; - explicit CopyStatus(std::string value) : m_value(std::move(value)) {} - bool operator==(const CopyStatus& other) const { return m_value == other.m_value; } - bool operator!=(const CopyStatus& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Pending; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Success; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Aborted; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Failed; - - private: - std::string m_value; - }; // extensible enum CopyStatus - - /** - * @brief The serialized return result for operation: SetServiceProperties - */ - struct SetServicePropertiesResult final - { - }; - - /** - * @brief The serialized return result for operation: CreateShare - */ - struct CreateShareResult final - { - - /** - * The ETag contains a value which represents the version of the share, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties or metadata updates the last modified time. Operations on files do - * not affect the last modified time of the share. - */ - DateTime LastModified; - - /** - * If the object is created. - */ - bool Created = true; - }; - - /** - * @brief The serialized return result for operation: GetShareProperties - */ - struct ShareProperties final - { - - /** - * The metadata of the object. - */ - Storage::Metadata Metadata; - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - - /** - * Returns the current share quota in GB. - */ - int64_t Quota = int64_t(); - - /** - * Returns the current share provisioned ipos. - */ - Azure::Nullable ProvisionedIops; - - /** - * Returns the current share provisioned ingress in megabytes per second. - */ - Azure::Nullable ProvisionedIngressMBps; - - /** - * Returns the current share provisioned egress in megabytes per second. - */ - Azure::Nullable ProvisionedEgressMBps; - - /** - * Returns the current share next allowed quota downgrade time. - */ - Azure::Nullable NextAllowedQuotaDowngradeTime; - - /** - * When a file or share is leased, specifies whether the lease is of infinite or fixed - * duration. - */ - Azure::Nullable LeaseDuration; - - /** - * Lease state of the file or share. - */ - Azure::Nullable LeaseState; - - /** - * The current lease status of the file or share. - */ - Azure::Nullable LeaseStatus; - - /** - * Returns the access tier set on the share. - */ - Azure::Nullable AccessTier; - - /** - * Returns the last modified time (in UTC) of the access tier of the share. - */ - Azure::Nullable AccessTierChangedOn; - - /** - * Returns the transition state betweeen access tiers, when present. - */ - Azure::Nullable AccessTierTransitionState; - }; - - /** - * @brief The serialized return result for operation: DeleteShare - */ - struct DeleteShareResult final - { - - /** - * If the object is deleted. - */ - bool Deleted = true; - }; - - /** - * @brief The serialized return result for operation: AcquireLease - */ - struct AcquireLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - - /** - * Uniquely identifies a share's lease - */ - std::string LeaseId; - }; - - /** - * @brief The serialized return result for operation: ReleaseLease - */ - struct ReleaseLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - }; - - /** - * @brief The serialized return result for operation: ChangeLease - */ - struct ChangeLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - - /** - * Uniquely identifies a share's lease - */ - std::string LeaseId; - }; - - /** - * @brief The serialized return result for operation: RenewLease - */ - struct RenewLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - - /** - * Uniquely identifies a share's lease - */ - std::string LeaseId; - }; - - /** - * @brief The serialized return result for operation: BreakLease - */ - struct BreakLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - }; - - /** - * @brief The serialized return result for operation: CreateShareSnapshot - */ - struct CreateShareSnapshotResult final - { - - /** - * This header is a DateTime value that uniquely identifies the share snapshot. The value of - * this header may be used in subsequent requests to access the share snapshot. This value is - * opaque. - */ - std::string Snapshot; - - /** - * The ETag contains a value which represents the version of the share snapshot, in quotes. A - * share snapshot cannot be modified, so the ETag of a given share snapshot never changes. - * However, if new metadata was supplied with the Snapshot Share request then the ETag of the - * share snapshot differs from that of the base share. If no metadata was specified with the - * request, the ETag of the share snapshot is identical to that of the base share at the time - * the share snapshot was taken. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. A share snapshot cannot be modified, - * so the last modified time of a given share snapshot never changes. However, if new metadata - * was supplied with the Snapshot Share request then the last modified time of the share - * snapshot differs from that of the base share. If no metadata was specified with the - * request, the last modified time of the share snapshot is identical to that of the base - * share at the time the share snapshot was taken. - */ - DateTime LastModified; - }; - - /** - * @brief The serialized return result for operation: CreateSharePermission - */ - struct CreateSharePermissionResult final - { - - /** - * Key of the permission set for the directory/file. - */ - std::string FilePermissionKey; - }; - - /** - * @brief The serialized return result for operation: SetShareProperties - */ - struct SetSharePropertiesResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - }; - - /** - * @brief The serialized return result for operation: SetShareMetadata - */ - struct SetShareMetadataResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - }; - - /** - * @brief The serialized return result for operation: GetShareAccessPolicy - */ - struct ShareAccessPolicy final - { - std::vector SignedIdentifiers; - }; - - /** - * @brief The serialized return result for operation: SetShareAccessPolicy - */ - struct SetShareAccessPolicyResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - }; - - /** - * @brief The serialized return result for operation: GetShareStatistics - */ - struct ShareStatistics final - { - /** - * The approximate size of the data stored in bytes. Note that this value may not include all - * recently created or recently resized files. - */ - int64_t ShareUsageInBytes = int64_t(); - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - }; - - /** - * @brief The serialized return result for operation: CreateDirectory - */ - struct CreateDirectoryResult final - { - - /** - * The ETag contains a value which represents the version of the directory, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * directory or its properties updates the last modified time. Operations on files do not - * affect the last modified time of the directory. - */ - DateTime LastModified; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - - /** - * If the object is created. - */ - bool Created = true; - }; - - /** - * @brief The serialized return result for operation: GetDirectoryProperties - */ - struct DirectoryProperties final - { - - /** - * The metadata of the object. - */ - Storage::Metadata Metadata; - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the Directory was last modified. Operations on files within the - * directory do not affect the last modified time of the directory. - */ - DateTime LastModified; - - /** - * The value of this header is set to true if the directory metadata is completely encrypted - * using the specified algorithm. Otherwise, the value is set to false. - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - }; - - /** - * @brief The serialized return result for operation: DeleteDirectory - */ - struct DeleteDirectoryResult final - { - - /** - * If the object is deleted. - */ - bool Deleted = true; - }; - - /** - * @brief The serialized return result for operation: SetDirectoryProperties - */ - struct SetDirectoryPropertiesResult final - { - - /** - * The ETag contains a value which represents the version of the file, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the directory was last modified. Any operation that modifies the - * directory or its properties updates the last modified time. Operations on files do not - * affect the last modified time of the directory. - */ - DateTime LastModified; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - }; - - /** - * @brief The serialized return result for operation: SetDirectoryMetadata - */ - struct SetDirectoryMetadataResult final - { - - /** - * The ETag contains a value which represents the version of the directory, in quotes. - */ - Azure::ETag ETag; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - }; - - /** - * @brief The serialized return result for operation: CreateFile - */ - struct CreateFileResult final - { - - /** - * The ETag contains a value which represents the version of the file, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * directory or its properties updates the last modified time. Operations on files do not - * affect the last modified time of the directory. - */ - DateTime LastModified; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - - /** - * If the object is created. - */ - bool Created = true; - }; - - /** - * @brief The serialized return result for operation: GetFileProperties - */ - struct FileProperties final - { - - /** - * Returns the date and time the file was last modified. The date format follows RFC 1123. Any - * operation that modifies the file or its properties updates the last modified time. - */ - DateTime LastModified; - - /** - * The metadata of the object. - */ - Storage::Metadata Metadata; - - /** - * The size of the file in bytes. This header returns the value of the 'x-ms-content-length' - * header that is stored with the file. - */ - int64_t FileSize = int64_t(); - - /** - * The HTTP headers of the object. - */ - FileHttpHeaders HttpHeaders; - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Conclusion time of the last attempted Copy File operation where this file was the - * destination file. This value can specify the time of a completed, aborted, or failed copy - * attempt. - */ - Azure::Nullable CopyCompletedOn; - - /** - * Only appears when x-ms-copy-status is failed or pending. Describes cause of fatal or - * non-fatal copy operation failure. - */ - Azure::Nullable CopyStatusDescription; - - /** - * String identifier for the last attempted Copy File operation where this file was the - * destination file. - */ - Azure::Nullable CopyId; - - /** - * Contains the number of bytes copied and the total bytes in the source in the last attempted - * Copy File operation where this file was the destination file. Can show between 0 and - * Content-Length bytes copied. - */ - Azure::Nullable CopyProgress; - - /** - * URL up to 2KB in length that specifies the source file used in the last attempted Copy File - * operation where this file was the destination file. - */ - Azure::Nullable CopySource; - - /** - * State of the copy operation identified by 'x-ms-copy-id'. - */ - Azure::Nullable CopyStatus; - - /** - * The value of this header is set to true if the file data and application metadata are - * completely encrypted using the specified algorithm. Otherwise, the value is set to false - * (when the file is unencrypted, or if only parts of the file/application metadata are - * encrypted). - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - - /** - * When a file or share is leased, specifies whether the lease is of infinite or fixed - * duration. - */ - Azure::Nullable LeaseDuration; - - /** - * Lease state of the file or share. - */ - Azure::Nullable LeaseState; - - /** - * The current lease status of the file or share. - */ - Azure::Nullable LeaseStatus; - }; - - /** - * @brief The serialized return result for operation: DeleteFile - */ - struct DeleteFileResult final - { - - /** - * If the object is deleted. - */ - bool Deleted = true; - }; - - /** - * @brief The serialized return result for operation: SetFileProperties - */ - struct SetFilePropertiesResult final - { - - /** - * The ETag contains a value which represents the version of the file, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the directory was last modified. Any operation that modifies the - * directory or its properties updates the last modified time. Operations on files do not - * affect the last modified time of the directory. - */ - DateTime LastModified; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - }; - - /** - * @brief The serialized return result for operation: SetFileMetadata - */ - struct SetFileMetadataResult final - { - - /** - * The ETag contains a value which represents the version of the file, in quotes. - */ - Azure::ETag ETag; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - }; - - /** - * @brief The serialized return result for operation: UploadFileRange - */ - struct UploadFileRangeResult final - { - - /** - * The ETag contains a value which represents the version of the file, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the directory was last modified. Any operation that modifies the - * share or its properties or metadata updates the last modified time. Operations on files do - * not affect the last modified time of the share. - */ - DateTime LastModified; - - /** - * This header is returned so that the client can check for message content integrity. The - * value of this header is computed by the File service; it is not necessarily the same value - * as may have been specified in the request headers. - */ - Storage::ContentHash TransactionalContentHash; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - }; - - /** - * @brief The serialized return result for operation: UploadFileRangeFromUri - */ - struct UploadFileRangeFromUriResult final - { - - /** - * The ETag contains a value which represents the version of the file, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the directory was last modified. Any operation that modifies the - * share or its properties or metadata updates the last modified time. Operations on files do - * not affect the last modified time of the share. - */ - DateTime LastModified; - - /** - * This header is returned so that the client can check for message content integrity. The - * value of this header is computed by the File service; it is not necessarily the same value - * as may have been specified in the request headers. - */ - Storage::ContentHash TransactionalContentHash; - - /** - * A boolean that indicates if the server is encrypted. - */ - bool IsServerEncrypted = bool(); - }; - - /** - * @brief The serialized return result for operation: GetFileRangeList - */ - struct GetFileRangeListResult final - { - /** - * Ranges of the file. - */ - std::vector Ranges; - - /** - * Cleared ranges of the file - */ - std::vector ClearRanges; - - /** - * The date/time that the file was last modified. Any operation that modifies the file, - * including an update of the file's metadata or properties, changes the file's last modified - * time. - */ - DateTime LastModified; - - /** - * The ETag contains a value which represents the version of the file, in quotes. - */ - Azure::ETag ETag; - - /** - * The size of the file in bytes. - */ - int64_t FileSize = int64_t(); - }; - - /** - * @brief The serialized return result for operation: AbortFileCopy - */ - struct AbortFileCopyResult final - { - }; - - /** - * @brief Include this parameter to specify one or more datasets to include in the response. - */ - enum class ListSharesIncludeFlags - { - None = 0, - Snapshots = 1, - Metadata = 2, - Deleted = 4, - }; - - inline ListSharesIncludeFlags operator|(ListSharesIncludeFlags lhs, ListSharesIncludeFlags rhs) - { - using type = std::underlying_type_t; - return static_cast(static_cast(lhs) | static_cast(rhs)); - } - - inline ListSharesIncludeFlags& operator|=( - ListSharesIncludeFlags& lhs, - ListSharesIncludeFlags rhs) - { - lhs = lhs | rhs; - return lhs; - } - - inline ListSharesIncludeFlags operator&(ListSharesIncludeFlags lhs, ListSharesIncludeFlags rhs) - { - using type = std::underlying_type_t; - return static_cast(static_cast(lhs) & static_cast(rhs)); - } - - inline ListSharesIncludeFlags& operator&=( - ListSharesIncludeFlags& lhs, - ListSharesIncludeFlags rhs) - { - lhs = lhs & rhs; - return lhs; - } - inline std::string ListSharesIncludeFlagsToString(const ListSharesIncludeFlags& val) - { - ListSharesIncludeFlags value_list[] = { - ListSharesIncludeFlags::Snapshots, - ListSharesIncludeFlags::Metadata, - ListSharesIncludeFlags::Deleted, - }; - const char* string_list[] = { - "snapshots", - "metadata", - "deleted", - }; - std::string result; - for (size_t i = 0; i < sizeof(value_list) / sizeof(ListSharesIncludeFlags); ++i) - { - if ((val & value_list[i]) == value_list[i]) - { - if (!result.empty()) - { - result += ","; - } - result += string_list[i]; - } - } - return result; - } - - } // namespace Models - namespace _detail { - using namespace Models; - constexpr static const char* DefaultServiceApiVersion = "2020-02-10"; - constexpr static const char* QueryCopyId = "copyid"; - constexpr static const char* QueryIncludeFlags = "include"; - constexpr static const char* QueryContinuationToken = "marker"; - constexpr static const char* QueryPageSizeHint = "maxresults"; - constexpr static const char* QueryPrefix = "prefix"; - constexpr static const char* QueryPrevShareSnapshot = "prevsharesnapshot"; - constexpr static const char* QueryShareSnapshot = "sharesnapshot"; - constexpr static const char* QueryTimeout = "timeout"; - constexpr static const char* QueryRestype = "restype"; - constexpr static const char* QueryComp = "comp"; - constexpr static const char* HeaderVersion = "x-ms-version"; - constexpr static const char* HeaderAccessTier = "x-ms-access-tier"; - constexpr static const char* HeaderContentLength = "content-length"; - constexpr static const char* HeaderContentHashMd5 = "content-md5"; - constexpr static const char* HeaderCopyActionAbortConstant = "x-ms-copy-action"; - constexpr static const char* HeaderCopySource = "x-ms-copy-source"; - constexpr static const char* HeaderFilePermissionCopyMode = "x-ms-file-permission-copy-mode"; - constexpr static const char* HeaderIgnoreReadOnly = "x-ms-file-copy-ignore-read-only"; - constexpr static const char* HeaderFileAttributes = "x-ms-file-attributes"; - constexpr static const char* HeaderFileCreatedOn = "x-ms-file-creation-time"; - constexpr static const char* HeaderFileLastWrittenOn = "x-ms-file-last-write-time"; - constexpr static const char* HeaderSetArchiveAttribute = "x-ms-file-copy-set-archive"; - constexpr static const char* HeaderDeletedShareName = "x-ms-deleted-share-name"; - constexpr static const char* HeaderDeletedShareVersion = "x-ms-deleted-share-version"; - constexpr static const char* HeaderDeleteSnapshots = "x-ms-delete-snapshots"; - constexpr static const char* HeaderFileCacheControl = "x-ms-cache-control"; - constexpr static const char* HeaderFileContentDisposition = "x-ms-content-disposition"; - constexpr static const char* HeaderFileContentEncoding = "x-ms-content-encoding"; - constexpr static const char* HeaderFileContentLanguage = "x-ms-content-language"; - constexpr static const char* HeaderFileContentType = "x-ms-content-type"; - constexpr static const char* HeaderFilePermission = "x-ms-file-permission"; - constexpr static const char* HeaderFilePermissionKey = "x-ms-file-permission-key"; - constexpr static const char* HeaderFileRangeWriteFromUrl = "x-ms-write"; - constexpr static const char* HeaderFileRangeWriteFromUrlDefault = "update"; - constexpr static const char* HeaderFileTypeConstant = "x-ms-type"; - constexpr static const char* HeaderRangeGetContentMd5 = "x-ms-range-get-content-md5"; - constexpr static const char* HeaderHandleId = "x-ms-handle-id"; - constexpr static const char* HeaderBreakPeriod = "x-ms-lease-break-period"; - constexpr static const char* HeaderDuration = "x-ms-lease-duration"; - constexpr static const char* HeaderLeaseId = "x-ms-lease-id"; - constexpr static const char* HeaderMetadata = "x-ms-meta"; - constexpr static const char* HeaderProposedLeaseId = "x-ms-proposed-lease-id"; - constexpr static const char* HeaderRange = "x-ms-range"; - constexpr static const char* HeaderRecursive = "x-ms-recursive"; - constexpr static const char* HeaderQuota = "x-ms-share-quota"; - constexpr static const char* HeaderSourceContentHashCrc64 = "x-ms-source-content-crc64"; - constexpr static const char* HeaderSourceIfMatchHashCrc64 = "x-ms-source-if-match-crc64"; - constexpr static const char* HeaderSourceIfNoneMatchHashCrc64 - = "x-ms-source-if-none-match-crc64"; - constexpr static const char* HeaderSourceRange = "x-ms-source-range"; - constexpr static const char* HeaderRequestId = "x-ms-request-id"; - constexpr static const char* HeaderErrorCode = "x-ms-error-code"; - constexpr static const char* HeaderETag = "etag"; - constexpr static const char* HeaderLastModified = "last-modified"; - constexpr static const char* HeaderDate = "date"; - constexpr static const char* HeaderProvisionedIops = "x-ms-share-provisioned-iops"; - constexpr static const char* HeaderProvisionedIngressMBps - = "x-ms-share-provisioned-ingress-mbps"; - constexpr static const char* HeaderProvisionedEgressMBps = "x-ms-share-provisioned-egress-mbps"; - constexpr static const char* HeaderNextAllowedQuotaDowngradeTime - = "x-ms-share-next-allowed-quota-downgrade-time"; - constexpr static const char* HeaderLeaseDuration = "x-ms-lease-duration"; - constexpr static const char* HeaderLeaseState = "x-ms-lease-state"; - constexpr static const char* HeaderLeaseStatus = "x-ms-lease-status"; - constexpr static const char* HeaderAccessTierChangedOn = "x-ms-access-tier-change-time"; - constexpr static const char* HeaderAccessTierTransitionState - = "x-ms-access-tier-transition-state"; - constexpr static const char* HeaderClientRequestId = "x-ms-client-request-id"; - constexpr static const char* HeaderAction = "x-ms-lease-action"; - constexpr static const char* HeaderSnapshot = "x-ms-snapshot"; - constexpr static const char* HeaderRequestIsServerEncrypted = "x-ms-request-server-encrypted"; - constexpr static const char* HeaderAttributes = "x-ms-file-attributes"; - constexpr static const char* HeaderCreatedOn = "x-ms-file-creation-time"; - constexpr static const char* HeaderLastWrittenOn = "x-ms-file-last-write-time"; - constexpr static const char* HeaderChangedOn = "x-ms-file-change-time"; - constexpr static const char* HeaderFileId = "x-ms-file-id"; - constexpr static const char* HeaderParentFileId = "x-ms-file-parent-id"; - constexpr static const char* HeaderIsServerEncrypted = "x-ms-server-encrypted"; - constexpr static const char* HeaderContentType = "content-type"; - constexpr static const char* HeaderContinuationToken = "x-ms-marker"; - constexpr static const char* HeaderNumberOfHandlesClosed = "x-ms-number-of-handles-closed"; - constexpr static const char* HeaderNumberOfHandlesFailedToClose - = "x-ms-number-of-handles-failed"; - constexpr static const char* HeaderXMsContentLength = "x-ms-content-length"; - constexpr static const char* HeaderContentRange = "content-range"; - constexpr static const char* HeaderTransactionalContentHashMd5 = "content-md5"; - constexpr static const char* HeaderContentEncoding = "content-encoding"; - constexpr static const char* HeaderCacheControl = "cache-control"; - constexpr static const char* HeaderContentDisposition = "content-disposition"; - constexpr static const char* HeaderContentLanguage = "content-language"; - constexpr static const char* HeaderAcceptRanges = "accept-ranges"; - constexpr static const char* HeaderCopyCompletedOn = "x-ms-copy-completion-time"; - constexpr static const char* HeaderCopyStatusDescription = "x-ms-copy-status-description"; - constexpr static const char* HeaderCopyId = "x-ms-copy-id"; - constexpr static const char* HeaderCopyProgress = "x-ms-copy-progress"; - constexpr static const char* HeaderCopyStatus = "x-ms-copy-status"; - constexpr static const char* HeaderXMsRange = "x-ms-range"; - constexpr static const char* HeaderFileRangeWrite = "x-ms-write"; - constexpr static const char* HeaderFileRangeWriteDefault = "update"; - constexpr static const char* HeaderTransactionalContentHashCrc64 = "x-ms-content-crc64"; - - /** - * @brief Only update is supported: - Update: Writes the bytes downloaded from the source URL - * into the specified range. - */ - class FileRangeWriteFromUrl final { - public: - FileRangeWriteFromUrl() = default; - explicit FileRangeWriteFromUrl(std::string value) : m_value(std::move(value)) {} - bool operator==(const FileRangeWriteFromUrl& other) const { return m_value == other.m_value; } - bool operator!=(const FileRangeWriteFromUrl& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileRangeWriteFromUrl Update; - - private: - std::string m_value; - }; // extensible enum FileRangeWriteFromUrl - - /** - * @brief Abstract for entries that can be listed from Directory. - */ - struct FilesAndDirectoriesListSinglePage final - { - /** - * An array of the directory items returned. - */ - std::vector DirectoryItems; - - /** - * An array of the directory items returned. - */ - std::vector FileItems; - }; - - /** - * @brief An enumeration of directories and files. - */ - struct ListFilesAndDirectoriesSinglePageResponse final - { - /** - * The service's endpoint. - */ - std::string ServiceEndpoint; - - /** - * The name of the share. - */ - std::string ShareName; - - /** - * The snapshot of the share. - */ - std::string ShareSnapshot; - - /** - * The path of the directory. - */ - std::string DirectoryPath; - - /** - * The prefix of the directories and files. - */ - std::string Prefix; - - /** - * The maximum number of items to be returned in a single page. - */ - int32_t PageSizeHint = int32_t(); - - /** - * A returned page. - */ - FilesAndDirectoriesListSinglePage SinglePage; - - /** - * A continuation token used for further enumerations. - */ - Azure::Nullable ContinuationToken; - }; - - /** - * @brief An enumeration of handles. - */ - struct ListHandlesResponse final - { - /** - * An array contains all the handles returned. - */ - std::vector HandleList; - - /** - * A continuation token used for further enumerations. - */ - Azure::Nullable ContinuationToken; - }; - - /** - * @brief An enumeration of shares. - */ - struct ListSharesResponse final - { - /** - * The service's endpoint. - */ - std::string ServiceEndpoint; - - /** - * The prefix of the share listed. - */ - std::string Prefix; - - /** - * The maximum number of entries returned in a single page. - */ - int32_t PageSizeHint = int32_t(); - - /** - * An array of the share items returned in a single page. - */ - std::vector Items; - - /** - * A continuation token used for further enumerations. - */ - Azure::Nullable ContinuationToken; - }; - - /** - * @brief An Azure Storage file range. - */ - struct FileRange final - { - /** - * Start of the range. - */ - int64_t Start = int64_t(); - - /** - * End of the range. - */ - int64_t End = int64_t(); - }; - - /** - * @brief An Azure Storage file clear range. - */ - struct ClearRange final - { - /** - * Start of the range. - */ - int64_t Start = int64_t(); - - /** - * End of the range. - */ - int64_t End = int64_t(); - }; - - /** - * @brief The list of file ranges - */ - struct RangeList final - { - /** - * Ranges of the file. - */ - std::vector Ranges; - - /** - * Cleared ranges of the file - */ - std::vector ClearRanges; - }; - - /** - * @brief Stats for the share. - */ - struct ShareStats final - { - /** - * The approximate size of the data stored in bytes. Note that this value may not include all - * recently created or recently resized files. - */ - int64_t ShareUsageInBytes = int64_t(); - }; - - /** - * @brief A permission (a security descriptor) at the share level. - */ - struct SharePermission final - { - /** - * The permission in the Security Descriptor Definition Language (SDDL). - */ - std::string FilePermission; - }; - - /** - * @brief Describes what lease action to take. - */ - class LeaseAction final { - public: - LeaseAction() = default; - explicit LeaseAction(std::string value) : m_value(std::move(value)) {} - bool operator==(const LeaseAction& other) const { return m_value == other.m_value; } - bool operator!=(const LeaseAction& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseAction Acquire; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseAction Release; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseAction Change; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseAction Renew; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseAction Break; - - private: - std::string m_value; - }; // extensible enum LeaseAction - - /** - * @brief Specify one of the following options: - Update: Writes the bytes specified by the - * request body into the specified range. The Range and Content-Length headers must match to - * perform the update. - Clear: Clears the specified range and releases the space used in - * storage for that range. To clear a range, set the Content-Length header to zero, and set the - * Range header to a value that indicates the range to clear, up to maximum file size. - */ - class FileRangeWrite final { - public: - FileRangeWrite() = default; - explicit FileRangeWrite(std::string value) : m_value(std::move(value)) {} - bool operator==(const FileRangeWrite& other) const { return m_value == other.m_value; } - bool operator!=(const FileRangeWrite& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileRangeWrite Update; - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileRangeWrite Clear; - - private: - std::string m_value; - }; // extensible enum FileRangeWrite - - struct ServiceGetPropertiesResult final - { - /** - * A summary of request statistics grouped by API in hourly aggregates for files. - */ - Metrics HourMetrics; - - /** - * A summary of request statistics grouped by API in minute aggregates for files. - */ - Metrics MinuteMetrics; - - /** - * The set of CORS rules. - */ - std::vector Cors; - - /** - * Protocol settings - */ - Azure::Nullable Protocol; - }; - - struct ServiceListSharesSinglePageResult final - { - /** - * The service's endpoint. - */ - std::string ServiceEndpoint; - - /** - * The prefix of the share listed. - */ - std::string Prefix; - - /** - * The maximum number of entries returned in a single page. - */ - int32_t PageSizeHint = int32_t(); - - /** - * An array of the share items returned in a single page. - */ - std::vector Items; - - /** - * A continuation token used for further enumerations. - */ - Azure::Nullable ContinuationToken; - }; - - struct ShareGetPermissionResult final - { - /** - * The permission in the Security Descriptor Definition Language (SDDL). - */ - std::string FilePermission; - }; - - struct ShareRestoreResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the share was last modified. Any operation that modifies the - * share or its properties updates the last modified time. Operations on files do not affect - * the last modified time of the share. - */ - DateTime LastModified; - }; - - struct DirectoryListFilesAndDirectoriesSinglePageResult final - { - /** - * The service's endpoint. - */ - std::string ServiceEndpoint; - - /** - * The name of the share. - */ - std::string ShareName; - - /** - * The snapshot of the share. - */ - std::string ShareSnapshot; - - /** - * The path of the directory. - */ - std::string DirectoryPath; - - /** - * The prefix of the directories and files. - */ - std::string Prefix; - - /** - * The maximum number of items to be returned in a single page. - */ - int32_t PageSizeHint = int32_t(); - - /** - * A returned page. - */ - FilesAndDirectoriesListSinglePage SinglePage; - - /** - * A continuation token used for further enumerations. - */ - Azure::Nullable ContinuationToken; - - /** - * The HTTP headers of the object. - */ - FileHttpHeaders HttpHeaders; - }; - - struct DirectoryListHandlesResult final - { - /** - * An array contains all the handles returned. - */ - std::vector HandleList; - - /** - * A continuation token used for further enumerations. - */ - Azure::Nullable ContinuationToken; - - /** - * The HTTP headers of the object. - */ - FileHttpHeaders HttpHeaders; - }; - - struct DirectoryForceCloseHandlesResult final - { - - /** - * A string describing next handle to be closed. It is returned when more handles need to be - * closed to complete the request. - */ - Azure::Nullable ContinuationToken; - - /** - * Contains count of number of handles closed. - */ - int32_t NumberOfHandlesClosed = int32_t(); - - /** - * Contains count of number of handles that failed to close. - */ - int32_t NumberOfHandlesFailedToClose = int32_t(); - }; - - struct FileDownloadResult final - { - std::unique_ptr BodyStream; - - /** - * Returns the date and time the file was last modified. Any operation that modifies the file - * or its properties updates the last modified time. - */ - DateTime LastModified; - - /** - * The metadata of the object. - */ - Storage::Metadata Metadata; - - /** - * The HTTP headers of the object. - */ - FileHttpHeaders HttpHeaders; - - /** - * A HttpRange type indicates the range of the content. - */ - Azure::Core::Http::HttpRange ContentRange; - - /** - * The size of the file. - */ - int64_t FileSize = int64_t(); - - /** - * The ETag contains a value that you can use to perform operations conditionally, in quotes. - */ - Azure::ETag ETag; - - /** - * If the file has an MD5 hash and the request is to read the full file, this response header - * is returned so that the client can check for message content integrity. If the request is - * to read a specified range and the 'x-ms-range-get-content-md5' is set to true, then the - * request returns an MD5 hash for the range, as long as the range size is less than or equal - * to 4 MB. If neither of these sets of conditions is true, then no value is returned for the - * 'Content-MD5' header. - */ - Azure::Nullable TransactionalContentHash; - - /** - * Indicates that the service supports requests for partial file content. - */ - std::string AcceptRanges; - - /** - * Conclusion time of the last attempted Copy File operation where this file was the - * destination file. This value can specify the time of a completed, aborted, or failed copy - * attempt. - */ - Azure::Nullable CopyCompletedOn; - - /** - * Only appears when x-ms-copy-status is failed or pending. Describes cause of fatal or - * non-fatal copy operation failure. - */ - Azure::Nullable CopyStatusDescription; - - /** - * String identifier for the last attempted Copy File operation where this file was the - * destination file. - */ - Azure::Nullable CopyId; - - /** - * Contains the number of bytes copied and the total bytes in the source in the last attempted - * Copy File operation where this file was the destination file. Can show between 0 and - * Content-Length bytes copied. - */ - Azure::Nullable CopyProgress; - - /** - * URL up to 2KB in length that specifies the source file used in the last attempted Copy File - * operation where this file was the destination file. - */ - Azure::Nullable CopySource; - - /** - * State of the copy operation identified by 'x-ms-copy-id'. - */ - Azure::Nullable CopyStatus; - - /** - * The value of this header is set to true if the file data and application metadata are - * completely encrypted using the specified algorithm. Otherwise, the value is set to false - * (when the file is unencrypted, or if only parts of the file/application metadata are - * encrypted). - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - - /** - * When a file or share is leased, specifies whether the lease is of infinite or fixed - * duration. - */ - Azure::Nullable LeaseDuration; - - /** - * Lease state of the file or share. - */ - Azure::Nullable LeaseState; - - /** - * The current lease status of the file or share. - */ - Azure::Nullable LeaseStatus; - }; - - struct FileAcquireLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally. If the - * request version is 2011-08-18 or newer, the ETag value will be in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the file was last modified. Any operation that modifies the file, - * including an update of the file's metadata or properties, changes the last-modified time of - * the file. - */ - DateTime LastModified; - - /** - * Uniquely identifies a file's lease - */ - std::string LeaseId; - }; - - struct FileReleaseLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally. If the - * request version is 2011-08-18 or newer, the ETag value will be in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the file was last modified. Any operation that modifies the file, - * including an update of the file's metadata or properties, changes the last-modified time of - * the file. - */ - DateTime LastModified; - }; - - struct FileChangeLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally. If the - * request version is 2011-08-18 or newer, the ETag value will be in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the file was last modified. Any operation that modifies the file, - * including an update of the file's metadata or properties, changes the last-modified time of - * the file. - */ - DateTime LastModified; - - /** - * Uniquely identifies a file's lease - */ - std::string LeaseId; - }; - - struct FileBreakLeaseResult final - { - - /** - * The ETag contains a value that you can use to perform operations conditionally. If the - * request version is 2011-08-18 or newer, the ETag value will be in quotes. - */ - Azure::ETag ETag; - - /** - * Returns the date and time the file was last modified. Any operation that modifies the file, - * including an update of the file's metadata or properties, changes the last-modified time of - * the file. - */ - DateTime LastModified; - - /** - * Uniquely identifies a file's lease - */ - Azure::Nullable LeaseId; - }; - - struct FileStartCopyResult final - { - - /** - * If the copy is completed, contains the ETag of the destination file. If the copy is not - * complete, contains the ETag of the empty file created at the start of the copy. - */ - Azure::ETag ETag; - - /** - * Returns the date/time that the copy operation to the destination file completed. - */ - DateTime LastModified; - - /** - * String identifier for this copy operation. Use with Get File or Get File Properties to - * check the status of this copy operation, or pass to Abort Copy File to abort a pending - * copy. - */ - std::string CopyId; - - /** - * State of the copy operation identified by x-ms-copy-id. - */ - Models::CopyStatus CopyStatus; - }; - - struct FileListHandlesResult final - { - /** - * An array contains all the handles returned. - */ - std::vector HandleList; - - /** - * A continuation token used for further enumerations. - */ - Azure::Nullable ContinuationToken; - - /** - * The HTTP headers of the object. - */ - FileHttpHeaders HttpHeaders; - }; - - struct FileForceCloseHandlesResult final - { - - /** - * A string describing next handle to be closed. It is returned when more handles need to be - * closed to complete the request. - */ - Azure::Nullable ContinuationToken; - - /** - * Contains count of number of handles closed. - */ - int32_t NumberOfHandlesClosed = int32_t(); - - /** - * Contains count of number of handles that failed to close. - */ - int32_t NumberOfHandlesFailedToClose = int32_t(); - }; - - class ShareRestClient final { - private: - static Azure::Core::Http::HttpRange HttpRangeFromXml(_internal::XmlReader& reader) - { - int depth = 0; - bool is_start = false; - bool is_end = false; - int64_t start = 0; - int64_t end = 0; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if ( - node.Type == _internal::XmlNodeType::StartTag - && strcmp(node.Name.data(), "Start") == 0) - { - ++depth; - is_start = true; - } - else if ( - node.Type == _internal::XmlNodeType::StartTag && strcmp(node.Name.data(), "End") == 0) - { - ++depth; - is_end = true; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - is_start = false; - is_end = false; - if (depth-- == 0) - { - break; - } - } - if (depth == 1 && node.Type == _internal::XmlNodeType::Text) - { - if (is_start) - { - start = std::stoll(node.Value); - } - else if (is_end) - { - end = std::stoll(node.Value); - } - } - } - Azure::Core::Http::HttpRange ret; - ret.Offset = start; - ret.Length = end - start + 1; - return ret; - } - - public: - class Service final { - public: - struct SetPropertiesOptions final - { - ShareServiceProperties ServiceProperties; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response SetProperties( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetPropertiesOptions& setPropertiesOptions) - { - - std::string xml_body; - { - _internal::XmlWriter writer; - ShareServicePropertiesToXml(writer, setPropertiesOptions.ServiceProperties); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::End}); - xml_body = writer.GetDocument(); - } - auto body = Azure::Core::IO::MemoryBodyStream( - reinterpret_cast(xml_body.data()), xml_body.length()); - auto request = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Put, url, &body); - request.SetHeader("Content-Length", std::to_string(body.Length())); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "service"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "properties"); - if (setPropertiesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setPropertiesOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, setPropertiesOptions.ApiVersionParameter); - return SetPropertiesParseResult(context, pipeline.Send(request, context)); - } - - struct GetPropertiesOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response GetProperties( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetPropertiesOptions& getPropertiesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "service"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "properties"); - if (getPropertiesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getPropertiesOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getPropertiesOptions.ApiVersionParameter); - return GetPropertiesParseResult(context, pipeline.Send(request, context)); - } - - struct ListSharesSinglePageOptions final - { - Azure::Nullable Prefix; - Azure::Nullable ContinuationToken; - Azure::Nullable MaxResults; - Azure::Nullable IncludeFlags; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response ListSharesSinglePage( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ListSharesSinglePageOptions& listSharesSinglePageOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "list"); - if (listSharesSinglePageOptions.Prefix.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryPrefix, - _internal::UrlEncodeQueryParameter(listSharesSinglePageOptions.Prefix.Value())); - } - if (listSharesSinglePageOptions.ContinuationToken.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryContinuationToken, - _internal::UrlEncodeQueryParameter( - listSharesSinglePageOptions.ContinuationToken.Value())); - } - if (listSharesSinglePageOptions.MaxResults.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryPageSizeHint, - _internal::UrlEncodeQueryParameter( - std::to_string(listSharesSinglePageOptions.MaxResults.Value()))); - } - if (listSharesSinglePageOptions.IncludeFlags.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryIncludeFlags, - _internal::UrlEncodeQueryParameter(ListSharesIncludeFlagsToString( - listSharesSinglePageOptions.IncludeFlags.Value()))); - } - if (listSharesSinglePageOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(listSharesSinglePageOptions.Timeout.Value()))); - } - request.SetHeader( - _detail::HeaderVersion, listSharesSinglePageOptions.ApiVersionParameter); - return ListSharesSinglePageParseResult(context, pipeline.Send(request, context)); - } - - private: - static Azure::Response SetPropertiesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Accepted) - { - // Success (Accepted) - Models::SetServicePropertiesResult result; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static void RetentionPolicyToXml( - _internal::XmlWriter& writer, - const RetentionPolicy& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Enabled"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), object.Enabled ? "true" : "false"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - if (object.Days.HasValue()) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Days"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), std::to_string(object.Days.Value())}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - } - - static void MetricsToXml(_internal::XmlWriter& writer, const Metrics& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Version"}); - writer.Write( - _internal::XmlNode{_internal::XmlNodeType::Text, std::string(), object.Version}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Enabled"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), object.Enabled ? "true" : "false"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - if (object.IncludeApis.HasValue()) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "IncludeAPIs"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, - std::string(), - object.IncludeApis.Value() ? "true" : "false"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "RetentionPolicy"}); - RetentionPolicyToXml(writer, object.RetentionPolicy); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - - static void CorsRuleToXml(_internal::XmlWriter& writer, const CorsRule& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "CorsRule"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "AllowedOrigins"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), object.AllowedOrigins}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "AllowedMethods"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), object.AllowedMethods}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "AllowedHeaders"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), object.AllowedHeaders}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "ExposedHeaders"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), object.ExposedHeaders}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "MaxAgeInSeconds"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), std::to_string(object.MaxAgeInSeconds)}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - - static void SmbMultichannelToXml( - _internal::XmlWriter& writer, - const SmbMultichannel& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Multichannel"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Enabled"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, std::string(), object.Enabled ? "true" : "false"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - - static void SmbSettingsToXml(_internal::XmlWriter& writer, const SmbSettings& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "SMB"}); - SmbMultichannelToXml(writer, object.Multichannel); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - - static void ProtocolSettingsToXml( - _internal::XmlWriter& writer, - const ProtocolSettings& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "ProtocolSettings"}); - SmbSettingsToXml(writer, object.Settings); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - - static void ShareServicePropertiesToXml( - _internal::XmlWriter& writer, - const ShareServiceProperties& object) - { - writer.Write( - _internal::XmlNode{_internal::XmlNodeType::StartTag, "StorageServiceProperties"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "HourMetrics"}); - MetricsToXml(writer, object.HourMetrics); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "MinuteMetrics"}); - MetricsToXml(writer, object.MinuteMetrics); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - if (object.Cors.size() > 0) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Cors"}); - for (const auto& item : object.Cors) - { - CorsRuleToXml(writer, item); - } - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - if (object.Protocol.HasValue()) - { - ProtocolSettingsToXml(writer, object.Protocol.Value()); - } - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - static Azure::Response GetPropertiesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - ServiceGetPropertiesResult result = bodyBuffer.empty() - ? ServiceGetPropertiesResult() - : ServiceGetPropertiesResultFromShareServiceProperties( - ShareServicePropertiesFromXml(reader)); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static RetentionPolicy RetentionPolicyFromXml(_internal::XmlReader& reader) - { - auto result = RetentionPolicy(); - enum class XmlTagName - { - Days, - Enabled, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Days") == 0) - { - path.emplace_back(XmlTagName::Days); - } - else if (std::strcmp(node.Name.data(), "Enabled") == 0) - { - path.emplace_back(XmlTagName::Enabled); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Days) - { - result.Days = std::stoi(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::Enabled) - { - result.Enabled = (std::strcmp(node.Value.data(), "true") == 0); - } - } - } - return result; - } - - static Metrics MetricsFromXml(_internal::XmlReader& reader) - { - auto result = Metrics(); - enum class XmlTagName - { - Enabled, - IncludeAPIs, - RetentionPolicy, - Unknown, - Version, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Enabled") == 0) - { - path.emplace_back(XmlTagName::Enabled); - } - else if (std::strcmp(node.Name.data(), "IncludeAPIs") == 0) - { - path.emplace_back(XmlTagName::IncludeAPIs); - } - else if (std::strcmp(node.Name.data(), "RetentionPolicy") == 0) - { - path.emplace_back(XmlTagName::RetentionPolicy); - } - else if (std::strcmp(node.Name.data(), "Version") == 0) - { - path.emplace_back(XmlTagName::Version); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 1 && path[0] == XmlTagName::RetentionPolicy) - { - result.RetentionPolicy = RetentionPolicyFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Enabled) - { - result.Enabled = (std::strcmp(node.Value.data(), "true") == 0); - } - else if (path.size() == 1 && path[0] == XmlTagName::IncludeAPIs) - { - result.IncludeApis = (std::strcmp(node.Value.data(), "true") == 0); - } - else if (path.size() == 1 && path[0] == XmlTagName::Version) - { - result.Version = node.Value; - } - } - } - return result; - } - - static CorsRule CorsRuleFromXml(_internal::XmlReader& reader) - { - auto result = CorsRule(); - enum class XmlTagName - { - AllowedHeaders, - AllowedMethods, - AllowedOrigins, - ExposedHeaders, - MaxAgeInSeconds, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "AllowedHeaders") == 0) - { - path.emplace_back(XmlTagName::AllowedHeaders); - } - else if (std::strcmp(node.Name.data(), "AllowedMethods") == 0) - { - path.emplace_back(XmlTagName::AllowedMethods); - } - else if (std::strcmp(node.Name.data(), "AllowedOrigins") == 0) - { - path.emplace_back(XmlTagName::AllowedOrigins); - } - else if (std::strcmp(node.Name.data(), "ExposedHeaders") == 0) - { - path.emplace_back(XmlTagName::ExposedHeaders); - } - else if (std::strcmp(node.Name.data(), "MaxAgeInSeconds") == 0) - { - path.emplace_back(XmlTagName::MaxAgeInSeconds); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::AllowedHeaders) - { - result.AllowedHeaders = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::AllowedMethods) - { - result.AllowedMethods = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::AllowedOrigins) - { - result.AllowedOrigins = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::ExposedHeaders) - { - result.ExposedHeaders = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::MaxAgeInSeconds) - { - result.MaxAgeInSeconds = std::stoi(node.Value); - } - } - } - return result; - } - - static SmbMultichannel SmbMultichannelFromXml(_internal::XmlReader& reader) - { - auto result = SmbMultichannel(); - enum class XmlTagName - { - Enabled, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Enabled") == 0) - { - path.emplace_back(XmlTagName::Enabled); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Enabled) - { - result.Enabled = (std::strcmp(node.Value.data(), "true") == 0); - } - } - } - return result; - } - - static SmbSettings SmbSettingsFromXml(_internal::XmlReader& reader) - { - auto result = SmbSettings(); - enum class XmlTagName - { - Multichannel, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Multichannel") == 0) - { - path.emplace_back(XmlTagName::Multichannel); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 1 && path[0] == XmlTagName::Multichannel) - { - result.Multichannel = SmbMultichannelFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return result; - } - - static ProtocolSettings ProtocolSettingsFromXml(_internal::XmlReader& reader) - { - auto result = ProtocolSettings(); - enum class XmlTagName - { - SMB, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "SMB") == 0) - { - path.emplace_back(XmlTagName::SMB); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 1 && path[0] == XmlTagName::SMB) - { - result.Settings = SmbSettingsFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return result; - } - - static ShareServiceProperties ShareServicePropertiesFromXml(_internal::XmlReader& reader) - { - auto result = ShareServiceProperties(); - enum class XmlTagName - { - Cors, - CorsRule, - HourMetrics, - MinuteMetrics, - ProtocolSettings, - StorageServiceProperties, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Cors") == 0) - { - path.emplace_back(XmlTagName::Cors); - } - else if (std::strcmp(node.Name.data(), "CorsRule") == 0) - { - path.emplace_back(XmlTagName::CorsRule); - } - else if (std::strcmp(node.Name.data(), "HourMetrics") == 0) - { - path.emplace_back(XmlTagName::HourMetrics); - } - else if (std::strcmp(node.Name.data(), "MinuteMetrics") == 0) - { - path.emplace_back(XmlTagName::MinuteMetrics); - } - else if (std::strcmp(node.Name.data(), "ProtocolSettings") == 0) - { - path.emplace_back(XmlTagName::ProtocolSettings); - } - else if (std::strcmp(node.Name.data(), "StorageServiceProperties") == 0) - { - path.emplace_back(XmlTagName::StorageServiceProperties); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 2 && path[0] == XmlTagName::StorageServiceProperties - && path[1] == XmlTagName::HourMetrics) - { - result.HourMetrics = MetricsFromXml(reader); - path.pop_back(); - } - else if ( - path.size() == 2 && path[0] == XmlTagName::StorageServiceProperties - && path[1] == XmlTagName::MinuteMetrics) - { - result.MinuteMetrics = MetricsFromXml(reader); - path.pop_back(); - } - else if ( - path.size() == 2 && path[0] == XmlTagName::StorageServiceProperties - && path[1] == XmlTagName::ProtocolSettings) - { - result.Protocol = ProtocolSettingsFromXml(reader); - path.pop_back(); - } - else if ( - path.size() == 3 && path[0] == XmlTagName::StorageServiceProperties - && path[1] == XmlTagName::Cors && path[2] == XmlTagName::CorsRule) - { - result.Cors.emplace_back(CorsRuleFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return result; - } - - static ServiceGetPropertiesResult ServiceGetPropertiesResultFromShareServiceProperties( - ShareServiceProperties object) - { - ServiceGetPropertiesResult result; - result.HourMetrics = std::move(object.HourMetrics); - result.MinuteMetrics = std::move(object.MinuteMetrics); - result.Cors = std::move(object.Cors); - result.Protocol = std::move(object.Protocol); - - return result; - } - static Azure::Response ListSharesSinglePageParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - ServiceListSharesSinglePageResult result = bodyBuffer.empty() - ? ServiceListSharesSinglePageResult() - : ServiceListSharesSinglePageResultFromListSharesResponse( - ListSharesResponseFromXml(reader)); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static LeaseStatus LeaseStatusFromXml(_internal::XmlReader& reader) - { - LeaseStatus result; - enum class XmlTagName - { - LeaseStatus, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "LeaseStatus") == 0) - { - path.emplace_back(XmlTagName::LeaseStatus); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::LeaseStatus) - { - result = LeaseStatus(node.Value); - } - } - } - return result; - } - - static LeaseState LeaseStateFromXml(_internal::XmlReader& reader) - { - LeaseState result; - enum class XmlTagName - { - LeaseState, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "LeaseState") == 0) - { - path.emplace_back(XmlTagName::LeaseState); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::LeaseState) - { - result = LeaseState(node.Value); - } - } - } - return result; - } - - static LeaseDuration LeaseDurationFromXml(_internal::XmlReader& reader) - { - LeaseDuration result; - enum class XmlTagName - { - LeaseDuration, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "LeaseDuration") == 0) - { - path.emplace_back(XmlTagName::LeaseDuration); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::LeaseDuration) - { - result = LeaseDuration(node.Value); - } - } - } - return result; - } - - static ShareItemDetails ShareItemDetailsFromXml(_internal::XmlReader& reader) - { - auto result = ShareItemDetails(); - enum class XmlTagName - { - AccessTier, - AccessTierChangeTime, - AccessTierTransitionState, - DeletedTime, - Etag, - LastModified, - LeaseDuration, - LeaseState, - LeaseStatus, - NextAllowedQuotaDowngradeTime, - ProvisionedEgressMBps, - ProvisionedIngressMBps, - ProvisionedIops, - Quota, - RemainingRetentionDays, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "AccessTier") == 0) - { - path.emplace_back(XmlTagName::AccessTier); - } - else if (std::strcmp(node.Name.data(), "AccessTierChangeTime") == 0) - { - path.emplace_back(XmlTagName::AccessTierChangeTime); - } - else if (std::strcmp(node.Name.data(), "AccessTierTransitionState") == 0) - { - path.emplace_back(XmlTagName::AccessTierTransitionState); - } - else if (std::strcmp(node.Name.data(), "DeletedTime") == 0) - { - path.emplace_back(XmlTagName::DeletedTime); - } - else if (std::strcmp(node.Name.data(), "Etag") == 0) - { - path.emplace_back(XmlTagName::Etag); - } - else if (std::strcmp(node.Name.data(), "Last-Modified") == 0) - { - path.emplace_back(XmlTagName::LastModified); - } - else if (std::strcmp(node.Name.data(), "LeaseDuration") == 0) - { - path.emplace_back(XmlTagName::LeaseDuration); - } - else if (std::strcmp(node.Name.data(), "LeaseState") == 0) - { - path.emplace_back(XmlTagName::LeaseState); - } - else if (std::strcmp(node.Name.data(), "LeaseStatus") == 0) - { - path.emplace_back(XmlTagName::LeaseStatus); - } - else if (std::strcmp(node.Name.data(), "NextAllowedQuotaDowngradeTime") == 0) - { - path.emplace_back(XmlTagName::NextAllowedQuotaDowngradeTime); - } - else if (std::strcmp(node.Name.data(), "ProvisionedEgressMBps") == 0) - { - path.emplace_back(XmlTagName::ProvisionedEgressMBps); - } - else if (std::strcmp(node.Name.data(), "ProvisionedIngressMBps") == 0) - { - path.emplace_back(XmlTagName::ProvisionedIngressMBps); - } - else if (std::strcmp(node.Name.data(), "ProvisionedIops") == 0) - { - path.emplace_back(XmlTagName::ProvisionedIops); - } - else if (std::strcmp(node.Name.data(), "Quota") == 0) - { - path.emplace_back(XmlTagName::Quota); - } - else if (std::strcmp(node.Name.data(), "RemainingRetentionDays") == 0) - { - path.emplace_back(XmlTagName::RemainingRetentionDays); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 1 && path[0] == XmlTagName::LeaseStatus) - { - result.LeaseStatus = LeaseStatusFromXml(reader); - path.pop_back(); - } - else if (path.size() == 1 && path[0] == XmlTagName::LeaseState) - { - result.LeaseState = LeaseStateFromXml(reader); - path.pop_back(); - } - else if (path.size() == 1 && path[0] == XmlTagName::LeaseDuration) - { - result.LeaseDuration = LeaseDurationFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::AccessTier) - { - result.AccessTier = AccessTier(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::AccessTierChangeTime) - { - result.AccessTierChangedOn - = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::AccessTierTransitionState) - { - result.AccessTierTransitionState = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::DeletedTime) - { - result.DeletedOn = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::Etag) - { - result.Etag = Azure::ETag(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::LastModified) - { - result.LastModified = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::NextAllowedQuotaDowngradeTime) - { - result.NextAllowedQuotaDowngradeTime - = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::ProvisionedEgressMBps) - { - result.ProvisionedEgressMBps = std::stoi(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::ProvisionedIngressMBps) - { - result.ProvisionedIngressMBps = std::stoi(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::ProvisionedIops) - { - result.ProvisionedIops = std::stoi(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::Quota) - { - result.Quota = std::stoll(node.Value); - } - else if (path.size() == 1 && path[0] == XmlTagName::RemainingRetentionDays) - { - result.RemainingRetentionDays = std::stoi(node.Value); - } - } - } - return result; - } - - static Metadata MetadataFromXml(_internal::XmlReader& reader) - { - Metadata result; - int depth = 0; - std::string key; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - if (depth++ == 0) - { - key = node.Name; - } - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (depth-- == 0) - { - break; - } - } - else if (depth == 1 && node.Type == _internal::XmlNodeType::Text) - { - result.emplace(std::move(key), node.Value); - } - } - return result; - } - - static ShareItem ShareItemFromXml(_internal::XmlReader& reader) - { - auto result = ShareItem(); - enum class XmlTagName - { - Deleted, - Metadata, - Name, - Properties, - Snapshot, - Unknown, - Version, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Deleted") == 0) - { - path.emplace_back(XmlTagName::Deleted); - } - else if (std::strcmp(node.Name.data(), "Metadata") == 0) - { - path.emplace_back(XmlTagName::Metadata); - } - else if (std::strcmp(node.Name.data(), "Name") == 0) - { - path.emplace_back(XmlTagName::Name); - } - else if (std::strcmp(node.Name.data(), "Properties") == 0) - { - path.emplace_back(XmlTagName::Properties); - } - else if (std::strcmp(node.Name.data(), "Snapshot") == 0) - { - path.emplace_back(XmlTagName::Snapshot); - } - else if (std::strcmp(node.Name.data(), "Version") == 0) - { - path.emplace_back(XmlTagName::Version); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 1 && path[0] == XmlTagName::Properties) - { - result.Details = ShareItemDetailsFromXml(reader); - path.pop_back(); - } - else if (path.size() == 1 && path[0] == XmlTagName::Metadata) - { - result.Metadata = MetadataFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Deleted) - { - result.Deleted = (std::strcmp(node.Value.data(), "true") == 0); - } - else if (path.size() == 1 && path[0] == XmlTagName::Name) - { - result.Name = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::Snapshot) - { - result.Snapshot = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::Version) - { - result.Version = node.Value; - } - } - } - return result; - } - - static ListSharesResponse ListSharesResponseFromXml(_internal::XmlReader& reader) - { - auto result = ListSharesResponse(); - enum class XmlTagName - { - EnumerationResults, - MaxResults, - NextMarker, - Prefix, - Share, - Shares, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "EnumerationResults") == 0) - { - path.emplace_back(XmlTagName::EnumerationResults); - } - else if (std::strcmp(node.Name.data(), "MaxResults") == 0) - { - path.emplace_back(XmlTagName::MaxResults); - } - else if (std::strcmp(node.Name.data(), "NextMarker") == 0) - { - path.emplace_back(XmlTagName::NextMarker); - } - else if (std::strcmp(node.Name.data(), "Prefix") == 0) - { - path.emplace_back(XmlTagName::Prefix); - } - else if (std::strcmp(node.Name.data(), "Share") == 0) - { - path.emplace_back(XmlTagName::Share); - } - else if (std::strcmp(node.Name.data(), "Shares") == 0) - { - path.emplace_back(XmlTagName::Shares); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - if (path.size() == 3 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::Shares && path[2] == XmlTagName::Share) - { - result.Items.emplace_back(ShareItemFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::NextMarker) - { - result.ContinuationToken = node.Value; - } - else if ( - path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::MaxResults) - { - result.PageSizeHint = std::stoi(node.Value); - } - else if ( - path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::Prefix) - { - result.Prefix = node.Value; - } - } - else if (node.Type == _internal::XmlNodeType::Attribute) - { - if (path.size() == 1 && path[0] == XmlTagName::EnumerationResults - && (std::strcmp(node.Name.data(), "ServiceEndpoint") == 0)) - { - result.ServiceEndpoint = node.Value; - } - } - } - return result; - } - - static ServiceListSharesSinglePageResult - ServiceListSharesSinglePageResultFromListSharesResponse(ListSharesResponse object) - { - ServiceListSharesSinglePageResult result; - result.ServiceEndpoint = std::move(object.ServiceEndpoint); - result.Prefix = std::move(object.Prefix); - result.PageSizeHint = object.PageSizeHint; - result.Items = std::move(object.Items); - result.ContinuationToken = std::move(object.ContinuationToken); - - return result; - } - }; - - class Share final { - public: - struct CreateOptions final - { - Azure::Nullable Timeout; - Storage::Metadata Metadata; - Azure::Nullable ShareQuota; - Azure::Nullable XMsAccessTier; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response Create( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const CreateOptions& createOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (createOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter(std::to_string(createOptions.Timeout.Value()))); - } - for (const auto& pair : createOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - if (createOptions.ShareQuota.HasValue()) - { - request.SetHeader( - _detail::HeaderQuota, std::to_string(createOptions.ShareQuota.Value())); - } - if (createOptions.XMsAccessTier.HasValue()) - { - request.SetHeader( - _detail::HeaderAccessTier, createOptions.XMsAccessTier.Value().ToString()); - } - request.SetHeader(_detail::HeaderVersion, createOptions.ApiVersionParameter); - return CreateParseResult(context, pipeline.Send(request, context)); - } - - struct GetPropertiesOptions final - { - Azure::Nullable ShareSnapshot; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response GetProperties( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetPropertiesOptions& getPropertiesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (getPropertiesOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(getPropertiesOptions.ShareSnapshot.Value())); - } - if (getPropertiesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getPropertiesOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getPropertiesOptions.ApiVersionParameter); - if (getPropertiesOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, getPropertiesOptions.LeaseIdOptional.Value()); - } - return GetPropertiesParseResult(context, pipeline.Send(request, context)); - } - - struct DeleteOptions final - { - Azure::Nullable ShareSnapshot; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable XMsDeleteSnapshots; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response Delete( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const DeleteOptions& deleteOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Delete, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (deleteOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(deleteOptions.ShareSnapshot.Value())); - } - if (deleteOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter(std::to_string(deleteOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, deleteOptions.ApiVersionParameter); - if (deleteOptions.XMsDeleteSnapshots.HasValue()) - { - request.SetHeader( - _detail::HeaderDeleteSnapshots, - deleteOptions.XMsDeleteSnapshots.Value().ToString()); - } - if (deleteOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, deleteOptions.LeaseIdOptional.Value()); - } - return DeleteParseResult(context, pipeline.Send(request, context)); - } - - struct AcquireLeaseOptions final - { - Azure::Nullable Timeout; - int32_t LeaseDuration = int32_t(); - Azure::Nullable ProposedLeaseIdOptional; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable ShareSnapshot; - }; - - static Azure::Response AcquireLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const AcquireLeaseOptions& acquireLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "acquire"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (acquireLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(acquireLeaseOptions.Timeout.Value()))); - } - request.SetHeader( - _detail::HeaderDuration, std::to_string(acquireLeaseOptions.LeaseDuration)); - if (acquireLeaseOptions.ProposedLeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderProposedLeaseId, - acquireLeaseOptions.ProposedLeaseIdOptional.Value()); - } - request.SetHeader(_detail::HeaderVersion, acquireLeaseOptions.ApiVersionParameter); - if (acquireLeaseOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(acquireLeaseOptions.ShareSnapshot.Value())); - } - return AcquireLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct ReleaseLeaseOptions final - { - Azure::Nullable Timeout; - std::string LeaseIdRequired; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable ShareSnapshot; - }; - - static Azure::Response ReleaseLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ReleaseLeaseOptions& releaseLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "release"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (releaseLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(releaseLeaseOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderLeaseId, releaseLeaseOptions.LeaseIdRequired); - request.SetHeader(_detail::HeaderVersion, releaseLeaseOptions.ApiVersionParameter); - if (releaseLeaseOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(releaseLeaseOptions.ShareSnapshot.Value())); - } - return ReleaseLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct ChangeLeaseOptions final - { - Azure::Nullable Timeout; - std::string LeaseIdRequired; - Azure::Nullable ProposedLeaseIdOptional; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable ShareSnapshot; - }; - - static Azure::Response ChangeLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ChangeLeaseOptions& changeLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "change"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (changeLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(changeLeaseOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderLeaseId, changeLeaseOptions.LeaseIdRequired); - if (changeLeaseOptions.ProposedLeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderProposedLeaseId, changeLeaseOptions.ProposedLeaseIdOptional.Value()); - } - request.SetHeader(_detail::HeaderVersion, changeLeaseOptions.ApiVersionParameter); - if (changeLeaseOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(changeLeaseOptions.ShareSnapshot.Value())); - } - return ChangeLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct RenewLeaseOptions final - { - Azure::Nullable Timeout; - std::string LeaseIdRequired; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable ShareSnapshot; - }; - - static Azure::Response RenewLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const RenewLeaseOptions& renewLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "renew"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (renewLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(renewLeaseOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderLeaseId, renewLeaseOptions.LeaseIdRequired); - request.SetHeader(_detail::HeaderVersion, renewLeaseOptions.ApiVersionParameter); - if (renewLeaseOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(renewLeaseOptions.ShareSnapshot.Value())); - } - return RenewLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct BreakLeaseOptions final - { - Azure::Nullable Timeout; - Azure::Nullable LeaseBreakPeriod; - Azure::Nullable LeaseIdOptional; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable ShareSnapshot; - }; - - static Azure::Response BreakLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const BreakLeaseOptions& breakLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "break"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - if (breakLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(breakLeaseOptions.Timeout.Value()))); - } - if (breakLeaseOptions.LeaseBreakPeriod.HasValue()) - { - request.SetHeader( - _detail::HeaderBreakPeriod, - std::to_string(breakLeaseOptions.LeaseBreakPeriod.Value())); - } - if (breakLeaseOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, breakLeaseOptions.LeaseIdOptional.Value()); - } - request.SetHeader(_detail::HeaderVersion, breakLeaseOptions.ApiVersionParameter); - if (breakLeaseOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(breakLeaseOptions.ShareSnapshot.Value())); - } - return BreakLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct CreateSnapshotOptions final - { - Azure::Nullable Timeout; - Storage::Metadata Metadata; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response CreateSnapshot( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const CreateSnapshotOptions& createSnapshotOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "snapshot"); - if (createSnapshotOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(createSnapshotOptions.Timeout.Value()))); - } - for (const auto& pair : createSnapshotOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - request.SetHeader(_detail::HeaderVersion, createSnapshotOptions.ApiVersionParameter); - return CreateSnapshotParseResult(context, pipeline.Send(request, context)); - } - - struct CreatePermissionOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - SharePermission Permission; - }; - - static Azure::Response CreatePermission( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const CreatePermissionOptions& createPermissionOptions) - { - - std::string json_body; - { - Azure::Core::Json::_internal::json json; - SharePermissionToJson(json, createPermissionOptions.Permission); - json_body = json.dump(); - } - auto body = Azure::Core::IO::MemoryBodyStream( - reinterpret_cast(json_body.data()), json_body.length()); - auto request = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Put, url, &body); - request.SetHeader("Content-Length", std::to_string(body.Length())); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "filepermission"); - if (createPermissionOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(createPermissionOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, createPermissionOptions.ApiVersionParameter); - return CreatePermissionParseResult(context, pipeline.Send(request, context)); - } - - struct GetPermissionOptions final - { - std::string FilePermissionKeyRequired; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response GetPermission( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetPermissionOptions& getPermissionOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "filepermission"); - request.SetHeader( - _detail::HeaderFilePermissionKey, getPermissionOptions.FilePermissionKeyRequired); - if (getPermissionOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getPermissionOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getPermissionOptions.ApiVersionParameter); - return GetPermissionParseResult(context, pipeline.Send(request, context)); - } - - struct SetPropertiesOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable ShareQuota; - Azure::Nullable XMsAccessTier; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response SetProperties( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetPropertiesOptions& setPropertiesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "properties"); - if (setPropertiesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setPropertiesOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, setPropertiesOptions.ApiVersionParameter); - if (setPropertiesOptions.ShareQuota.HasValue()) - { - request.SetHeader( - _detail::HeaderQuota, std::to_string(setPropertiesOptions.ShareQuota.Value())); - } - if (setPropertiesOptions.XMsAccessTier.HasValue()) - { - request.SetHeader( - _detail::HeaderAccessTier, setPropertiesOptions.XMsAccessTier.Value().ToString()); - } - if (setPropertiesOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, setPropertiesOptions.LeaseIdOptional.Value()); - } - return SetPropertiesParseResult(context, pipeline.Send(request, context)); - } - - struct SetMetadataOptions final - { - Azure::Nullable Timeout; - Storage::Metadata Metadata; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response SetMetadata( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetMetadataOptions& setMetadataOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "metadata"); - if (setMetadataOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setMetadataOptions.Timeout.Value()))); - } - for (const auto& pair : setMetadataOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - request.SetHeader(_detail::HeaderVersion, setMetadataOptions.ApiVersionParameter); - if (setMetadataOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, setMetadataOptions.LeaseIdOptional.Value()); - } - return SetMetadataParseResult(context, pipeline.Send(request, context)); - } - - struct GetAccessPolicyOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response GetAccessPolicy( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetAccessPolicyOptions& getAccessPolicyOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "acl"); - if (getAccessPolicyOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getAccessPolicyOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getAccessPolicyOptions.ApiVersionParameter); - if (getAccessPolicyOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderLeaseId, getAccessPolicyOptions.LeaseIdOptional.Value()); - } - return GetAccessPolicyParseResult(context, pipeline.Send(request, context)); - } - - struct SetAccessPolicyOptions final - { - std::vector ShareAcl; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response SetAccessPolicy( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetAccessPolicyOptions& setAccessPolicyOptions) - { - - std::string xml_body; - { - _internal::XmlWriter writer; - SignedIdentifiersToXml(writer, setAccessPolicyOptions.ShareAcl); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::End}); - xml_body = writer.GetDocument(); - } - auto body = Azure::Core::IO::MemoryBodyStream( - reinterpret_cast(xml_body.data()), xml_body.length()); - auto request = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Put, url, &body); - request.SetHeader("Content-Length", std::to_string(body.Length())); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "acl"); - if (setAccessPolicyOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setAccessPolicyOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, setAccessPolicyOptions.ApiVersionParameter); - if (setAccessPolicyOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderLeaseId, setAccessPolicyOptions.LeaseIdOptional.Value()); - } - return SetAccessPolicyParseResult(context, pipeline.Send(request, context)); - } - - struct GetStatisticsOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response GetStatistics( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetStatisticsOptions& getStatisticsOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "stats"); - if (getStatisticsOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getStatisticsOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getStatisticsOptions.ApiVersionParameter); - if (getStatisticsOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, getStatisticsOptions.LeaseIdOptional.Value()); - } - return GetStatisticsParseResult(context, pipeline.Send(request, context)); - } - - struct RestoreOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable DeletedShareName; - Azure::Nullable DeletedShareVersion; - }; - - static Azure::Response Restore( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const RestoreOptions& restoreOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "share"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "undelete"); - if (restoreOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter(std::to_string(restoreOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, restoreOptions.ApiVersionParameter); - if (restoreOptions.DeletedShareName.HasValue()) - { - request.SetHeader( - _detail::HeaderDeletedShareName, restoreOptions.DeletedShareName.Value()); - } - if (restoreOptions.DeletedShareVersion.HasValue()) - { - request.SetHeader( - _detail::HeaderDeletedShareVersion, restoreOptions.DeletedShareVersion.Value()); - } - return RestoreParseResult(context, pipeline.Send(request, context)); - } - - private: - static Azure::Response CreateParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Success, Share created. - Models::CreateShareResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response GetPropertiesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - Models::ShareProperties result; - - for (auto i = response.GetHeaders().lower_bound(_detail::HeaderMetadata); - i != response.GetHeaders().end() - && i->first.substr(0, 9) == _detail::HeaderMetadata; - ++i) - { - result.Metadata.emplace(i->first.substr(10), i->second); - } - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.Quota = std::stoll(response.GetHeaders().at(_detail::HeaderQuota)); - if (response.GetHeaders().find(_detail::HeaderProvisionedIops) - != response.GetHeaders().end()) - { - result.ProvisionedIops - = std::stoi(response.GetHeaders().at(_detail::HeaderProvisionedIops)); - } - if (response.GetHeaders().find(_detail::HeaderProvisionedIngressMBps) - != response.GetHeaders().end()) - { - result.ProvisionedIngressMBps - = std::stoi(response.GetHeaders().at(_detail::HeaderProvisionedIngressMBps)); - } - if (response.GetHeaders().find(_detail::HeaderProvisionedEgressMBps) - != response.GetHeaders().end()) - { - result.ProvisionedEgressMBps - = std::stoi(response.GetHeaders().at(_detail::HeaderProvisionedEgressMBps)); - } - if (response.GetHeaders().find(_detail::HeaderNextAllowedQuotaDowngradeTime) - != response.GetHeaders().end()) - { - result.NextAllowedQuotaDowngradeTime = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderNextAllowedQuotaDowngradeTime), - DateTime::DateFormat::Rfc1123); - } - if (response.GetHeaders().find(_detail::HeaderLeaseDuration) - != response.GetHeaders().end()) - { - result.LeaseDuration - = LeaseDuration(response.GetHeaders().at(_detail::HeaderLeaseDuration)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseState) - != response.GetHeaders().end()) - { - result.LeaseState = LeaseState(response.GetHeaders().at(_detail::HeaderLeaseState)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseStatus) - != response.GetHeaders().end()) - { - result.LeaseStatus - = LeaseStatus(response.GetHeaders().at(_detail::HeaderLeaseStatus)); - } - if (response.GetHeaders().find("x-ms-access-tier") != response.GetHeaders().end()) - { - result.AccessTier = AccessTier(response.GetHeaders().at("x-ms-access-tier")); - } - if (response.GetHeaders().find(_detail::HeaderAccessTierChangedOn) - != response.GetHeaders().end()) - { - result.AccessTierChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderAccessTierChangedOn), - DateTime::DateFormat::Rfc1123); - } - if (response.GetHeaders().find(_detail::HeaderAccessTierTransitionState) - != response.GetHeaders().end()) - { - result.AccessTierTransitionState - = response.GetHeaders().at(_detail::HeaderAccessTierTransitionState); - } - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response DeleteParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Accepted) - { - // Accepted - Models::DeleteShareResult result; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response AcquireLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // The Acquire operation completed successfully. - Models::AcquireLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.LeaseId = response.GetHeaders().at(_detail::HeaderLeaseId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response ReleaseLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // The Release operation completed successfully. - Models::ReleaseLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response ChangeLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // The Change operation completed successfully. - Models::ChangeLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.LeaseId = response.GetHeaders().at(_detail::HeaderLeaseId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response RenewLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // The Renew operation completed successfully. - Models::RenewLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.LeaseId = response.GetHeaders().at(_detail::HeaderLeaseId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response BreakLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Accepted) - { - // The Break operation completed successfully. - Models::BreakLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response CreateSnapshotParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Success, Share snapshot created. - Models::CreateShareSnapshotResult result; - result.Snapshot = response.GetHeaders().at(_detail::HeaderSnapshot); - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response CreatePermissionParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Success, Share level permission created. - Models::CreateSharePermissionResult result; - result.FilePermissionKey = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static void SharePermissionToJson( - Azure::Core::Json::_internal::json& node, - const SharePermission& object) - { - node["permission"] = object.FilePermission; - } - - static Azure::Response GetPermissionParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - const auto& bodyBuffer = response.GetBody(); - ShareGetPermissionResult result = bodyBuffer.empty() - ? ShareGetPermissionResult() - : ShareGetPermissionResultFromSharePermission( - SharePermissionFromJson(Azure::Core::Json::_internal::json::parse(bodyBuffer))); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static SharePermission SharePermissionFromJson( - const Azure::Core::Json::_internal::json& node) - { - SharePermission result; - result.FilePermission = node["permission"].get(); - return result; - } - - static ShareGetPermissionResult ShareGetPermissionResultFromSharePermission( - SharePermission object) - { - ShareGetPermissionResult result; - result.FilePermission = std::move(object.FilePermission); - - return result; - } - static Azure::Response SetPropertiesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - Models::SetSharePropertiesResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response SetMetadataParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - Models::SetShareMetadataResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response GetAccessPolicyParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - Models::ShareAccessPolicy result = bodyBuffer.empty() - ? Models::ShareAccessPolicy() - : ShareAccessPolicyFromSignedIdentifiers(SignedIdentifiersFromXml(reader)); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static AccessPolicy AccessPolicyFromXml(_internal::XmlReader& reader) - { - auto result = AccessPolicy(); - enum class XmlTagName - { - Expiry, - Permission, - Start, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Expiry") == 0) - { - path.emplace_back(XmlTagName::Expiry); - } - else if (std::strcmp(node.Name.data(), "Permission") == 0) - { - path.emplace_back(XmlTagName::Permission); - } - else if (std::strcmp(node.Name.data(), "Start") == 0) - { - path.emplace_back(XmlTagName::Start); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Expiry) - { - result.ExpiresOn = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc3339); - } - else if (path.size() == 1 && path[0] == XmlTagName::Permission) - { - result.Permission = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::Start) - { - result.StartsOn = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc3339); - } - } - } - return result; - } - - static SignedIdentifier SignedIdentifierFromXml(_internal::XmlReader& reader) - { - auto result = SignedIdentifier(); - enum class XmlTagName - { - AccessPolicy, - Id, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "AccessPolicy") == 0) - { - path.emplace_back(XmlTagName::AccessPolicy); - } - else if (std::strcmp(node.Name.data(), "Id") == 0) - { - path.emplace_back(XmlTagName::Id); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 1 && path[0] == XmlTagName::AccessPolicy) - { - result.Policy = AccessPolicyFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Id) - { - result.Id = node.Value; - } - } - } - return result; - } - - static std::vector SignedIdentifiersFromXml(_internal::XmlReader& reader) - { - auto result = std::vector(); - enum class XmlTagName - { - SignedIdentifier, - SignedIdentifiers, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "SignedIdentifier") == 0) - { - path.emplace_back(XmlTagName::SignedIdentifier); - } - else if (std::strcmp(node.Name.data(), "SignedIdentifiers") == 0) - { - path.emplace_back(XmlTagName::SignedIdentifiers); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 2 && path[0] == XmlTagName::SignedIdentifiers - && path[1] == XmlTagName::SignedIdentifier) - { - result.emplace_back(SignedIdentifierFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return result; - } - - static Models::ShareAccessPolicy ShareAccessPolicyFromSignedIdentifiers( - std::vector object) - { - Models::ShareAccessPolicy result; - result.SignedIdentifiers = std::move(object); - - return result; - } - static Azure::Response SetAccessPolicyParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - Models::SetShareAccessPolicyResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static void AccessPolicyToXml(_internal::XmlWriter& writer, const AccessPolicy& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "AccessPolicy"}); - if (object.StartsOn.HasValue()) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Start"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, - std::string(), - object.StartsOn.Value().ToString( - Azure::DateTime::DateFormat::Rfc3339, - DateTime::TimeFractionFormat::AllDigits)}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - if (object.ExpiresOn.HasValue()) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Expiry"}); - writer.Write(_internal::XmlNode{ - _internal::XmlNodeType::Text, - std::string(), - object.ExpiresOn.Value().ToString( - Azure::DateTime::DateFormat::Rfc3339, - DateTime::TimeFractionFormat::AllDigits)}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Permission"}); - writer.Write( - _internal::XmlNode{_internal::XmlNodeType::Text, std::string(), object.Permission}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - - static void SignedIdentifierToXml( - _internal::XmlWriter& writer, - const SignedIdentifier& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "SignedIdentifier"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Id"}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::Text, std::string(), object.Id}); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - AccessPolicyToXml(writer, object.Policy); - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - - static void SignedIdentifiersToXml( - _internal::XmlWriter& writer, - const std::vector& object) - { - writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "SignedIdentifiers"}); - for (const auto& item : object) - { - SignedIdentifierToXml(writer, item); - } - writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); - } - static Azure::Response GetStatisticsParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - Models::ShareStatistics result = bodyBuffer.empty() - ? Models::ShareStatistics() - : ShareStatisticsFromShareStats(ShareStatsFromXml(reader)); - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static ShareStats ShareStatsFromXml(_internal::XmlReader& reader) - { - auto result = ShareStats(); - enum class XmlTagName - { - ShareStats, - ShareUsageBytes, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "ShareStats") == 0) - { - path.emplace_back(XmlTagName::ShareStats); - } - else if (std::strcmp(node.Name.data(), "ShareUsageBytes") == 0) - { - path.emplace_back(XmlTagName::ShareUsageBytes); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 2 && path[0] == XmlTagName::ShareStats - && path[1] == XmlTagName::ShareUsageBytes) - { - result.ShareUsageInBytes = std::stoll(node.Value); - } - } - } - return result; - } - - static Models::ShareStatistics ShareStatisticsFromShareStats(ShareStats object) - { - Models::ShareStatistics result; - result.ShareUsageInBytes = object.ShareUsageInBytes; - - return result; - } - static Azure::Response RestoreParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Created - ShareRestoreResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response(std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - }; - - class Directory final { - public: - struct CreateOptions final - { - Azure::Nullable Timeout; - Storage::Metadata Metadata; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable FilePermission; - Azure::Nullable FilePermissionKey; - std::string FileAttributes; - std::string FileCreationTime; - std::string FileLastWriteTime; - }; - - static Azure::Response Create( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const CreateOptions& createOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "directory"); - if (createOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter(std::to_string(createOptions.Timeout.Value()))); - } - for (const auto& pair : createOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - request.SetHeader(_detail::HeaderVersion, createOptions.ApiVersionParameter); - if (createOptions.FilePermission.HasValue()) - { - request.SetHeader(_detail::HeaderFilePermission, createOptions.FilePermission.Value()); - } - if (createOptions.FilePermissionKey.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermissionKey, createOptions.FilePermissionKey.Value()); - } - request.SetHeader(_detail::HeaderFileAttributes, createOptions.FileAttributes); - request.SetHeader(_detail::HeaderFileCreatedOn, createOptions.FileCreationTime); - request.SetHeader(_detail::HeaderFileLastWrittenOn, createOptions.FileLastWriteTime); - return CreateParseResult(context, pipeline.Send(request, context)); - } - - struct GetPropertiesOptions final - { - Azure::Nullable ShareSnapshot; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response GetProperties( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetPropertiesOptions& getPropertiesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "directory"); - if (getPropertiesOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(getPropertiesOptions.ShareSnapshot.Value())); - } - if (getPropertiesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getPropertiesOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getPropertiesOptions.ApiVersionParameter); - return GetPropertiesParseResult(context, pipeline.Send(request, context)); - } - - struct DeleteOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response Delete( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const DeleteOptions& deleteOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Delete, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "directory"); - if (deleteOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter(std::to_string(deleteOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, deleteOptions.ApiVersionParameter); - return DeleteParseResult(context, pipeline.Send(request, context)); - } - - struct SetPropertiesOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable FilePermission; - Azure::Nullable FilePermissionKey; - std::string FileAttributes; - std::string FileCreationTime; - std::string FileLastWriteTime; - }; - - static Azure::Response SetProperties( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetPropertiesOptions& setPropertiesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "directory"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "properties"); - if (setPropertiesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setPropertiesOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, setPropertiesOptions.ApiVersionParameter); - if (setPropertiesOptions.FilePermission.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermission, setPropertiesOptions.FilePermission.Value()); - } - if (setPropertiesOptions.FilePermissionKey.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermissionKey, setPropertiesOptions.FilePermissionKey.Value()); - } - request.SetHeader(_detail::HeaderFileAttributes, setPropertiesOptions.FileAttributes); - request.SetHeader(_detail::HeaderFileCreatedOn, setPropertiesOptions.FileCreationTime); - request.SetHeader( - _detail::HeaderFileLastWrittenOn, setPropertiesOptions.FileLastWriteTime); - return SetPropertiesParseResult(context, pipeline.Send(request, context)); - } - - struct SetMetadataOptions final - { - Azure::Nullable Timeout; - Storage::Metadata Metadata; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response SetMetadata( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetMetadataOptions& setMetadataOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "directory"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "metadata"); - if (setMetadataOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setMetadataOptions.Timeout.Value()))); - } - for (const auto& pair : setMetadataOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - request.SetHeader(_detail::HeaderVersion, setMetadataOptions.ApiVersionParameter); - return SetMetadataParseResult(context, pipeline.Send(request, context)); - } - - struct ListFilesAndDirectoriesSinglePageOptions final - { - Azure::Nullable Prefix; - Azure::Nullable ShareSnapshot; - Azure::Nullable ContinuationToken; - Azure::Nullable MaxResults; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response - ListFilesAndDirectoriesSinglePage( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ListFilesAndDirectoriesSinglePageOptions& - listFilesAndDirectoriesSinglePageOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryRestype, "directory"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "list"); - if (listFilesAndDirectoriesSinglePageOptions.Prefix.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryPrefix, - _internal::UrlEncodeQueryParameter( - listFilesAndDirectoriesSinglePageOptions.Prefix.Value())); - } - if (listFilesAndDirectoriesSinglePageOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter( - listFilesAndDirectoriesSinglePageOptions.ShareSnapshot.Value())); - } - if (listFilesAndDirectoriesSinglePageOptions.ContinuationToken.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryContinuationToken, - _internal::UrlEncodeQueryParameter( - listFilesAndDirectoriesSinglePageOptions.ContinuationToken.Value())); - } - if (listFilesAndDirectoriesSinglePageOptions.MaxResults.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryPageSizeHint, - _internal::UrlEncodeQueryParameter( - std::to_string(listFilesAndDirectoriesSinglePageOptions.MaxResults.Value()))); - } - if (listFilesAndDirectoriesSinglePageOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(listFilesAndDirectoriesSinglePageOptions.Timeout.Value()))); - } - request.SetHeader( - _detail::HeaderVersion, listFilesAndDirectoriesSinglePageOptions.ApiVersionParameter); - return ListFilesAndDirectoriesSinglePageParseResult( - context, pipeline.Send(request, context)); - } - - struct ListHandlesOptions final - { - Azure::Nullable ContinuationToken; - Azure::Nullable MaxResults; - Azure::Nullable Timeout; - Azure::Nullable ShareSnapshot; - Azure::Nullable Recursive; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response ListHandles( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ListHandlesOptions& listHandlesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "listhandles"); - if (listHandlesOptions.ContinuationToken.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryContinuationToken, - _internal::UrlEncodeQueryParameter(listHandlesOptions.ContinuationToken.Value())); - } - if (listHandlesOptions.MaxResults.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryPageSizeHint, - _internal::UrlEncodeQueryParameter( - std::to_string(listHandlesOptions.MaxResults.Value()))); - } - if (listHandlesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(listHandlesOptions.Timeout.Value()))); - } - if (listHandlesOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(listHandlesOptions.ShareSnapshot.Value())); - } - if (listHandlesOptions.Recursive.HasValue()) - { - request.SetHeader( - _detail::HeaderRecursive, - (listHandlesOptions.Recursive.Value() ? "true" : "false")); - } - request.SetHeader(_detail::HeaderVersion, listHandlesOptions.ApiVersionParameter); - return ListHandlesParseResult(context, pipeline.Send(request, context)); - } - - struct ForceCloseHandlesOptions final - { - Azure::Nullable Timeout; - Azure::Nullable ContinuationToken; - Azure::Nullable ShareSnapshot; - std::string HandleId; - Azure::Nullable Recursive; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response ForceCloseHandles( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ForceCloseHandlesOptions& forceCloseHandlesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "forceclosehandles"); - if (forceCloseHandlesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(forceCloseHandlesOptions.Timeout.Value()))); - } - if (forceCloseHandlesOptions.ContinuationToken.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryContinuationToken, - _internal::UrlEncodeQueryParameter( - forceCloseHandlesOptions.ContinuationToken.Value())); - } - if (forceCloseHandlesOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(forceCloseHandlesOptions.ShareSnapshot.Value())); - } - request.SetHeader(_detail::HeaderHandleId, forceCloseHandlesOptions.HandleId); - if (forceCloseHandlesOptions.Recursive.HasValue()) - { - request.SetHeader( - _detail::HeaderRecursive, - (forceCloseHandlesOptions.Recursive.Value() ? "true" : "false")); - } - request.SetHeader(_detail::HeaderVersion, forceCloseHandlesOptions.ApiVersionParameter); - return ForceCloseHandlesParseResult(context, pipeline.Send(request, context)); - } - - private: - static Azure::Response CreateParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Success, Directory created. - Models::CreateDirectoryResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response GetPropertiesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - Models::DirectoryProperties result; - - for (auto i = response.GetHeaders().lower_bound(_detail::HeaderMetadata); - i != response.GetHeaders().end() - && i->first.substr(0, 9) == _detail::HeaderMetadata; - ++i) - { - result.Metadata.emplace(i->first.substr(10), i->second); - } - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderIsServerEncrypted) == "true"; - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response DeleteParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Accepted) - { - // Success (Accepted). - Models::DeleteDirectoryResult result; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response SetPropertiesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - Models::SetDirectoryPropertiesResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response SetMetadataParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success (OK). - Models::SetDirectoryMetadataResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response - ListFilesAndDirectoriesSinglePageParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - DirectoryListFilesAndDirectoriesSinglePageResult result = bodyBuffer.empty() - ? DirectoryListFilesAndDirectoriesSinglePageResult() - : DirectoryListFilesAndDirectoriesSinglePageResultFromListFilesAndDirectoriesSinglePageResponse( - ListFilesAndDirectoriesSinglePageResponseFromXml(reader)); - result.HttpHeaders.ContentType = response.GetHeaders().at(_detail::HeaderContentType); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static DirectoryItem DirectoryItemFromXml(_internal::XmlReader& reader) - { - auto result = DirectoryItem(); - enum class XmlTagName - { - Name, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Name") == 0) - { - path.emplace_back(XmlTagName::Name); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Name) - { - result.Name = node.Value; - } - } - } - return result; - } - - static FileItemDetails FileItemDetailsFromXml(_internal::XmlReader& reader) - { - auto result = FileItemDetails(); - enum class XmlTagName - { - ContentLength, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Content-Length") == 0) - { - path.emplace_back(XmlTagName::ContentLength); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::ContentLength) - { - result.FileSize = std::stoll(node.Value); - } - } - } - return result; - } - - static FileItem FileItemFromXml(_internal::XmlReader& reader) - { - auto result = FileItem(); - enum class XmlTagName - { - Name, - Properties, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Name") == 0) - { - path.emplace_back(XmlTagName::Name); - } - else if (std::strcmp(node.Name.data(), "Properties") == 0) - { - path.emplace_back(XmlTagName::Properties); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 1 && path[0] == XmlTagName::Properties) - { - result.Details = FileItemDetailsFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::Name) - { - result.Name = node.Value; - } - } - } - return result; - } - - static FilesAndDirectoriesListSinglePage FilesAndDirectoriesListSinglePageFromXml( - _internal::XmlReader& reader) - { - auto result = FilesAndDirectoriesListSinglePage(); - enum class XmlTagName - { - Directory, - File, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Directory") == 0) - { - path.emplace_back(XmlTagName::Directory); - } - else if (std::strcmp(node.Name.data(), "File") == 0) - { - path.emplace_back(XmlTagName::File); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - if (path.size() == 1 && path[0] == XmlTagName::Directory) - { - result.DirectoryItems.emplace_back(DirectoryItemFromXml(reader)); - path.pop_back(); - } - else if (path.size() == 1 && path[0] == XmlTagName::File) - { - result.FileItems.emplace_back(FileItemFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return result; - } - - static ListFilesAndDirectoriesSinglePageResponse - ListFilesAndDirectoriesSinglePageResponseFromXml(_internal::XmlReader& reader) - { - auto result = ListFilesAndDirectoriesSinglePageResponse(); - enum class XmlTagName - { - Entries, - EnumerationResults, - MaxResults, - NextMarker, - Prefix, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Entries") == 0) - { - path.emplace_back(XmlTagName::Entries); - } - else if (std::strcmp(node.Name.data(), "EnumerationResults") == 0) - { - path.emplace_back(XmlTagName::EnumerationResults); - } - else if (std::strcmp(node.Name.data(), "MaxResults") == 0) - { - path.emplace_back(XmlTagName::MaxResults); - } - else if (std::strcmp(node.Name.data(), "NextMarker") == 0) - { - path.emplace_back(XmlTagName::NextMarker); - } - else if (std::strcmp(node.Name.data(), "Prefix") == 0) - { - path.emplace_back(XmlTagName::Prefix); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - - if (path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::Entries) - { - result.SinglePage = FilesAndDirectoriesListSinglePageFromXml(reader); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::NextMarker) - { - result.ContinuationToken = node.Value; - } - else if ( - path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::MaxResults) - { - result.PageSizeHint = std::stoi(node.Value); - } - else if ( - path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::Prefix) - { - result.Prefix = node.Value; - } - } - else if (node.Type == _internal::XmlNodeType::Attribute) - { - if (path.size() == 1 && path[0] == XmlTagName::EnumerationResults - && (std::strcmp(node.Name.data(), "DirectoryPath") == 0)) - { - result.DirectoryPath = node.Value; - } - else if ( - path.size() == 1 && path[0] == XmlTagName::EnumerationResults - && (std::strcmp(node.Name.data(), "ServiceEndpoint") == 0)) - { - result.ServiceEndpoint = node.Value; - } - else if ( - path.size() == 1 && path[0] == XmlTagName::EnumerationResults - && (std::strcmp(node.Name.data(), "ShareName") == 0)) - { - result.ShareName = node.Value; - } - else if ( - path.size() == 1 && path[0] == XmlTagName::EnumerationResults - && (std::strcmp(node.Name.data(), "ShareSnapshot") == 0)) - { - result.ShareSnapshot = node.Value; - } - } - } - return result; - } - - static DirectoryListFilesAndDirectoriesSinglePageResult - DirectoryListFilesAndDirectoriesSinglePageResultFromListFilesAndDirectoriesSinglePageResponse( - ListFilesAndDirectoriesSinglePageResponse object) - { - DirectoryListFilesAndDirectoriesSinglePageResult result; - result.ServiceEndpoint = std::move(object.ServiceEndpoint); - result.ShareName = std::move(object.ShareName); - result.ShareSnapshot = std::move(object.ShareSnapshot); - result.DirectoryPath = std::move(object.DirectoryPath); - result.Prefix = std::move(object.Prefix); - result.PageSizeHint = object.PageSizeHint; - result.SinglePage = std::move(object.SinglePage); - result.ContinuationToken = std::move(object.ContinuationToken); - - return result; - } - static Azure::Response ListHandlesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - DirectoryListHandlesResult result = bodyBuffer.empty() - ? DirectoryListHandlesResult() - : DirectoryListHandlesResultFromListHandlesResponse( - ListHandlesResponseFromXml(reader)); - result.HttpHeaders.ContentType = response.GetHeaders().at(_detail::HeaderContentType); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static HandleItem HandleItemFromXml(_internal::XmlReader& reader) - { - auto result = HandleItem(); - enum class XmlTagName - { - ClientIp, - FileId, - HandleId, - LastReconnectTime, - OpenTime, - ParentId, - Path, - SessionId, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "ClientIp") == 0) - { - path.emplace_back(XmlTagName::ClientIp); - } - else if (std::strcmp(node.Name.data(), "FileId") == 0) - { - path.emplace_back(XmlTagName::FileId); - } - else if (std::strcmp(node.Name.data(), "HandleId") == 0) - { - path.emplace_back(XmlTagName::HandleId); - } - else if (std::strcmp(node.Name.data(), "LastReconnectTime") == 0) - { - path.emplace_back(XmlTagName::LastReconnectTime); - } - else if (std::strcmp(node.Name.data(), "OpenTime") == 0) - { - path.emplace_back(XmlTagName::OpenTime); - } - else if (std::strcmp(node.Name.data(), "ParentId") == 0) - { - path.emplace_back(XmlTagName::ParentId); - } - else if (std::strcmp(node.Name.data(), "Path") == 0) - { - path.emplace_back(XmlTagName::Path); - } - else if (std::strcmp(node.Name.data(), "SessionId") == 0) - { - path.emplace_back(XmlTagName::SessionId); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::ClientIp) - { - result.ClientIp = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::FileId) - { - result.FileId = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::HandleId) - { - result.HandleId = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::LastReconnectTime) - { - result.LastReconnectedOn - = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::OpenTime) - { - result.OpenedOn = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::ParentId) - { - result.ParentId = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::Path) - { - result.Path = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::SessionId) - { - result.SessionId = node.Value; - } - } - } - return result; - } - - static ListHandlesResponse ListHandlesResponseFromXml(_internal::XmlReader& reader) - { - auto result = ListHandlesResponse(); - enum class XmlTagName - { - Entries, - EnumerationResults, - Handle, - NextMarker, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Entries") == 0) - { - path.emplace_back(XmlTagName::Entries); - } - else if (std::strcmp(node.Name.data(), "EnumerationResults") == 0) - { - path.emplace_back(XmlTagName::EnumerationResults); - } - else if (std::strcmp(node.Name.data(), "Handle") == 0) - { - path.emplace_back(XmlTagName::Handle); - } - else if (std::strcmp(node.Name.data(), "NextMarker") == 0) - { - path.emplace_back(XmlTagName::NextMarker); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - if (path.size() == 3 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::Entries && path[2] == XmlTagName::Handle) - { - result.HandleList.emplace_back(HandleItemFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::NextMarker) - { - result.ContinuationToken = node.Value; - } - } - } - return result; - } - - static DirectoryListHandlesResult DirectoryListHandlesResultFromListHandlesResponse( - ListHandlesResponse object) - { - DirectoryListHandlesResult result; - result.HandleList = std::move(object.HandleList); - result.ContinuationToken = std::move(object.ContinuationToken); - - return result; - } - static Azure::Response ForceCloseHandlesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - DirectoryForceCloseHandlesResult result; - if (response.GetHeaders().find(_detail::HeaderContinuationToken) - != response.GetHeaders().end()) - { - result.ContinuationToken = response.GetHeaders().at(_detail::HeaderContinuationToken); - } - result.NumberOfHandlesClosed - = std::stoi(response.GetHeaders().at(_detail::HeaderNumberOfHandlesClosed)); - result.NumberOfHandlesFailedToClose - = std::stoi(response.GetHeaders().at(_detail::HeaderNumberOfHandlesFailedToClose)); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - }; - - class File final { - public: - struct CreateOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - int64_t XMsContentLength = int64_t(); - Azure::Nullable FileContentType; - Azure::Nullable FileContentEncoding; - Azure::Nullable FileContentLanguage; - Azure::Nullable FileCacheControl; - Azure::Nullable ContentMd5; - Azure::Nullable FileContentDisposition; - Storage::Metadata Metadata; - Azure::Nullable FilePermission; - Azure::Nullable FilePermissionKey; - std::string FileAttributes; - std::string FileCreationTime; - std::string FileLastWriteTime; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response Create( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const CreateOptions& createOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - if (createOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter(std::to_string(createOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, createOptions.ApiVersionParameter); - request.SetHeader( - _detail::HeaderXMsContentLength, std::to_string(createOptions.XMsContentLength)); - request.SetHeader(_detail::HeaderFileTypeConstant, "file"); - if (createOptions.FileContentType.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentType, createOptions.FileContentType.Value()); - } - if (createOptions.FileContentEncoding.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentEncoding, createOptions.FileContentEncoding.Value()); - } - if (createOptions.FileContentLanguage.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentLanguage, createOptions.FileContentLanguage.Value()); - } - if (createOptions.FileCacheControl.HasValue()) - { - request.SetHeader( - _detail::HeaderFileCacheControl, createOptions.FileCacheControl.Value()); - } - if (createOptions.ContentMd5.HasValue()) - { - request.SetHeader( - _detail::HeaderContentHashMd5, - _internal::ToBase64String(createOptions.ContentMd5.Value())); - } - if (createOptions.FileContentDisposition.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentDisposition, - createOptions.FileContentDisposition.Value()); - } - for (const auto& pair : createOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - if (createOptions.FilePermission.HasValue()) - { - request.SetHeader(_detail::HeaderFilePermission, createOptions.FilePermission.Value()); - } - if (createOptions.FilePermissionKey.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermissionKey, createOptions.FilePermissionKey.Value()); - } - request.SetHeader(_detail::HeaderFileAttributes, createOptions.FileAttributes); - request.SetHeader(_detail::HeaderFileCreatedOn, createOptions.FileCreationTime); - request.SetHeader(_detail::HeaderFileLastWrittenOn, createOptions.FileLastWriteTime); - if (createOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, createOptions.LeaseIdOptional.Value()); - } - return CreateParseResult(context, pipeline.Send(request, context)); - } - - struct DownloadOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable Range; - Azure::Nullable GetRangeContentMd5; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response Download( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const DownloadOptions& downloadOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url, false); - if (downloadOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(downloadOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, downloadOptions.ApiVersionParameter); - if (downloadOptions.Range.HasValue()) - { - request.SetHeader(_detail::HeaderRange, downloadOptions.Range.Value()); - } - if (downloadOptions.GetRangeContentMd5.HasValue()) - { - request.SetHeader( - _detail::HeaderRangeGetContentMd5, - (downloadOptions.GetRangeContentMd5.Value() ? "true" : "false")); - } - if (downloadOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, downloadOptions.LeaseIdOptional.Value()); - } - return DownloadParseResult(context, pipeline.Send(request, context)); - } - - struct GetPropertiesOptions final - { - Azure::Nullable ShareSnapshot; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response GetProperties( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetPropertiesOptions& getPropertiesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Head, url); - if (getPropertiesOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(getPropertiesOptions.ShareSnapshot.Value())); - } - if (getPropertiesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getPropertiesOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getPropertiesOptions.ApiVersionParameter); - if (getPropertiesOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, getPropertiesOptions.LeaseIdOptional.Value()); - } - return GetPropertiesParseResult(context, pipeline.Send(request, context)); - } - - struct DeleteOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response Delete( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const DeleteOptions& deleteOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Delete, url); - if (deleteOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter(std::to_string(deleteOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, deleteOptions.ApiVersionParameter); - if (deleteOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, deleteOptions.LeaseIdOptional.Value()); - } - return DeleteParseResult(context, pipeline.Send(request, context)); - } - - struct SetHttpHeadersOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable XMsContentLength; - Azure::Nullable FileContentType; - Azure::Nullable FileContentEncoding; - Azure::Nullable FileContentLanguage; - Azure::Nullable FileCacheControl; - Azure::Nullable ContentMd5; - Azure::Nullable FileContentDisposition; - Azure::Nullable FilePermission; - Azure::Nullable FilePermissionKey; - std::string FileAttributes; - std::string FileCreationTime; - std::string FileLastWriteTime; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response SetHttpHeaders( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetHttpHeadersOptions& setHttpHeadersOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "properties"); - if (setHttpHeadersOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setHttpHeadersOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, setHttpHeadersOptions.ApiVersionParameter); - if (setHttpHeadersOptions.XMsContentLength.HasValue()) - { - request.SetHeader( - _detail::HeaderXMsContentLength, - std::to_string(setHttpHeadersOptions.XMsContentLength.Value())); - } - if (setHttpHeadersOptions.FileContentType.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentType, setHttpHeadersOptions.FileContentType.Value()); - } - if (setHttpHeadersOptions.FileContentEncoding.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentEncoding, - setHttpHeadersOptions.FileContentEncoding.Value()); - } - if (setHttpHeadersOptions.FileContentLanguage.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentLanguage, - setHttpHeadersOptions.FileContentLanguage.Value()); - } - if (setHttpHeadersOptions.FileCacheControl.HasValue()) - { - request.SetHeader( - _detail::HeaderFileCacheControl, setHttpHeadersOptions.FileCacheControl.Value()); - } - if (setHttpHeadersOptions.ContentMd5.HasValue()) - { - request.SetHeader( - _detail::HeaderContentHashMd5, - _internal::ToBase64String(setHttpHeadersOptions.ContentMd5.Value())); - } - if (setHttpHeadersOptions.FileContentDisposition.HasValue()) - { - request.SetHeader( - _detail::HeaderFileContentDisposition, - setHttpHeadersOptions.FileContentDisposition.Value()); - } - if (setHttpHeadersOptions.FilePermission.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermission, setHttpHeadersOptions.FilePermission.Value()); - } - if (setHttpHeadersOptions.FilePermissionKey.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermissionKey, setHttpHeadersOptions.FilePermissionKey.Value()); - } - request.SetHeader(_detail::HeaderFileAttributes, setHttpHeadersOptions.FileAttributes); - request.SetHeader(_detail::HeaderFileCreatedOn, setHttpHeadersOptions.FileCreationTime); - request.SetHeader( - _detail::HeaderFileLastWrittenOn, setHttpHeadersOptions.FileLastWriteTime); - if (setHttpHeadersOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderLeaseId, setHttpHeadersOptions.LeaseIdOptional.Value()); - } - return SetHttpHeadersParseResult(context, pipeline.Send(request, context)); - } - - struct SetMetadataOptions final - { - Azure::Nullable Timeout; - Storage::Metadata Metadata; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response SetMetadata( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const SetMetadataOptions& setMetadataOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "metadata"); - if (setMetadataOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(setMetadataOptions.Timeout.Value()))); - } - for (const auto& pair : setMetadataOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - request.SetHeader(_detail::HeaderVersion, setMetadataOptions.ApiVersionParameter); - if (setMetadataOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, setMetadataOptions.LeaseIdOptional.Value()); - } - return SetMetadataParseResult(context, pipeline.Send(request, context)); - } - - struct AcquireLeaseOptions final - { - Azure::Nullable Timeout; - int32_t LeaseDuration = int32_t(); - Azure::Nullable ProposedLeaseIdOptional; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response AcquireLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const AcquireLeaseOptions& acquireLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "acquire"); - if (acquireLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(acquireLeaseOptions.Timeout.Value()))); - } - request.SetHeader( - _detail::HeaderDuration, std::to_string(acquireLeaseOptions.LeaseDuration)); - if (acquireLeaseOptions.ProposedLeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderProposedLeaseId, - acquireLeaseOptions.ProposedLeaseIdOptional.Value()); - } - request.SetHeader(_detail::HeaderVersion, acquireLeaseOptions.ApiVersionParameter); - return AcquireLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct ReleaseLeaseOptions final - { - Azure::Nullable Timeout; - std::string LeaseIdRequired; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response ReleaseLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ReleaseLeaseOptions& releaseLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "release"); - if (releaseLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(releaseLeaseOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderLeaseId, releaseLeaseOptions.LeaseIdRequired); - request.SetHeader(_detail::HeaderVersion, releaseLeaseOptions.ApiVersionParameter); - return ReleaseLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct ChangeLeaseOptions final - { - Azure::Nullable Timeout; - std::string LeaseIdRequired; - Azure::Nullable ProposedLeaseIdOptional; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response ChangeLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ChangeLeaseOptions& changeLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "change"); - if (changeLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(changeLeaseOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderLeaseId, changeLeaseOptions.LeaseIdRequired); - if (changeLeaseOptions.ProposedLeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderProposedLeaseId, changeLeaseOptions.ProposedLeaseIdOptional.Value()); - } - request.SetHeader(_detail::HeaderVersion, changeLeaseOptions.ApiVersionParameter); - return ChangeLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct BreakLeaseOptions final - { - Azure::Nullable Timeout; - Azure::Nullable LeaseIdOptional; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response BreakLease( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const BreakLeaseOptions& breakLeaseOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "lease"); - request.SetHeader(_detail::HeaderAction, "break"); - if (breakLeaseOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(breakLeaseOptions.Timeout.Value()))); - } - if (breakLeaseOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, breakLeaseOptions.LeaseIdOptional.Value()); - } - request.SetHeader(_detail::HeaderVersion, breakLeaseOptions.ApiVersionParameter); - return BreakLeaseParseResult(context, pipeline.Send(request, context)); - } - - struct UploadRangeOptions final - { - Azure::Nullable Timeout; - std::string XMsRange; - FileRangeWrite XMsWrite; - int64_t ContentLength = int64_t(); - Azure::Nullable ContentMd5; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response UploadRange( - const Azure::Core::Url& url, - Azure::Core::IO::BodyStream& bodyStream, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const UploadRangeOptions& uploadRangeOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url, &bodyStream); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "range"); - if (uploadRangeOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(uploadRangeOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderXMsRange, uploadRangeOptions.XMsRange); - request.SetHeader(_detail::HeaderFileRangeWrite, uploadRangeOptions.XMsWrite.ToString()); - request.SetHeader( - _detail::HeaderContentLength, std::to_string(uploadRangeOptions.ContentLength)); - if (uploadRangeOptions.ContentMd5.HasValue()) - { - request.SetHeader( - _detail::HeaderContentHashMd5, - _internal::ToBase64String(uploadRangeOptions.ContentMd5.Value())); - } - request.SetHeader(_detail::HeaderVersion, uploadRangeOptions.ApiVersionParameter); - if (uploadRangeOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, uploadRangeOptions.LeaseIdOptional.Value()); - } - return UploadRangeParseResult(context, pipeline.Send(request, context)); - } - - struct UploadRangeFromUrlOptions final - { - Azure::Nullable Timeout; - std::string TargetRange; - std::string CopySource; - Azure::Nullable SourceRange; - FileRangeWriteFromUrl XMsWrite; - int64_t ContentLength = int64_t(); - Azure::Nullable SourceContentCrc64; - Azure::Nullable SourceIfMatchCrc64; - Azure::Nullable SourceIfNoneMatchCrc64; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response UploadRangeFromUrl( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const UploadRangeFromUrlOptions& uploadRangeFromUrlOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "range"); - if (uploadRangeFromUrlOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(uploadRangeFromUrlOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderRange, uploadRangeFromUrlOptions.TargetRange); - request.SetHeader(_detail::HeaderCopySource, uploadRangeFromUrlOptions.CopySource); - if (uploadRangeFromUrlOptions.SourceRange.HasValue()) - { - request.SetHeader( - _detail::HeaderSourceRange, uploadRangeFromUrlOptions.SourceRange.Value()); - } - request.SetHeader( - _detail::HeaderFileRangeWriteFromUrl, uploadRangeFromUrlOptions.XMsWrite.ToString()); - request.SetHeader( - _detail::HeaderContentLength, - std::to_string(uploadRangeFromUrlOptions.ContentLength)); - if (uploadRangeFromUrlOptions.SourceContentCrc64.HasValue()) - { - request.SetHeader( - _detail::HeaderSourceContentHashCrc64, - _internal::ToBase64String(uploadRangeFromUrlOptions.SourceContentCrc64.Value())); - } - if (uploadRangeFromUrlOptions.SourceIfMatchCrc64.HasValue()) - { - request.SetHeader( - _detail::HeaderSourceIfMatchHashCrc64, - _internal::ToBase64String(uploadRangeFromUrlOptions.SourceIfMatchCrc64.Value())); - } - if (uploadRangeFromUrlOptions.SourceIfNoneMatchCrc64.HasValue()) - { - request.SetHeader( - _detail::HeaderSourceIfNoneMatchHashCrc64, - _internal::ToBase64String( - uploadRangeFromUrlOptions.SourceIfNoneMatchCrc64.Value())); - } - request.SetHeader(_detail::HeaderVersion, uploadRangeFromUrlOptions.ApiVersionParameter); - if (uploadRangeFromUrlOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader( - _detail::HeaderLeaseId, uploadRangeFromUrlOptions.LeaseIdOptional.Value()); - } - return UploadRangeFromUrlParseResult(context, pipeline.Send(request, context)); - } - - struct GetRangeListOptions final - { - Azure::Nullable ShareSnapshot; - Azure::Nullable PrevShareSnapshot; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable XMsRange; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response GetRangeList( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const GetRangeListOptions& getRangeListOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "rangelist"); - if (getRangeListOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(getRangeListOptions.ShareSnapshot.Value())); - } - if (getRangeListOptions.PrevShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryPrevShareSnapshot, - _internal::UrlEncodeQueryParameter(getRangeListOptions.PrevShareSnapshot.Value())); - } - if (getRangeListOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(getRangeListOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, getRangeListOptions.ApiVersionParameter); - if (getRangeListOptions.XMsRange.HasValue()) - { - request.SetHeader(_detail::HeaderXMsRange, getRangeListOptions.XMsRange.Value()); - } - if (getRangeListOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, getRangeListOptions.LeaseIdOptional.Value()); - } - return GetRangeListParseResult(context, pipeline.Send(request, context)); - } - - struct StartCopyOptions final - { - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Storage::Metadata Metadata; - std::string CopySource; - Azure::Nullable FilePermission; - Azure::Nullable FilePermissionKey; - Azure::Nullable XMsFilePermissionCopyMode; - Azure::Nullable FileCopyIgnoreReadOnly; - Azure::Nullable FileCopyFileAttributes; - Azure::Nullable FileCopyFileCreationTime; - Azure::Nullable FileCopyFileLastWriteTime; - Azure::Nullable FileCopySetArchiveAttribute; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response StartCopy( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const StartCopyOptions& startCopyOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - if (startCopyOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(startCopyOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderVersion, startCopyOptions.ApiVersionParameter); - for (const auto& pair : startCopyOptions.Metadata) - { - request.SetHeader(_detail::HeaderMetadata + ("-" + pair.first), pair.second); - } - request.SetHeader(_detail::HeaderCopySource, startCopyOptions.CopySource); - if (startCopyOptions.FilePermission.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermission, startCopyOptions.FilePermission.Value()); - } - if (startCopyOptions.FilePermissionKey.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermissionKey, startCopyOptions.FilePermissionKey.Value()); - } - if (startCopyOptions.XMsFilePermissionCopyMode.HasValue()) - { - request.SetHeader( - _detail::HeaderFilePermissionCopyMode, - startCopyOptions.XMsFilePermissionCopyMode.Value().ToString()); - } - if (startCopyOptions.FileCopyIgnoreReadOnly.HasValue()) - { - request.SetHeader( - _detail::HeaderIgnoreReadOnly, - (startCopyOptions.FileCopyIgnoreReadOnly.Value() ? "true" : "false")); - } - if (startCopyOptions.FileCopyFileAttributes.HasValue()) - { - request.SetHeader( - _detail::HeaderFileAttributes, startCopyOptions.FileCopyFileAttributes.Value()); - } - if (startCopyOptions.FileCopyFileCreationTime.HasValue()) - { - request.SetHeader( - _detail::HeaderFileCreatedOn, startCopyOptions.FileCopyFileCreationTime.Value()); - } - if (startCopyOptions.FileCopyFileLastWriteTime.HasValue()) - { - request.SetHeader( - _detail::HeaderFileLastWrittenOn, - startCopyOptions.FileCopyFileLastWriteTime.Value()); - } - if (startCopyOptions.FileCopySetArchiveAttribute.HasValue()) - { - request.SetHeader( - _detail::HeaderSetArchiveAttribute, - (startCopyOptions.FileCopySetArchiveAttribute.Value() ? "true" : "false")); - } - if (startCopyOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, startCopyOptions.LeaseIdOptional.Value()); - } - return StartCopyParseResult(context, pipeline.Send(request, context)); - } - - struct AbortCopyOptions final - { - std::string CopyId; - Azure::Nullable Timeout; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - Azure::Nullable LeaseIdOptional; - }; - - static Azure::Response AbortCopy( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const AbortCopyOptions& abortCopyOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "copy"); - request.GetUrl().AppendQueryParameter( - _detail::QueryCopyId, _internal::UrlEncodeQueryParameter(abortCopyOptions.CopyId)); - if (abortCopyOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(abortCopyOptions.Timeout.Value()))); - } - request.SetHeader(_detail::HeaderCopyActionAbortConstant, "abort"); - request.SetHeader(_detail::HeaderVersion, abortCopyOptions.ApiVersionParameter); - if (abortCopyOptions.LeaseIdOptional.HasValue()) - { - request.SetHeader(_detail::HeaderLeaseId, abortCopyOptions.LeaseIdOptional.Value()); - } - return AbortCopyParseResult(context, pipeline.Send(request, context)); - } - - struct ListHandlesOptions final - { - Azure::Nullable ContinuationToken; - Azure::Nullable MaxResults; - Azure::Nullable Timeout; - Azure::Nullable ShareSnapshot; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response ListHandles( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ListHandlesOptions& listHandlesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "listhandles"); - if (listHandlesOptions.ContinuationToken.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryContinuationToken, - _internal::UrlEncodeQueryParameter(listHandlesOptions.ContinuationToken.Value())); - } - if (listHandlesOptions.MaxResults.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryPageSizeHint, - _internal::UrlEncodeQueryParameter( - std::to_string(listHandlesOptions.MaxResults.Value()))); - } - if (listHandlesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(listHandlesOptions.Timeout.Value()))); - } - if (listHandlesOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(listHandlesOptions.ShareSnapshot.Value())); - } - request.SetHeader(_detail::HeaderVersion, listHandlesOptions.ApiVersionParameter); - return ListHandlesParseResult(context, pipeline.Send(request, context)); - } - - struct ForceCloseHandlesOptions final - { - Azure::Nullable Timeout; - Azure::Nullable ContinuationToken; - Azure::Nullable ShareSnapshot; - std::string HandleId; - std::string ApiVersionParameter = _detail::DefaultServiceApiVersion; - }; - - static Azure::Response ForceCloseHandles( - const Azure::Core::Url& url, - Azure::Core::Http::_internal::HttpPipeline& pipeline, - Azure::Core::Context context, - const ForceCloseHandlesOptions& forceCloseHandlesOptions) - { - Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url); - request.SetHeader(_detail::HeaderContentLength, "0"); - request.GetUrl().AppendQueryParameter(_detail::QueryComp, "forceclosehandles"); - if (forceCloseHandlesOptions.Timeout.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryTimeout, - _internal::UrlEncodeQueryParameter( - std::to_string(forceCloseHandlesOptions.Timeout.Value()))); - } - if (forceCloseHandlesOptions.ContinuationToken.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryContinuationToken, - _internal::UrlEncodeQueryParameter( - forceCloseHandlesOptions.ContinuationToken.Value())); - } - if (forceCloseHandlesOptions.ShareSnapshot.HasValue()) - { - request.GetUrl().AppendQueryParameter( - _detail::QueryShareSnapshot, - _internal::UrlEncodeQueryParameter(forceCloseHandlesOptions.ShareSnapshot.Value())); - } - request.SetHeader(_detail::HeaderHandleId, forceCloseHandlesOptions.HandleId); - request.SetHeader(_detail::HeaderVersion, forceCloseHandlesOptions.ApiVersionParameter); - return ForceCloseHandlesParseResult(context, pipeline.Send(request, context)); - } - - private: - static Azure::Response CreateParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Success, File created. - Models::CreateFileResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response DownloadParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Succeeded to read the entire file. - FileDownloadResult result; - result.BodyStream = response.ExtractBodyStream(); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - - for (auto i = response.GetHeaders().lower_bound(_detail::HeaderMetadata); - i != response.GetHeaders().end() - && i->first.substr(0, 9) == _detail::HeaderMetadata; - ++i) - { - result.Metadata.emplace(i->first.substr(10), i->second); - } - result.HttpHeaders.ContentType = response.GetHeaders().at(_detail::HeaderContentType); - - auto content_range_iterator = response.GetHeaders().find(_detail::HeaderContentRange); - if (content_range_iterator != response.GetHeaders().end()) - { - const std::string& content_range = content_range_iterator->second; - auto bytes_pos = content_range.find("bytes "); - auto dash_pos = content_range.find("-", bytes_pos + 6); - auto slash_pos = content_range.find("/", dash_pos + 1); - int64_t range_start_offset = std::stoll(std::string( - content_range.begin() + bytes_pos + 6, content_range.begin() + dash_pos)); - int64_t range_end_offset = std::stoll(std::string( - content_range.begin() + dash_pos + 1, content_range.begin() + slash_pos)); - result.ContentRange = Azure::Core::Http::HttpRange{ - range_start_offset, range_end_offset - range_start_offset + 1}; - } - else - { - result.ContentRange = Azure::Core::Http::HttpRange{ - 0, std::stoll(response.GetHeaders().at(_detail::HeaderContentLength))}; - } - if (content_range_iterator != response.GetHeaders().end()) - { - const std::string& content_range = content_range_iterator->second; - auto slash_pos = content_range.find("/"); - result.FileSize = std::stoll(content_range.substr(slash_pos + 1)); - } - else - { - result.FileSize = std::stoll(response.GetHeaders().at(_detail::HeaderContentLength)); - } - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - if (response.GetHeaders().find(_detail::HeaderTransactionalContentHashMd5) - != response.GetHeaders().end()) - { - result.TransactionalContentHash = _internal::FromBase64String( - response.GetHeaders().at(_detail::HeaderTransactionalContentHashMd5), - HashAlgorithm::Md5); - } - if (response.GetHeaders().find(_detail::HeaderContentEncoding) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentEncoding - = response.GetHeaders().at(_detail::HeaderContentEncoding); - } - if (response.GetHeaders().find(_detail::HeaderCacheControl) - != response.GetHeaders().end()) - { - result.HttpHeaders.CacheControl - = response.GetHeaders().at(_detail::HeaderCacheControl); - } - if (response.GetHeaders().find(_detail::HeaderContentDisposition) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentDisposition - = response.GetHeaders().at(_detail::HeaderContentDisposition); - } - if (response.GetHeaders().find(_detail::HeaderContentLanguage) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentLanguage - = response.GetHeaders().at(_detail::HeaderContentLanguage); - } - result.AcceptRanges = response.GetHeaders().at(_detail::HeaderAcceptRanges); - if (response.GetHeaders().find(_detail::HeaderCopyCompletedOn) - != response.GetHeaders().end()) - { - result.CopyCompletedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCopyCompletedOn), - DateTime::DateFormat::Rfc1123); - } - if (response.GetHeaders().find(_detail::HeaderCopyStatusDescription) - != response.GetHeaders().end()) - { - result.CopyStatusDescription - = response.GetHeaders().at(_detail::HeaderCopyStatusDescription); - } - if (response.GetHeaders().find(_detail::HeaderCopyId) != response.GetHeaders().end()) - { - result.CopyId = response.GetHeaders().at(_detail::HeaderCopyId); - } - if (response.GetHeaders().find(_detail::HeaderCopyProgress) - != response.GetHeaders().end()) - { - result.CopyProgress = response.GetHeaders().at(_detail::HeaderCopyProgress); - } - if (response.GetHeaders().find(_detail::HeaderCopySource) - != response.GetHeaders().end()) - { - result.CopySource = response.GetHeaders().at(_detail::HeaderCopySource); - } - if (response.GetHeaders().find(_detail::HeaderCopyStatus) - != response.GetHeaders().end()) - { - result.CopyStatus = CopyStatus(response.GetHeaders().at(_detail::HeaderCopyStatus)); - } - if (response.GetHeaders().find(_detail::HeaderContentHashMd5) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentHash = _internal::FromBase64String( - response.GetHeaders().at(_detail::HeaderContentHashMd5), HashAlgorithm::Md5); - } - if (response.GetHeaders().find(_detail::HeaderIsServerEncrypted) - != response.GetHeaders().end()) - { - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderIsServerEncrypted) == "true"; - } - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - if (response.GetHeaders().find(_detail::HeaderLeaseDuration) - != response.GetHeaders().end()) - { - result.LeaseDuration - = LeaseDuration(response.GetHeaders().at(_detail::HeaderLeaseDuration)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseState) - != response.GetHeaders().end()) - { - result.LeaseState = LeaseState(response.GetHeaders().at(_detail::HeaderLeaseState)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseStatus) - != response.GetHeaders().end()) - { - result.LeaseStatus - = LeaseStatus(response.GetHeaders().at(_detail::HeaderLeaseStatus)); - } - return Azure::Response(std::move(result), std::move(responsePtr)); - } - else if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::PartialContent) - { - // Succeeded to read a specified range of the file. - FileDownloadResult result; - result.BodyStream = response.ExtractBodyStream(); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - - for (auto i = response.GetHeaders().lower_bound(_detail::HeaderMetadata); - i != response.GetHeaders().end() - && i->first.substr(0, 9) == _detail::HeaderMetadata; - ++i) - { - result.Metadata.emplace(i->first.substr(10), i->second); - } - result.HttpHeaders.ContentType = response.GetHeaders().at(_detail::HeaderContentType); - - auto content_range_iterator = response.GetHeaders().find(_detail::HeaderContentRange); - if (content_range_iterator != response.GetHeaders().end()) - { - const std::string& content_range = content_range_iterator->second; - auto bytes_pos = content_range.find("bytes "); - auto dash_pos = content_range.find("-", bytes_pos + 6); - auto slash_pos = content_range.find("/", dash_pos + 1); - int64_t range_start_offset = std::stoll(std::string( - content_range.begin() + bytes_pos + 6, content_range.begin() + dash_pos)); - int64_t range_end_offset = std::stoll(std::string( - content_range.begin() + dash_pos + 1, content_range.begin() + slash_pos)); - result.ContentRange = Azure::Core::Http::HttpRange{ - range_start_offset, range_end_offset - range_start_offset + 1}; - } - else - { - result.ContentRange = Azure::Core::Http::HttpRange{ - 0, std::stoll(response.GetHeaders().at(_detail::HeaderContentLength))}; - } - if (content_range_iterator != response.GetHeaders().end()) - { - const std::string& content_range = content_range_iterator->second; - auto slash_pos = content_range.find("/"); - result.FileSize = std::stoll(content_range.substr(slash_pos + 1)); - } - else - { - result.FileSize = std::stoll(response.GetHeaders().at(_detail::HeaderContentLength)); - } - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - if (response.GetHeaders().find(_detail::HeaderTransactionalContentHashMd5) - != response.GetHeaders().end()) - { - result.TransactionalContentHash = _internal::FromBase64String( - response.GetHeaders().at(_detail::HeaderTransactionalContentHashMd5), - HashAlgorithm::Md5); - } - if (response.GetHeaders().find(_detail::HeaderContentEncoding) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentEncoding - = response.GetHeaders().at(_detail::HeaderContentEncoding); - } - if (response.GetHeaders().find(_detail::HeaderCacheControl) - != response.GetHeaders().end()) - { - result.HttpHeaders.CacheControl - = response.GetHeaders().at(_detail::HeaderCacheControl); - } - if (response.GetHeaders().find(_detail::HeaderContentDisposition) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentDisposition - = response.GetHeaders().at(_detail::HeaderContentDisposition); - } - if (response.GetHeaders().find(_detail::HeaderContentLanguage) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentLanguage - = response.GetHeaders().at(_detail::HeaderContentLanguage); - } - result.AcceptRanges = response.GetHeaders().at(_detail::HeaderAcceptRanges); - if (response.GetHeaders().find(_detail::HeaderCopyCompletedOn) - != response.GetHeaders().end()) - { - result.CopyCompletedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCopyCompletedOn), - DateTime::DateFormat::Rfc1123); - } - if (response.GetHeaders().find(_detail::HeaderCopyStatusDescription) - != response.GetHeaders().end()) - { - result.CopyStatusDescription - = response.GetHeaders().at(_detail::HeaderCopyStatusDescription); - } - if (response.GetHeaders().find(_detail::HeaderCopyId) != response.GetHeaders().end()) - { - result.CopyId = response.GetHeaders().at(_detail::HeaderCopyId); - } - if (response.GetHeaders().find(_detail::HeaderCopyProgress) - != response.GetHeaders().end()) - { - result.CopyProgress = response.GetHeaders().at(_detail::HeaderCopyProgress); - } - if (response.GetHeaders().find(_detail::HeaderCopySource) - != response.GetHeaders().end()) - { - result.CopySource = response.GetHeaders().at(_detail::HeaderCopySource); - } - if (response.GetHeaders().find(_detail::HeaderCopyStatus) - != response.GetHeaders().end()) - { - result.CopyStatus = CopyStatus(response.GetHeaders().at(_detail::HeaderCopyStatus)); - } - if (response.GetHeaders().find(_detail::HeaderContentHashMd5) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentHash = _internal::FromBase64String( - response.GetHeaders().at(_detail::HeaderContentHashMd5), HashAlgorithm::Md5); - } - if (response.GetHeaders().find(_detail::HeaderIsServerEncrypted) - != response.GetHeaders().end()) - { - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderIsServerEncrypted) == "true"; - } - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - if (response.GetHeaders().find(_detail::HeaderLeaseDuration) - != response.GetHeaders().end()) - { - result.LeaseDuration - = LeaseDuration(response.GetHeaders().at(_detail::HeaderLeaseDuration)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseState) - != response.GetHeaders().end()) - { - result.LeaseState = LeaseState(response.GetHeaders().at(_detail::HeaderLeaseState)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseStatus) - != response.GetHeaders().end()) - { - result.LeaseStatus - = LeaseStatus(response.GetHeaders().at(_detail::HeaderLeaseStatus)); - } - return Azure::Response(std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response GetPropertiesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - Models::FileProperties result; - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - - for (auto i = response.GetHeaders().lower_bound(_detail::HeaderMetadata); - i != response.GetHeaders().end() - && i->first.substr(0, 9) == _detail::HeaderMetadata; - ++i) - { - result.Metadata.emplace(i->first.substr(10), i->second); - } - result.FileSize = std::stoll(response.GetHeaders().at(_detail::HeaderContentLength)); - if (response.GetHeaders().find(_detail::HeaderContentType) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentType = response.GetHeaders().at(_detail::HeaderContentType); - } - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - if (response.GetHeaders().find(_detail::HeaderTransactionalContentHashMd5) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentHash = _internal::FromBase64String( - response.GetHeaders().at(_detail::HeaderTransactionalContentHashMd5), - HashAlgorithm::Md5); - } - if (response.GetHeaders().find(_detail::HeaderContentEncoding) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentEncoding - = response.GetHeaders().at(_detail::HeaderContentEncoding); - } - if (response.GetHeaders().find(_detail::HeaderCacheControl) - != response.GetHeaders().end()) - { - result.HttpHeaders.CacheControl - = response.GetHeaders().at(_detail::HeaderCacheControl); - } - if (response.GetHeaders().find(_detail::HeaderContentDisposition) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentDisposition - = response.GetHeaders().at(_detail::HeaderContentDisposition); - } - if (response.GetHeaders().find(_detail::HeaderContentLanguage) - != response.GetHeaders().end()) - { - result.HttpHeaders.ContentLanguage - = response.GetHeaders().at(_detail::HeaderContentLanguage); - } - if (response.GetHeaders().find(_detail::HeaderCopyCompletedOn) - != response.GetHeaders().end()) - { - result.CopyCompletedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCopyCompletedOn), - DateTime::DateFormat::Rfc1123); - } - if (response.GetHeaders().find(_detail::HeaderCopyStatusDescription) - != response.GetHeaders().end()) - { - result.CopyStatusDescription - = response.GetHeaders().at(_detail::HeaderCopyStatusDescription); - } - if (response.GetHeaders().find(_detail::HeaderCopyId) != response.GetHeaders().end()) - { - result.CopyId = response.GetHeaders().at(_detail::HeaderCopyId); - } - if (response.GetHeaders().find(_detail::HeaderCopyProgress) - != response.GetHeaders().end()) - { - result.CopyProgress = response.GetHeaders().at(_detail::HeaderCopyProgress); - } - if (response.GetHeaders().find(_detail::HeaderCopySource) - != response.GetHeaders().end()) - { - result.CopySource = response.GetHeaders().at(_detail::HeaderCopySource); - } - if (response.GetHeaders().find(_detail::HeaderCopyStatus) - != response.GetHeaders().end()) - { - result.CopyStatus = CopyStatus(response.GetHeaders().at(_detail::HeaderCopyStatus)); - } - if (response.GetHeaders().find(_detail::HeaderIsServerEncrypted) - != response.GetHeaders().end()) - { - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderIsServerEncrypted) == "true"; - } - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - if (response.GetHeaders().find(_detail::HeaderLeaseDuration) - != response.GetHeaders().end()) - { - result.LeaseDuration - = LeaseDuration(response.GetHeaders().at(_detail::HeaderLeaseDuration)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseState) - != response.GetHeaders().end()) - { - result.LeaseState = LeaseState(response.GetHeaders().at(_detail::HeaderLeaseState)); - } - if (response.GetHeaders().find(_detail::HeaderLeaseStatus) - != response.GetHeaders().end()) - { - result.LeaseStatus - = LeaseStatus(response.GetHeaders().at(_detail::HeaderLeaseStatus)); - } - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response DeleteParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Accepted) - { - // Success (Accepted). - Models::DeleteFileResult result; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response SetHttpHeadersParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success - Models::SetFilePropertiesResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - result.SmbProperties.PermissionKey - = response.GetHeaders().at(_detail::HeaderFilePermissionKey); - result.SmbProperties.Attributes - = FileAttributes(response.GetHeaders().at(_detail::HeaderAttributes)); - result.SmbProperties.CreatedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderCreatedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.LastWrittenOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastWrittenOn), - DateTime::DateFormat::Rfc3339); - result.SmbProperties.ChangedOn = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderChangedOn), DateTime::DateFormat::Rfc3339); - result.SmbProperties.FileId = response.GetHeaders().at(_detail::HeaderFileId); - result.SmbProperties.ParentFileId - = response.GetHeaders().at(_detail::HeaderParentFileId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response SetMetadataParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success (OK). - Models::SetFileMetadataResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response AcquireLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // The Acquire operation completed successfully. - FileAcquireLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.LeaseId = response.GetHeaders().at(_detail::HeaderLeaseId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response ReleaseLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // The Release operation completed successfully. - FileReleaseLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response ChangeLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // The Change operation completed successfully. - FileChangeLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.LeaseId = response.GetHeaders().at(_detail::HeaderLeaseId); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response BreakLeaseParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Accepted) - { - // The Break operation completed successfully. - FileBreakLeaseResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - if (response.GetHeaders().find(_detail::HeaderLeaseId) != response.GetHeaders().end()) - { - result.LeaseId = response.GetHeaders().at(_detail::HeaderLeaseId); - } - return Azure::Response(std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response UploadRangeParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Success (Created). - Models::UploadFileRangeResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - if (response.GetHeaders().find(_detail::HeaderTransactionalContentHashMd5) - != response.GetHeaders().end()) - { - result.TransactionalContentHash = _internal::FromBase64String( - response.GetHeaders().at(_detail::HeaderTransactionalContentHashMd5), - HashAlgorithm::Md5); - } - if (response.GetHeaders().find(_detail::HeaderRequestIsServerEncrypted) - != response.GetHeaders().end()) - { - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - } - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response UploadRangeFromUrlParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Created) - { - // Success (Created). - Models::UploadFileRangeFromUriResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.TransactionalContentHash = _internal::FromBase64String( - response.GetHeaders().at(_detail::HeaderTransactionalContentHashCrc64), - HashAlgorithm::Crc64); - result.IsServerEncrypted - = response.GetHeaders().at(_detail::HeaderRequestIsServerEncrypted) == "true"; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response GetRangeListParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - Models::GetFileRangeListResult result = bodyBuffer.empty() - ? Models::GetFileRangeListResult() - : GetFileRangeListResultFromRangeList(RangeListFromXml(reader)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.FileSize = std::stoll(response.GetHeaders().at(_detail::HeaderXMsContentLength)); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static RangeList RangeListFromXml(_internal::XmlReader& reader) - { - auto result = RangeList(); - enum class XmlTagName - { - ClearRange, - Range, - Ranges, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "ClearRange") == 0) - { - path.emplace_back(XmlTagName::ClearRange); - } - else if (std::strcmp(node.Name.data(), "Range") == 0) - { - path.emplace_back(XmlTagName::Range); - } - else if (std::strcmp(node.Name.data(), "Ranges") == 0) - { - path.emplace_back(XmlTagName::Ranges); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - if (path.size() == 2 && path[0] == XmlTagName::Ranges && path[1] == XmlTagName::Range) - { - result.Ranges.emplace_back(HttpRangeFromXml(reader)); - path.pop_back(); - } - else if ( - path.size() == 2 && path[0] == XmlTagName::Ranges - && path[1] == XmlTagName::ClearRange) - { - result.ClearRanges.emplace_back(HttpRangeFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - } - } - return result; - } - - static Models::GetFileRangeListResult GetFileRangeListResultFromRangeList(RangeList object) - { - Models::GetFileRangeListResult result; - result.Ranges = std::move(object.Ranges); - result.ClearRanges = std::move(object.ClearRanges); - - return result; - } - static Azure::Response StartCopyParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Accepted) - { - // The copy file has been accepted with the specified copy status. - FileStartCopyResult result; - result.ETag = Azure::ETag(response.GetHeaders().at(_detail::HeaderETag)); - result.LastModified = DateTime::Parse( - response.GetHeaders().at(_detail::HeaderLastModified), - DateTime::DateFormat::Rfc1123); - if (response.GetHeaders().find(_detail::HeaderCopyId) != response.GetHeaders().end()) - { - result.CopyId = response.GetHeaders().at(_detail::HeaderCopyId); - } - if (response.GetHeaders().find(_detail::HeaderCopyStatus) - != response.GetHeaders().end()) - { - result.CopyStatus = CopyStatus(response.GetHeaders().at(_detail::HeaderCopyStatus)); - } - return Azure::Response(std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response AbortCopyParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::NoContent) - { - // The delete request was accepted and the file will be deleted. - Models::AbortFileCopyResult result; - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static Azure::Response ListHandlesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - const auto& bodyBuffer = response.GetBody(); - auto reader = _internal::XmlReader( - reinterpret_cast(bodyBuffer.data()), bodyBuffer.size()); - FileListHandlesResult result = bodyBuffer.empty() - ? FileListHandlesResult() - : FileListHandlesResultFromListHandlesResponse(ListHandlesResponseFromXml(reader)); - result.HttpHeaders.ContentType = response.GetHeaders().at(_detail::HeaderContentType); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - - static HandleItem HandleItemFromXml(_internal::XmlReader& reader) - { - auto result = HandleItem(); - enum class XmlTagName - { - ClientIp, - FileId, - HandleId, - LastReconnectTime, - OpenTime, - ParentId, - Path, - SessionId, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "ClientIp") == 0) - { - path.emplace_back(XmlTagName::ClientIp); - } - else if (std::strcmp(node.Name.data(), "FileId") == 0) - { - path.emplace_back(XmlTagName::FileId); - } - else if (std::strcmp(node.Name.data(), "HandleId") == 0) - { - path.emplace_back(XmlTagName::HandleId); - } - else if (std::strcmp(node.Name.data(), "LastReconnectTime") == 0) - { - path.emplace_back(XmlTagName::LastReconnectTime); - } - else if (std::strcmp(node.Name.data(), "OpenTime") == 0) - { - path.emplace_back(XmlTagName::OpenTime); - } - else if (std::strcmp(node.Name.data(), "ParentId") == 0) - { - path.emplace_back(XmlTagName::ParentId); - } - else if (std::strcmp(node.Name.data(), "Path") == 0) - { - path.emplace_back(XmlTagName::Path); - } - else if (std::strcmp(node.Name.data(), "SessionId") == 0) - { - path.emplace_back(XmlTagName::SessionId); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 1 && path[0] == XmlTagName::ClientIp) - { - result.ClientIp = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::FileId) - { - result.FileId = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::HandleId) - { - result.HandleId = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::LastReconnectTime) - { - result.LastReconnectedOn - = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::OpenTime) - { - result.OpenedOn = DateTime::Parse(node.Value, DateTime::DateFormat::Rfc1123); - } - else if (path.size() == 1 && path[0] == XmlTagName::ParentId) - { - result.ParentId = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::Path) - { - result.Path = node.Value; - } - else if (path.size() == 1 && path[0] == XmlTagName::SessionId) - { - result.SessionId = node.Value; - } - } - } - return result; - } - - static ListHandlesResponse ListHandlesResponseFromXml(_internal::XmlReader& reader) - { - auto result = ListHandlesResponse(); - enum class XmlTagName - { - Entries, - EnumerationResults, - Handle, - NextMarker, - Unknown, - }; - std::vector path; - - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (path.size() > 0) - { - path.pop_back(); - } - else - { - break; - } - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - - if (std::strcmp(node.Name.data(), "Entries") == 0) - { - path.emplace_back(XmlTagName::Entries); - } - else if (std::strcmp(node.Name.data(), "EnumerationResults") == 0) - { - path.emplace_back(XmlTagName::EnumerationResults); - } - else if (std::strcmp(node.Name.data(), "Handle") == 0) - { - path.emplace_back(XmlTagName::Handle); - } - else if (std::strcmp(node.Name.data(), "NextMarker") == 0) - { - path.emplace_back(XmlTagName::NextMarker); - } - else - { - path.emplace_back(XmlTagName::Unknown); - } - if (path.size() == 3 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::Entries && path[2] == XmlTagName::Handle) - { - result.HandleList.emplace_back(HandleItemFromXml(reader)); - path.pop_back(); - } - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (path.size() == 2 && path[0] == XmlTagName::EnumerationResults - && path[1] == XmlTagName::NextMarker) - { - result.ContinuationToken = node.Value; - } - } - } - return result; - } - - static FileListHandlesResult FileListHandlesResultFromListHandlesResponse( - ListHandlesResponse object) - { - FileListHandlesResult result; - result.HandleList = std::move(object.HandleList); - result.ContinuationToken = std::move(object.ContinuationToken); - - return result; - } - static Azure::Response ForceCloseHandlesParseResult( - Azure::Core::Context context, - std::unique_ptr responsePtr) - { - auto& response = *responsePtr; - if (response.GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) - { - // Success. - FileForceCloseHandlesResult result; - if (response.GetHeaders().find(_detail::HeaderContinuationToken) - != response.GetHeaders().end()) - { - result.ContinuationToken = response.GetHeaders().at(_detail::HeaderContinuationToken); - } - result.NumberOfHandlesClosed - = std::stoi(response.GetHeaders().at(_detail::HeaderNumberOfHandlesClosed)); - result.NumberOfHandlesFailedToClose - = std::stoi(response.GetHeaders().at(_detail::HeaderNumberOfHandlesFailedToClose)); - return Azure::Response( - std::move(result), std::move(responsePtr)); - } - else - { - (void)context; - throw Storage::StorageException::CreateFromResponse(std::move(responsePtr)); - } - } - }; - - }; // class ShareRestClient - - } // namespace _detail - -}}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp new file mode 100644 index 000000000..d5881956a --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp @@ -0,0 +1,2113 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest C++ Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Azure { namespace Storage { namespace Files { namespace Shares { + namespace _detail { + /** + * The version used for the operations to Azure storage services. + */ + constexpr static const char* ApiVersion = "2020-02-10"; + } // namespace _detail + namespace Models { + /** + * @brief The retention policy. + */ + struct RetentionPolicy final + { + /** + * Indicates whether a retention policy is enabled for the File service. If false, metrics + * data is retained, and the user is responsible for deleting it. + */ + bool Enabled = bool(); + /** + * Indicates the number of days that metrics data should be retained. All data older than this + * value will be deleted. Metrics data is deleted on a best-effort basis after the retention + * period expires. + */ + Nullable Days; + }; + /** + * @brief Storage Analytics metrics for file service. + */ + struct Metrics final + { + /** + * The version of Storage Analytics to configure. + */ + std::string Version; + /** + * Indicates whether metrics are enabled for the File service. + */ + bool Enabled = bool(); + /** + * Indicates whether metrics should generate summary statistics for called API operations. + */ + Nullable IncludeApis; + /** + * The retention policy. + */ + Models::RetentionPolicy RetentionPolicy; + }; + /** + * @brief CORS is an HTTP feature that enables a web application running under one domain to + * access resources in another domain. Web browsers implement a security restriction known as + * same-origin policy that prevents a web page from calling APIs in a different domain; CORS + * provides a secure way to allow one domain (the origin domain) to call APIs in another domain. + */ + struct CorsRule final + { + /** + * The origin domains that are permitted to make a request against the storage service via + * CORS. The origin domain is the domain from which the request originates. Note that the + * origin must be an exact case-sensitive match with the origin that the user age sends to the + * service. You can also use the wildcard character '*' to allow all origin domains to make + * requests via CORS. + */ + std::string AllowedOrigins; + /** + * The methods (HTTP request verbs) that the origin domain may use for a CORS request. (comma + * separated). + */ + std::string AllowedMethods; + /** + * The request headers that the origin domain may specify on the CORS request. + */ + std::string AllowedHeaders; + /** + * The response headers that may be sent in the response to the CORS request and exposed by + * the browser to the request issuer. + */ + std::string ExposedHeaders; + /** + * The maximum amount time that a browser should cache the preflight OPTIONS request. + */ + int32_t MaxAgeInSeconds = int32_t(); + }; + /** + * @brief Settings for SMB multichannel. + */ + struct SmbMultichannel final + { + /** + * If SMB multichannel is enabled. + */ + bool Enabled = bool(); + }; + /** + * @brief Settings for SMB protocol. + */ + struct SmbSettings final + { + /** + * Settings for SMB Multichannel. + */ + SmbMultichannel Multichannel; + }; + /** + * @brief Protocol settings. + */ + struct ProtocolSettings final + { + /** + * Settings for SMB protocol. + */ + SmbSettings Settings; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ServiceClient::SetProperties. + */ + struct SetServicePropertiesResult final + { + }; + /** + * @brief Storage service properties. + */ + struct ShareServiceProperties final + { + /** + * A summary of request statistics grouped by API in hourly aggregates for files. + */ + Metrics HourMetrics; + /** + * A summary of request statistics grouped by API in minute aggregates for files. + */ + Metrics MinuteMetrics; + /** + * The set of CORS rules. + */ + std::vector Cors; + /** + * Protocol settings. + */ + Nullable Protocol; + }; + /** + * @brief Specifies the access tier of the share. + */ + class AccessTier final { + public: + AccessTier() = default; + explicit AccessTier(std::string value) : m_value(std::move(value)) {} + bool operator==(const AccessTier& other) const { return m_value == other.m_value; } + bool operator!=(const AccessTier& other) const { return !(*this == other); } + const std::string& ToString() const { return m_value; } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier TransactionOptimized; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier Hot; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier Cool; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static AccessTier Premium; + + private: + std::string m_value; + }; + /** + * @brief The current lease status of the share. + */ + class LeaseStatus final { + public: + LeaseStatus() = default; + explicit LeaseStatus(std::string value) : m_value(std::move(value)) {} + bool operator==(const LeaseStatus& other) const { return m_value == other.m_value; } + bool operator!=(const LeaseStatus& other) const { return !(*this == other); } + const std::string& ToString() const { return m_value; } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseStatus Locked; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseStatus Unlocked; + + private: + std::string m_value; + }; + /** + * @brief Lease state of the share. + */ + class LeaseState final { + public: + LeaseState() = default; + explicit LeaseState(std::string value) : m_value(std::move(value)) {} + bool operator==(const LeaseState& other) const { return m_value == other.m_value; } + bool operator!=(const LeaseState& other) const { return !(*this == other); } + const std::string& ToString() const { return m_value; } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Available; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Leased; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Expired; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Breaking; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseState Broken; + + private: + std::string m_value; + }; + /** + * @brief When a share is leased, specifies whether the lease is of infinite or fixed duration. + */ + class LeaseDurationType final { + public: + LeaseDurationType() = default; + explicit LeaseDurationType(std::string value) : m_value(std::move(value)) {} + bool operator==(const LeaseDurationType& other) const { return m_value == other.m_value; } + bool operator!=(const LeaseDurationType& other) const { return !(*this == other); } + const std::string& ToString() const { return m_value; } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseDurationType Infinite; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static LeaseDurationType Fixed; + + private: + std::string m_value; + }; + /** + * @brief Properties of a share. + */ + struct ShareItemDetails final + { + DateTime LastModified; + ETag Etag; + int64_t Quota = int64_t(); + Nullable ProvisionedIops; + Nullable ProvisionedIngressMBps; + Nullable ProvisionedEgressMBps; + Nullable NextAllowedQuotaDowngradeTime; + Nullable DeletedOn; + int32_t RemainingRetentionDays = int32_t(); + /** + * Specifies the access tier of the share. + */ + Nullable AccessTier; + Nullable AccessTierChangedOn; + Nullable AccessTierTransitionState; + /** + * The current lease status of the share. + */ + Models::LeaseStatus LeaseStatus; + /** + * Lease state of the share. + */ + Models::LeaseState LeaseState; + /** + * When a share is leased, specifies whether the lease is of infinite or fixed duration. + */ + LeaseDurationType LeaseDuration; + }; + /** + * @brief A listed Azure Storage share item. + */ + struct ShareItem final + { + std::string Name; + std::string Snapshot; + bool Deleted = bool(); + std::string Version; + /** + * A set of name-value pairs associated with the share or file. + */ + std::map< + std::string, + std::string, + Core::_internal::StringExtensions::CaseInsensitiveComparator> + Metadata; + /** + * Properties of a share. + */ + ShareItemDetails Details; + }; + /** + * @brief Include this parameter to specify one or more datasets to include in the response. + */ + enum class ListSharesIncludeFlags + { + None = 0, + Snapshots = 1, + Metadata = 2, + Deleted = 4, + }; + inline ListSharesIncludeFlags operator|(ListSharesIncludeFlags lhs, ListSharesIncludeFlags rhs) + { + using type = std::underlying_type_t; + return static_cast(static_cast(lhs) | static_cast(rhs)); + } + inline ListSharesIncludeFlags& operator|=( + ListSharesIncludeFlags& lhs, + ListSharesIncludeFlags rhs) + { + lhs = lhs | rhs; + return lhs; + } + inline ListSharesIncludeFlags operator&(ListSharesIncludeFlags lhs, ListSharesIncludeFlags rhs) + { + using type = std::underlying_type_t; + return static_cast(static_cast(lhs) & static_cast(rhs)); + } + inline ListSharesIncludeFlags& operator&=( + ListSharesIncludeFlags& lhs, + ListSharesIncludeFlags rhs) + { + lhs = lhs & rhs; + return lhs; + } + namespace _detail { + /** + * @brief An enumeration of shares. + */ + struct ListSharesResponse final + { + std::string ServiceEndpoint; + Nullable Prefix; + Nullable Marker; + Nullable MaxResults; + /** + * Array of ShareItem. + */ + std::vector ShareItems; + std::string NextMarker; + }; + } // namespace _detail + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::Create. + */ + struct CreateShareResult final + { + /** + * Indicates if the share was successfully created by this operation. + */ + bool Created = true; + /** + * The ETag contains a value which represents the version of the share, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties or metadata updates the last modified time. Operations on files do + * not affect the last modified time of the share. + */ + DateTime LastModified; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::GetProperties. + */ + struct ShareProperties final + { + /** + * Specifies the access tier of the share. + */ + Nullable AccessTier; + /** + * A set of name-value pairs that contain the user-defined metadata of the share. + */ + std::map< + std::string, + std::string, + Core::_internal::StringExtensions::CaseInsensitiveComparator> + Metadata; + /** + * The ETag contains a value that you can use to perform operations conditionally, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Returns the current share quota in GB. + */ + int64_t Quota = int64_t(); + /** + * Returns the current share provisioned IOPS. + */ + Nullable ProvisionedIops; + /** + * Returns the current share provisioned ingress in megabytes per second. + */ + Nullable ProvisionedIngressMBps; + /** + * Returns the current share provisioned egress in megabytes per second. + */ + Nullable ProvisionedEgressMBps; + /** + * Returns the current share next allowed quota downgrade time. + */ + Nullable NextAllowedQuotaDowngradeTime; + /** + * When a share is leased, specifies whether the lease is of infinite or fixed duration. + */ + Nullable LeaseDuration; + /** + * Lease state of the share. + */ + Nullable LeaseState; + /** + * The current lease status of the share. + */ + Nullable LeaseStatus; + /** + * Returns the last modified time (in UTC) of the access tier of the share. + */ + Nullable AccessTierChangedOn; + /** + * Returns the transition state between access tiers, when present. + */ + Nullable AccessTierTransitionState; + }; + /** + * @brief Specifies the option include to delete the base share and all of its snapshots. + */ + class DeleteSnapshotsOption final { + public: + DeleteSnapshotsOption() = default; + explicit DeleteSnapshotsOption(std::string value) : m_value(std::move(value)) {} + bool operator==(const DeleteSnapshotsOption& other) const { return m_value == other.m_value; } + bool operator!=(const DeleteSnapshotsOption& other) const { return !(*this == other); } + const std::string& ToString() const { return m_value; } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static DeleteSnapshotsOption Include; + + private: + std::string m_value; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::Delete. + */ + struct DeleteShareResult final + { + /** + * Indicates if the share was successfully deleted by this operation. + */ + bool Deleted = true; + }; + namespace _detail { + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::AcquireLease. + */ + struct AcquireShareLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Uniquely identifies a share's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::ReleaseLease. + */ + struct ReleaseShareLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::ChangeLease. + */ + struct ChangeShareLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Uniquely identifies a share's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::RenewLease. + */ + struct RenewShareLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Uniquely identifies a share's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::BreakLease. + */ + struct BreakShareLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Approximate time remaining in the lease period, in seconds. + */ + int32_t LeaseTime = int32_t(); + /** + * Uniquely identifies a share's lease. + */ + std::string LeaseId; + }; + } // namespace _detail + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::CreateSnapshot. + */ + struct CreateShareSnapshotResult final + { + /** + * This header is a DateTime value that uniquely identifies the share snapshot. The value of + * this header may be used in subsequent requests to access the share snapshot. This value is + * opaque. + */ + std::string Snapshot; + /** + * The ETag contains a value which represents the version of the share snapshot, in quotes. A + * share snapshot cannot be modified, so the ETag of a given share snapshot never changes. + * However, if new metadata was supplied with the Snapshot Share request then the ETag of the + * share snapshot differs from that of the base share. If no metadata was specified with the + * request, the ETag of the share snapshot is identical to that of the base share at the time + * the share snapshot was taken. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. A share snapshot cannot be modified, + * so the last modified time of a given share snapshot never changes. However, if new metadata + * was supplied with the Snapshot Share request then the last modified time of the share + * snapshot differs from that of the base share. If no metadata was specified with the + * request, the last modified time of the share snapshot is identical to that of the base + * share at the time the share snapshot was taken. + */ + DateTime LastModified; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::CreatePermission. + */ + struct CreateSharePermissionResult final + { + /** + * Key of the permission set for the directory/file. + */ + std::string FilePermissionKey; + }; + namespace _detail { + /** + * @brief A permission (a security descriptor) at the share level. + */ + struct SharePermission final + { + /** + * The permission in the Security Descriptor Definition Language (SDDL). + */ + std::string Permission; + }; + } // namespace _detail + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::SetProperties. + */ + struct SetSharePropertiesResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::SetMetadata. + */ + struct SetShareMetadataResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + }; + /** + * @brief An Access policy. + */ + struct AccessPolicy final + { + /** + * The date-time the policy is active. + */ + Nullable StartsOn; + /** + * The date-time the policy expires. + */ + Nullable ExpiresOn; + /** + * The permissions for the ACL policy. + */ + std::string Permission; + }; + /** + * @brief Signed identifier. + */ + struct SignedIdentifier final + { + /** + * A unique id. + */ + std::string Id; + /** + * The access policy. + */ + AccessPolicy Policy; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::GetAccessPolicy. + */ + struct ShareAccessPolicy final + { + /** + * A collection of signed identifiers. + */ + std::vector SignedIdentifiers; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::SetAccessPolicy. + */ + struct SetShareAccessPolicyResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + }; + /** + * @brief Stats for the share. + */ + struct ShareStatistics final + { + /** + * The approximate size of the data stored in bytes. Note that this value may not include all + * recently created or recently resized files. + */ + int64_t ShareUsageInBytes = int64_t(); + /** + * The ETag contains a value that you can use to perform operations conditionally, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + }; + /** + * @brief Attributes for a file or directory. + */ + class FileAttributes final { + public: + FileAttributes() = default; + explicit FileAttributes(const std::string& value); + bool operator==(const FileAttributes& other) const { return m_value == other.m_value; } + bool operator!=(const FileAttributes& other) const { return !(*this == other); } + std::string ToString() const; + const std::vector& GetValues() const { return m_value; } + FileAttributes operator|(const FileAttributes& other) const; + FileAttributes operator&(const FileAttributes& other) const; + FileAttributes operator^(const FileAttributes& other) const; + FileAttributes& operator|=(const FileAttributes& other) + { + *this = *this | other; + return *this; + } + FileAttributes& operator&=(const FileAttributes& other) + { + *this = *this & other; + return *this; + } + FileAttributes& operator^=(const FileAttributes& other) + { + *this = *this ^ other; + return *this; + } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes ReadOnly; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Hidden; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes System; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes None; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Directory; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Archive; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Temporary; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Offline; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes NotContentIndexed; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes NoScrubData; + + private: + std::vector m_value; + }; + /** + * @brief The SMB related properties for the file. + */ + struct FileSmbProperties final + { + /** + * Permission key for the directory or file. + */ + Nullable PermissionKey; + /** + * Attributes for the file or directory. + */ + FileAttributes Attributes; + /** + * Creation time for the file or directory. + */ + Nullable CreatedOn; + /** + * Last write time for the file or directory. + */ + Nullable LastWrittenOn; + /** + * Changed time for the file or directory. + */ + Nullable ChangedOn; + /** + * The fileId of the file. + */ + std::string FileId; + /** + * The parentId of the file. + */ + std::string ParentFileId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::DirectoryClient::Create. + */ + struct CreateDirectoryResult final + { + /** + * Indicates if the directory was successfully created by this operation. + */ + bool Created = true; + /** + * The SMB related properties for the file. + */ + FileSmbProperties SmbProperties; + /** + * The ETag contains a value which represents the version of the directory, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * directory or its properties updates the last modified time. Operations on files do not + * affect the last modified time of the directory. + */ + DateTime LastModified; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = bool(); + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::DirectoryClient::GetProperties. + */ + struct DirectoryProperties final + { + /** + * The SMB related properties for the file. + */ + FileSmbProperties SmbProperties; + /** + * A set of name-value pairs that contain metadata for the directory. + */ + std::map< + std::string, + std::string, + Core::_internal::StringExtensions::CaseInsensitiveComparator> + Metadata; + /** + * The ETag contains a value that you can use to perform operations conditionally, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the Directory was last modified. Operations on files within the + * directory do not affect the last modified time of the directory. + */ + DateTime LastModified; + /** + * The value of this header is set to true if the directory metadata is completely encrypted + * using the specified algorithm. Otherwise, the value is set to false. + */ + bool IsServerEncrypted = bool(); + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::DirectoryClient::Delete. + */ + struct DeleteDirectoryResult final + { + /** + * Indicates if the directory was successfully deleted by this operation. + */ + bool Deleted = true; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::DirectoryClient::SetProperties. + */ + struct SetDirectoryPropertiesResult final + { + /** + * The SMB related properties for the file. + */ + FileSmbProperties SmbProperties; + /** + * The ETag contains a value which represents the version of the file, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the directory was last modified. Any operation that modifies the + * directory or its properties updates the last modified time. Operations on files do not + * affect the last modified time of the directory. + */ + DateTime LastModified; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = bool(); + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::DirectoryClient::SetMetadata. + */ + struct SetDirectoryMetadataResult final + { + /** + * The ETag contains a value which represents the version of the directory, in quotes. + */ + Azure::ETag ETag; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = bool(); + }; + /** + * @brief A listed directory item. + */ + struct DirectoryItem final + { + std::string Name; + }; + /** + * @brief File properties. + */ + struct FileItemDetails final + { + /** + * Content length of the file. This value may not be up-to-date since an SMB client may have + * modified the file locally. The value of Content-Length may not reflect that fact until the + * handle is closed or the op-lock is broken. To retrieve current property values, call Get + * File Properties. + */ + int64_t FileSize = int64_t(); + }; + /** + * @brief A listed file item. + */ + struct FileItem final + { + std::string Name; + /** + * File properties. + */ + FileItemDetails Details; + }; + namespace _detail { + /** + * @brief Abstract for entries that can be listed from Directory. + */ + struct FilesAndDirectoriesListSegment final + { + /** + * Array of DirectoryItem. + */ + std::vector DirectoryItems; + /** + * Array of FileItem. + */ + std::vector FileItems; + }; + /** + * @brief An enumeration of directories and files. + */ + struct ListFilesAndDirectoriesSegmentResponse final + { + std::string ServiceEndpoint; + std::string ShareName; + Nullable ShareSnapshot; + std::string DirectoryPath; + std::string Prefix; + Nullable Marker; + Nullable MaxResults; + /** + * Abstract for entries that can be listed from Directory. + */ + FilesAndDirectoriesListSegment Segment; + std::string NextMarker; + }; + } // namespace _detail + /** + * @brief A listed Azure Storage handle item. + */ + struct HandleItem final + { + /** + * XSMB service handle ID. + */ + std::string HandleId; + /** + * File or directory name including full path starting from share root. + */ + std::string Path; + /** + * FileId uniquely identifies the file or directory. + */ + std::string FileId; + /** + * ParentId uniquely identifies the parent directory of the object. + */ + std::string ParentId; + /** + * SMB session ID in context of which the file handle was opened. + */ + std::string SessionId; + /** + * Client IP that opened the handle. + */ + std::string ClientIp; + /** + * Time when the session that previously opened the handle has last been reconnected. (UTC). + */ + DateTime OpenedOn; + /** + * Time handle was last connected to (UTC). + */ + DateTime LastReconnectedOn; + }; + namespace _detail { + /** + * @brief Response type for + * #Azure::Storage::Files::Shares::DirectoryClient::ForceCloseHandles. + */ + struct ForceCloseDirectoryHandlesResult final + { + /** + * A string describing next handle to be closed. It is returned when more handles need to be + * closed to complete the request. + */ + Nullable ContinuationToken; + /** + * Contains count of number of handles closed. + */ + int32_t NumberOfHandlesClosed = int32_t(); + /** + * Contains count of number of handles that failed to close. + */ + int32_t NumberOfHandlesFailedToClose = int32_t(); + }; + } // namespace _detail + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::Create. + */ + struct CreateFileResult final + { + /** + * Indicates if the file was successfully created by this operation. + */ + bool Created = true; + /** + * The SMB related properties for the file. + */ + FileSmbProperties SmbProperties; + /** + * The ETag contains a value which represents the version of the file, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * directory or its properties updates the last modified time. Operations on files do not + * affect the last modified time of the directory. + */ + DateTime LastModified; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = bool(); + }; + /** + * @brief Standard HTTP properties supported files. + */ + struct FileHttpHeaders final + { + /** + * MIME content type of the file. + */ + std::string ContentType; + /** + * Specifies which content encodings have been applied to the file. + */ + std::string ContentEncoding; + /** + * Specifies the natural languages used by this file. + */ + std::string ContentLanguage; + /** + * Hash of the file content. + */ + Storage::ContentHash ContentHash; + /** + * Conveys additional information about how to process the resource payload, and also can be + * used to attach additional metadata. + */ + std::string ContentDisposition; + /** + * Specifies directives for caching mechanisms. + */ + std::string CacheControl; + }; + /** + * @brief Status of a copy operation. + */ + class CopyStatus final { + public: + CopyStatus() = default; + explicit CopyStatus(std::string value) : m_value(std::move(value)) {} + bool operator==(const CopyStatus& other) const { return m_value == other.m_value; } + bool operator!=(const CopyStatus& other) const { return !(*this == other); } + const std::string& ToString() const { return m_value; } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Pending; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Success; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Aborted; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static CopyStatus Failed; + + private: + std::string m_value; + }; + struct DownloadFileDetails final + { + /** + * The ETag contains a value that you can use to perform operations conditionally. If the + * request version is 2011-08-18 or newer, the ETag value will be in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the file was last modified. Any operation that modifies the file, + * including an update of the file's metadata or properties, changes the last-modified time of + * the file. + */ + DateTime LastModified; + /** + * A set of name-value pairs associated with the share or file. + */ + std::map< + std::string, + std::string, + Core::_internal::StringExtensions::CaseInsensitiveComparator> + Metadata; + /** + * String identifier for this copy operation. Use with Get File Properties to check the + * status of this copy operation, or pass to Abort Copy File to abort a pending copy. + */ + Nullable CopyId; + /** + * URL up to 2 KB in length that specifies the source file or file used in the last attempted + * Copy File operation where this file was the destination file. This header does not appear + * if this file has never been the destination in a Copy File operation, or if this file has + * been modified after a concluded Copy File operation using Set File Properties, Put File, or + * Put Block List. + */ + Nullable CopySource; + /** + * Status of a copy operation. + */ + Nullable CopyStatus; + /** + * Only appears when x-ms-copy-status is failed or pending. Describes the cause of the last + * fatal or non-fatal copy operation failure. This header does not appear if this file has + * never been the destination in a Copy File operation, or if this file has been modified + * after a concluded Copy File operation using Set File Properties, Put File, or Put Block + * List. + */ + Nullable CopyStatusDescription; + /** + * Contains the number of bytes copied and the total bytes in the source in the last attempted + * Copy File operation where this file was the destination file. Can show between 0 and + * Content-Length bytes copied. This header does not appear if this file has never been the + * destination in a Copy File operation, or if this file has been modified after a concluded + * Copy File operation using Set File Properties, Put File, or Put Block List. + */ + Nullable CopyProgress; + /** + * Conclusion time of the last attempted Copy File operation where this file was the + * destination file. This value can specify the time of a completed, aborted, or failed copy + * attempt. This header does not appear if a copy is pending, if this file has never been the + * destination in a Copy File operation, or if this file has been modified after a concluded + * Copy File operation using Set File Properties, Put File, or Put Block List. + */ + Nullable CopyCompletedOn; + /** + * True if the file data and metadata are completely encrypted using the specified algorithm. + * Otherwise, the value is set to false (when the file is unencrypted, or if only parts of the + * file/application metadata are encrypted). + */ + bool IsServerEncrypted = bool(); + /** + * The SMB related properties for the file. + */ + FileSmbProperties SmbProperties; + /** + * When a share is leased, specifies whether the lease is of infinite or fixed duration. + */ + Nullable LeaseDuration; + /** + * Lease state of the share. + */ + Nullable LeaseState; + /** + * The current lease status of the share. + */ + Nullable LeaseStatus; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::Download. + */ + struct DownloadFileResult final + { + /** + * Content of the file or file range. + */ + std::unique_ptr BodyStream; + /** + * Indicates the range of bytes returned. + */ + Core::Http::HttpRange ContentRange; + int64_t FileSize = int64_t(); + /** + * MD5 hash for the downloaded range of data. + */ + Nullable TransactionalContentHash; + /** + * Standard HTTP properties supported files. + */ + FileHttpHeaders HttpHeaders; + DownloadFileDetails Details; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::GetProperties. + */ + struct FileProperties final + { + /** + * The SMB related properties for the file. + */ + FileSmbProperties SmbProperties; + /** + * Standard HTTP properties supported files. + */ + FileHttpHeaders HttpHeaders; + /** + * Returns the date and time the file was last modified. The date format follows RFC 1123. Any + * operation that modifies the file or its properties updates the last modified time. + */ + DateTime LastModified; + /** + * A set of name-value pairs associated with this file as user-defined metadata. + */ + std::map< + std::string, + std::string, + Core::_internal::StringExtensions::CaseInsensitiveComparator> + Metadata; + /** + * The size of the file in bytes. This header returns the value of the 'x-ms-content-length' + * header that is stored with the file. + */ + int64_t FileSize = int64_t(); + /** + * The ETag contains a value that you can use to perform operations conditionally, in quotes. + */ + Azure::ETag ETag; + /** + * Conclusion time of the last attempted Copy File operation where this file was the + * destination file. This value can specify the time of a completed, aborted, or failed copy + * attempt. + */ + Nullable CopyCompletedOn; + /** + * Only appears when x-ms-copy-status is failed or pending. Describes cause of fatal or + * non-fatal copy operation failure. + */ + Nullable CopyStatusDescription; + /** + * String identifier for the last attempted Copy File operation where this file was the + * destination file. + */ + Nullable CopyId; + /** + * Contains the number of bytes copied and the total bytes in the source in the last attempted + * Copy File operation where this file was the destination file. Can show between 0 and + * Content-Length bytes copied. + */ + Nullable CopyProgress; + /** + * URL up to 2KB in length that specifies the source file used in the last attempted Copy File + * operation where this file was the destination file. + */ + Nullable CopySource; + /** + * State of the copy operation identified by 'x-ms-copy-id'. + */ + Nullable CopyStatus; + /** + * The value of this header is set to true if the file data and application metadata are + * completely encrypted using the specified algorithm. Otherwise, the value is set to false + * (when the file is unencrypted, or if only parts of the file/application metadata are + * encrypted). + */ + bool IsServerEncrypted = bool(); + /** + * When a file is leased, specifies whether the lease is of infinite or fixed duration. + */ + Nullable LeaseDuration; + /** + * Lease state of the file. + */ + Nullable LeaseState; + /** + * The current lease status of the file. + */ + Nullable LeaseStatus; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::Delete. + */ + struct DeleteFileResult final + { + /** + * Indicates if the file was successfully deleted by this operation. + */ + bool Deleted = true; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::SetHttpHeaders. + */ + struct SetFilePropertiesResult final + { + /** + * The SMB related properties for the file. + */ + FileSmbProperties SmbProperties; + /** + * The ETag contains a value which represents the version of the file, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the directory was last modified. Any operation that modifies the + * directory or its properties updates the last modified time. Operations on files do not + * affect the last modified time of the directory. + */ + DateTime LastModified; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = bool(); + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::SetMetadata. + */ + struct SetFileMetadataResult final + { + /** + * The ETag contains a value which represents the version of the file, in quotes. + */ + Azure::ETag ETag; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = bool(); + }; + namespace _detail { + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::AcquireLease. + */ + struct AcquireFileLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally. If the + * request version is 2011-08-18 or newer, the ETag value will be in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the file was last modified. Any operation that modifies the + * file, including an update of the file's metadata or properties, changes the last-modified + * time of the file. + */ + DateTime LastModified; + /** + * Uniquely identifies a file's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::ReleaseLease. + */ + struct ReleaseFileLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally. If the + * request version is 2011-08-18 or newer, the ETag value will be in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the file was last modified. Any operation that modifies the + * file, including an update of the file's metadata or properties, changes the last-modified + * time of the file. + */ + DateTime LastModified; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::ChangeLease. + */ + struct ChangeFileLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally. If the + * request version is 2011-08-18 or newer, the ETag value will be in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the file was last modified. Any operation that modifies the + * file, including an update of the file's metadata or properties, changes the last-modified + * time of the file. + */ + DateTime LastModified; + /** + * Uniquely identifies a file's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::BreakLease. + */ + struct BreakFileLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally. If the + * request version is 2011-08-18 or newer, the ETag value will be in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the file was last modified. Any operation that modifies the + * file, including an update of the file's metadata or properties, changes the last-modified + * time of the file. + */ + DateTime LastModified; + }; + } // namespace _detail + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::UploadRange. + */ + struct UploadFileRangeResult final + { + /** + * The ETag contains a value which represents the version of the file, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the directory was last modified. Any operation that modifies the + * share or its properties or metadata updates the last modified time. Operations on files do + * not affect the last modified time of the share. + */ + DateTime LastModified; + /** + * This header is returned so that the client can check for message content integrity. The + * value of this header is computed by the File service; it is not necessarily the same value + * as may have been specified in the request headers. + */ + ContentHash TransactionalContentHash; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = false; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::UploadRangeFromUri. + */ + struct UploadFileRangeFromUriResult final + { + /** + * The ETag contains a value which represents the version of the file, in quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the directory was last modified. Any operation that modifies the + * share or its properties or metadata updates the last modified time. Operations on files do + * not affect the last modified time of the share. + */ + DateTime LastModified; + /** + * This header is returned so that the client can check for message content integrity. The + * value of this header is computed by the File service; it is not necessarily the same value + * as may have been specified in the request headers. + */ + ContentHash TransactionalContentHash; + /** + * The value of this header is set to true if the contents of the request are successfully + * encrypted using the specified algorithm, and false otherwise. + */ + bool IsServerEncrypted = false; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::GetRangeList. + */ + struct GetFileRangeListResult final + { + /** + * Array of Range. + */ + std::vector Ranges; + /** + * Array of ClearRange. + */ + std::vector ClearRanges; + /** + * The date/time that the file was last modified. Any operation that modifies the file, + * including an update of the file's metadata or properties, changes the file's last modified + * time. + */ + DateTime LastModified; + /** + * The ETag contains a value which represents the version of the file, in quotes. + */ + Azure::ETag ETag; + /** + * The size of the file in bytes. + */ + int64_t FileSize = int64_t(); + }; + /** + * @brief Specifies the option to copy file security descriptor from source file or to set it + * using the value which is defined by the header value of x-ms-file-permission or + * x-ms-file-permission-key. + */ + class PermissionCopyMode final { + public: + PermissionCopyMode() = default; + explicit PermissionCopyMode(std::string value) : m_value(std::move(value)) {} + bool operator==(const PermissionCopyMode& other) const { return m_value == other.m_value; } + bool operator!=(const PermissionCopyMode& other) const { return !(*this == other); } + const std::string& ToString() const { return m_value; } + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static PermissionCopyMode Source; + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static PermissionCopyMode Override; + + private: + std::string m_value; + }; + namespace _detail { + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::StartCopy. + */ + struct StartFileCopyResult final + { + /** + * If the copy is completed, contains the ETag of the destination file. If the copy is not + * complete, contains the ETag of the empty file created at the start of the copy. + */ + Azure::ETag ETag; + /** + * Returns the date/time that the copy operation to the destination file completed. + */ + DateTime LastModified; + /** + * String identifier for this copy operation. Use with Get File or Get File Properties to + * check the status of this copy operation, or pass to Abort Copy File to abort a pending + * copy. + */ + std::string CopyId; + /** + * State of the copy operation identified by x-ms-copy-id. + */ + Models::CopyStatus CopyStatus; + }; + } // namespace _detail + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::AbortCopy. + */ + struct AbortFileCopyResult final + { + }; + namespace _detail { + /** + * @brief An enumeration of handles. + */ + struct ListHandlesResponse final + { + /** + * Array of HandleItem. + */ + std::vector HandleList; + std::string NextMarker; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::FileClient::ForceCloseHandles. + */ + struct ForceFileCloseHandlesResult final + { + /** + * A string describing next handle to be closed. It is returned when more handles need to be + * closed to complete the request. + */ + Nullable ContinuationToken; + /** + * Contains count of number of handles closed. + */ + int32_t NumberOfHandlesClosed = int32_t(); + /** + * Contains count of number of handles that failed to close. + */ + int32_t NumberOfHandlesFailedToClose = int32_t(); + }; + } // namespace _detail + } // namespace Models + namespace _detail { + class ServiceClient final { + public: + struct SetServicePropertiesOptions final + { + Models::ShareServiceProperties ShareServiceProperties; + }; + static Response SetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetServicePropertiesOptions& options, + const Core::Context& context); + struct GetServicePropertiesOptions final + { + }; + static Response GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetServicePropertiesOptions& options, + const Core::Context& context); + struct ListServiceSharesSegmentOptions final + { + Nullable Prefix; + Nullable Marker; + Nullable MaxResults; + Nullable Include; + }; + static Response ListSharesSegment( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListServiceSharesSegmentOptions& options, + const Core::Context& context); + }; + class ShareClient final { + public: + struct CreateShareOptions final + { + std::map Metadata; + Nullable Quota; + Nullable AccessTier; + }; + static Response Create( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateShareOptions& options, + const Core::Context& context); + struct GetSharePropertiesOptions final + { + Nullable Sharesnapshot; + Nullable LeaseId; + }; + static Response GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetSharePropertiesOptions& options, + const Core::Context& context); + struct DeleteShareOptions final + { + Nullable Sharesnapshot; + Nullable DeleteSnapshots; + Nullable LeaseId; + }; + static Response Delete( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DeleteShareOptions& options, + const Core::Context& context); + struct AcquireShareLeaseOptions final + { + Nullable Duration; + Nullable ProposedLeaseId; + Nullable Sharesnapshot; + }; + static Response AcquireLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const AcquireShareLeaseOptions& options, + const Core::Context& context); + struct ReleaseShareLeaseOptions final + { + std::string LeaseId; + Nullable Sharesnapshot; + }; + static Response ReleaseLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ReleaseShareLeaseOptions& options, + const Core::Context& context); + struct ChangeShareLeaseOptions final + { + std::string LeaseId; + Nullable ProposedLeaseId; + Nullable Sharesnapshot; + }; + static Response ChangeLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ChangeShareLeaseOptions& options, + const Core::Context& context); + struct RenewShareLeaseOptions final + { + std::string LeaseId; + Nullable Sharesnapshot; + }; + static Response RenewLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const RenewShareLeaseOptions& options, + const Core::Context& context); + struct BreakShareLeaseOptions final + { + Nullable BreakPeriod; + Nullable LeaseId; + Nullable Sharesnapshot; + }; + static Response BreakLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const BreakShareLeaseOptions& options, + const Core::Context& context); + struct CreateShareSnapshotOptions final + { + std::map Metadata; + }; + static Response CreateSnapshot( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateShareSnapshotOptions& options, + const Core::Context& context); + struct CreateSharePermissionOptions final + { + Models::_detail::SharePermission SharePermission; + }; + static Response CreatePermission( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateSharePermissionOptions& options, + const Core::Context& context); + struct GetSharePermissionOptions final + { + std::string FilePermissionKey; + }; + static Response GetPermission( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetSharePermissionOptions& options, + const Core::Context& context); + struct SetSharePropertiesOptions final + { + Nullable Quota; + Nullable AccessTier; + Nullable LeaseId; + }; + static Response SetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetSharePropertiesOptions& options, + const Core::Context& context); + struct SetShareMetadataOptions final + { + std::map Metadata; + Nullable LeaseId; + }; + static Response SetMetadata( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetShareMetadataOptions& options, + const Core::Context& context); + struct GetShareAccessPolicyOptions final + { + Nullable LeaseId; + }; + static Response GetAccessPolicy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetShareAccessPolicyOptions& options, + const Core::Context& context); + struct SetShareAccessPolicyOptions final + { + std::vector ShareAcl; + Nullable LeaseId; + }; + static Response SetAccessPolicy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetShareAccessPolicyOptions& options, + const Core::Context& context); + struct GetShareStatisticsOptions final + { + Nullable LeaseId; + }; + static Response GetStatistics( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetShareStatisticsOptions& options, + const Core::Context& context); + }; + class DirectoryClient final { + public: + struct CreateDirectoryOptions final + { + std::map Metadata; + Nullable FilePermission; + Nullable FilePermissionKey; + std::string FileAttributes; + std::string FileCreationTime; + std::string FileLastWriteTime; + }; + static Response Create( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateDirectoryOptions& options, + const Core::Context& context); + struct GetDirectoryPropertiesOptions final + { + Nullable Sharesnapshot; + }; + static Response GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetDirectoryPropertiesOptions& options, + const Core::Context& context); + struct DeleteDirectoryOptions final + { + }; + static Response Delete( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DeleteDirectoryOptions& options, + const Core::Context& context); + struct SetDirectoryPropertiesOptions final + { + Nullable FilePermission; + Nullable FilePermissionKey; + std::string FileAttributes; + std::string FileCreationTime; + std::string FileLastWriteTime; + }; + static Response SetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetDirectoryPropertiesOptions& options, + const Core::Context& context); + struct SetDirectoryMetadataOptions final + { + std::map Metadata; + }; + static Response SetMetadata( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetDirectoryMetadataOptions& options, + const Core::Context& context); + struct ListDirectoryFilesAndDirectoriesSegmentOptions final + { + Nullable Prefix; + Nullable Sharesnapshot; + Nullable Marker; + Nullable MaxResults; + }; + static Response + ListFilesAndDirectoriesSegment( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListDirectoryFilesAndDirectoriesSegmentOptions& options, + const Core::Context& context); + struct ListDirectoryHandlesOptions final + { + Nullable Marker; + Nullable MaxResults; + Nullable Sharesnapshot; + Nullable Recursive; + }; + static Response ListHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListDirectoryHandlesOptions& options, + const Core::Context& context); + struct ForceDirectoryCloseHandlesOptions final + { + Nullable Marker; + Nullable Sharesnapshot; + std::string HandleId; + Nullable Recursive; + }; + static Response ForceCloseHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ForceDirectoryCloseHandlesOptions& options, + const Core::Context& context); + }; + class FileClient final { + public: + struct CreateFileOptions final + { + int64_t FileContentLength = int64_t(); + Nullable FileContentType; + Nullable FileContentEncoding; + Nullable FileContentLanguage; + Nullable FileCacheControl; + Nullable> FileContentMD5; + Nullable FileContentDisposition; + std::map Metadata; + Nullable FilePermission; + Nullable FilePermissionKey; + std::string FileAttributes; + std::string FileCreationTime; + std::string FileLastWriteTime; + Nullable LeaseId; + }; + static Response Create( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateFileOptions& options, + const Core::Context& context); + struct DownloadFileOptions final + { + Nullable Range; + Nullable RangeGetContentMD5; + Nullable LeaseId; + }; + static Response Download( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DownloadFileOptions& options, + const Core::Context& context); + struct GetFilePropertiesOptions final + { + Nullable Sharesnapshot; + Nullable LeaseId; + }; + static Response GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetFilePropertiesOptions& options, + const Core::Context& context); + struct DeleteFileOptions final + { + Nullable LeaseId; + }; + static Response Delete( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DeleteFileOptions& options, + const Core::Context& context); + struct SetFileHttpHeadersOptions final + { + Nullable FileContentLength; + Nullable FileContentType; + Nullable FileContentEncoding; + Nullable FileContentLanguage; + Nullable FileCacheControl; + Nullable> FileContentMD5; + Nullable FileContentDisposition; + Nullable FilePermission; + Nullable FilePermissionKey; + std::string FileAttributes; + std::string FileCreationTime; + std::string FileLastWriteTime; + Nullable LeaseId; + }; + static Response SetHttpHeaders( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetFileHttpHeadersOptions& options, + const Core::Context& context); + struct SetFileMetadataOptions final + { + std::map Metadata; + Nullable LeaseId; + }; + static Response SetMetadata( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetFileMetadataOptions& options, + const Core::Context& context); + struct AcquireFileLeaseOptions final + { + Nullable Duration; + Nullable ProposedLeaseId; + }; + static Response AcquireLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const AcquireFileLeaseOptions& options, + const Core::Context& context); + struct ReleaseFileLeaseOptions final + { + std::string LeaseId; + }; + static Response ReleaseLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ReleaseFileLeaseOptions& options, + const Core::Context& context); + struct ChangeFileLeaseOptions final + { + std::string LeaseId; + Nullable ProposedLeaseId; + }; + static Response ChangeLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ChangeFileLeaseOptions& options, + const Core::Context& context); + struct BreakFileLeaseOptions final + { + Nullable LeaseId; + }; + static Response BreakLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const BreakFileLeaseOptions& options, + const Core::Context& context); + struct UploadFileRangeOptions final + { + std::string Range; + std::string FileRangeWrite; + Nullable> ContentMD5; + Nullable LeaseId; + }; + static Response UploadRange( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + Core::IO::BodyStream& requestBody, + const UploadFileRangeOptions& options, + const Core::Context& context); + struct UploadFileRangeFromUriOptions final + { + std::string Range; + std::string CopySource; + Nullable SourceRange; + Nullable> SourceContentCrc64; + Nullable> SourceIfMatchCrc64; + Nullable> SourceIfNoneMatchCrc64; + Nullable LeaseId; + }; + static Response UploadRangeFromUri( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const UploadFileRangeFromUriOptions& options, + const Core::Context& context); + struct GetFileRangeListOptions final + { + Nullable Sharesnapshot; + Nullable Prevsharesnapshot; + Nullable Range; + Nullable LeaseId; + }; + static Response GetRangeList( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetFileRangeListOptions& options, + const Core::Context& context); + struct StartFileCopyOptions final + { + std::map Metadata; + std::string CopySource; + Nullable FilePermission; + Nullable FilePermissionKey; + Nullable FilePermissionCopyMode; + Nullable IgnoreReadOnly; + Nullable FileAttributes; + Nullable FileCreationTime; + Nullable FileLastWriteTime; + Nullable SetArchiveAttribute; + Nullable LeaseId; + }; + static Response StartCopy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const StartFileCopyOptions& options, + const Core::Context& context); + struct AbortFileCopyOptions final + { + std::string CopyId; + Nullable LeaseId; + }; + static Response AbortCopy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const AbortFileCopyOptions& options, + const Core::Context& context); + struct ListFileHandlesOptions final + { + Nullable Marker; + Nullable MaxResults; + Nullable Sharesnapshot; + }; + static Response ListHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListFileHandlesOptions& options, + const Core::Context& context); + struct ForceFileCloseHandlesOptions final + { + Nullable Marker; + Nullable Sharesnapshot; + std::string HandleId; + }; + static Response ForceCloseHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ForceFileCloseHandlesOptions& options, + const Core::Context& context); + }; + } // namespace _detail +}}}} // namespace Azure::Storage::Files::Shares \ No newline at end of file diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp index 00903f871..684062fa6 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp @@ -9,7 +9,6 @@ #include #include -#include "azure/storage/files/shares/protocol/share_rest_client.hpp" #include "azure/storage/files/shares/share_options.hpp" #include "azure/storage/files/shares/share_responses.hpp" #include "azure/storage/files/shares/share_service_client.hpp" diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp index b453e0970..ef3f2f61a 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_directory_client.hpp @@ -10,7 +10,6 @@ #include #include -#include "azure/storage/files/shares/protocol/share_rest_client.hpp" #include "azure/storage/files/shares/share_client.hpp" #include "azure/storage/files/shares/share_options.hpp" #include "azure/storage/files/shares/share_responses.hpp" diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_attributes.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_attributes.hpp deleted file mode 100644 index 715c4908e..000000000 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_attributes.hpp +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#pragma once - -#include -#include - -#include "azure/storage/files/shares/dll_import_export.hpp" - -namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace Models { - - class FileAttributes final { - public: - FileAttributes() = default; - explicit FileAttributes(const std::string& value); - - std::string ToString() const; - const std::vector GetValues() const { return m_value; } - - bool operator==(const FileAttributes& other) const { return m_value == other.m_value; } - bool operator!=(const FileAttributes& other) const { return !(*this == other); } - - FileAttributes operator|(const FileAttributes& other) const; - FileAttributes operator&(const FileAttributes& other) const; - FileAttributes operator^(const FileAttributes& other) const; - - FileAttributes& operator|=(const FileAttributes& other) - { - *this = *this | other; - return *this; - } - - FileAttributes& operator&=(const FileAttributes& other) - { - *this = *this & other; - return *this; - } - - FileAttributes& operator^=(const FileAttributes& other) - { - *this = *this ^ other; - return *this; - } - - /** - * @brief The File or Directory is read-only. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes ReadOnly; - - /** - * @brief The File or Directory is hidden, and thus is not included in an ordinary directory - * listing. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Hidden; - - /** - * @brief The File or Directory is a systemfile. That is, the file is part of the operating - * system or is used exclusively by the operating system. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes System; - - /** - * @brief The file or directory is a standard file that has no special attributes. This - * attribute is valid only if it is used alone. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes None; - - /** - * @brief The file is a directory. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Directory; - - /** - * @brief The file is a candidate for backup or removal. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Archive; - - /** - * @brief The file or directory is temporary. A temporary file contains data that is needed - * while an application is executing but is not needed after the application is finished. File - * systems try to keep all the data in memory for quicker access rather than flushing the data - * back to mass storage. A temporary file should be deleted by the application as soon as it - * is no longer needed. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Temporary; - - /** - * @brief The file or directory is offline. The data of the file is not immediately available. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes Offline; - - /** - * @brief The file or directory will not be indexed by the operating system's content indexing - * service. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes NotContentIndexed; - - /** - * @brief The file or directory is excluded from the data integrity scan. When this value is - * applied to a directory, by default, all new files and subdirectories within that directory - * are excluded from data integrity. - */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FileAttributes NoScrubData; - - private: - std::vector m_value; - }; - -}}}}} // namespace Azure::Storage::Files::Shares::Models diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp index 22e6dee0b..813638e94 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp @@ -10,7 +10,6 @@ #include #include -#include "azure/storage/files/shares/protocol/share_rest_client.hpp" #include "azure/storage/files/shares/share_client.hpp" #include "azure/storage/files/shares/share_directory_client.hpp" #include "azure/storage/files/shares/share_options.hpp" diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp index 55a50ebc8..ac87d8d82 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp @@ -11,7 +11,7 @@ #include #include -#include "azure/storage/files/shares/protocol/share_rest_client.hpp" +#include "azure/storage/files/shares/rest_client.hpp" /* cSpell:ignore dacl */ diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp index 2f8ceb358..19d075ba1 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp @@ -6,7 +6,6 @@ #include #include -#include "azure/storage/files/shares/protocol/share_rest_client.hpp" #include "azure/storage/files/shares/share_constants.hpp" #include "azure/storage/files/shares/share_options.hpp" @@ -18,6 +17,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace Models { + using LeaseDuration [[deprecated]] = LeaseDurationType; + /** * @brief The information returned when forcing the directory handles to close. */ @@ -25,118 +26,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { }; - /** - * @brief The detailed information returned when downloading a file. - */ - struct DownloadFileDetails final - { - /** - * An HTTP entity tag associated with the file. - */ - Azure::ETag ETag; - - /** - * The data and time the file was last modified. - */ - DateTime LastModified; - - /** - * The metadata of the file. - */ - Storage::Metadata Metadata; - - /** - * The copy completed time of the file, if the file is created from a copy operation. - */ - Nullable CopyCompletedOn; - - /** - * The copy status's description of the file, if the file is created from a copy operation. - */ - Nullable CopyStatusDescription; - - /** - * The copy ID of the file, if the file is created from a copy operation. - */ - Nullable CopyId; - - /** - * The copy progress of the file, if the file is created from a copy operation. - */ - Nullable CopyProgress; - - /** - * The copy source of the file, if the file is created from a copy operation. - */ - Nullable CopySource; - - /** - * The copy status of the file, if the file is created from a copy operation. - */ - Nullable CopyStatus; - - /** - * A boolean indicates if the service is encrypted. - */ - bool IsServerEncrypted = bool(); - - /** - * The SMB related properties of the file or directory. - */ - FileSmbProperties SmbProperties; - - /** - * When a file is leased, specifies whether the lease is of infinite or fixed duration. - */ - Nullable LeaseDuration; - - /** - * Lease state of the file. - */ - Nullable LeaseState; - - /** - * The current lease status of the file. - */ - Nullable LeaseStatus; - }; - - /** - * @brief The content and information returned when downloading a file. - */ - struct DownloadFileResult final - { - /** - * The body of the downloaded result. - */ - std::unique_ptr BodyStream; - - /** - * The range of the downloaded content. - */ - Azure::Core::Http::HttpRange ContentRange; - - /** - * The size of the file. - */ - int64_t FileSize = 0; - - /** - * The transactional hash of the downloaded content. - */ - Nullable TransactionalContentHash; - - /** - * The common HTTP headers of the file. - */ - FileHttpHeaders HttpHeaders; - - /** - * The detailed information of the downloaded file. - */ - DownloadFileDetails Details; - }; - /** * @brief The information returned when clearing a range in the file. */ @@ -202,6 +91,103 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { bool IsServerEncrypted = false; }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareLeaseClient::AcquireLease. + */ + struct AcquireLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Uniquely identifies a share's or file's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareLeaseClient::ReleaseLease. + */ + struct ReleaseLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareLeaseClient::ChangeLease. + */ + struct ChangeLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Uniquely identifies a share's or file's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareLeaseClient::RenewLease. + */ + struct RenewLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + /** + * Uniquely identifies a share's or file's lease. + */ + std::string LeaseId; + }; + /** + * @brief Response type for #Azure::Storage::Files::Shares::ShareLeaseClient::BreakLease. + */ + struct BreakLeaseResult final + { + /** + * The ETag contains a value that you can use to perform operations conditionally, in + * quotes. + */ + Azure::ETag ETag; + /** + * Returns the date and time the share was last modified. Any operation that modifies the + * share or its properties updates the last modified time. Operations on files do not affect + * the last modified time of the share. + */ + DateTime LastModified; + }; } // namespace Models /** diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp index 89002bd77..435ee0b65 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_service_client.hpp @@ -10,7 +10,6 @@ #include #include -#include "azure/storage/files/shares/protocol/share_rest_client.hpp" #include "azure/storage/files/shares/share_options.hpp" #include "azure/storage/files/shares/share_responses.hpp" diff --git a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp new file mode 100644 index 000000000..9b3635e32 --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp @@ -0,0 +1,3450 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// +// Code generated by Microsoft (R) AutoRest C++ Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +std::string ListSharesIncludeFlagsToString( + const Azure::Storage::Files::Shares::Models::ListSharesIncludeFlags& val) +{ + const Azure::Storage::Files::Shares::Models::ListSharesIncludeFlags valueList[] = { + Azure::Storage::Files::Shares::Models::ListSharesIncludeFlags::Snapshots, + Azure::Storage::Files::Shares::Models::ListSharesIncludeFlags::Metadata, + Azure::Storage::Files::Shares::Models::ListSharesIncludeFlags::Deleted, + }; + const char* stringList[] = { + "snapshots", + "metadata", + "deleted", + }; + std::string ret; + for (size_t i = 0; i < 3; ++i) + { + if ((val & valueList[i]) == valueList[i]) + { + if (!ret.empty()) + { + ret += ","; + } + ret += stringList[i]; + } + } + return ret; +} +} // namespace +namespace Azure { namespace Storage { namespace Files { namespace Shares { + namespace Models { + const AccessTier AccessTier::TransactionOptimized("TransactionOptimized"); + const AccessTier AccessTier::Hot("Hot"); + const AccessTier AccessTier::Cool("Cool"); + const AccessTier AccessTier::Premium("Premium"); + const LeaseStatus LeaseStatus::Locked("locked"); + const LeaseStatus LeaseStatus::Unlocked("unlocked"); + const LeaseState LeaseState::Available("available"); + const LeaseState LeaseState::Leased("leased"); + const LeaseState LeaseState::Expired("expired"); + const LeaseState LeaseState::Breaking("breaking"); + const LeaseState LeaseState::Broken("broken"); + const LeaseDurationType LeaseDurationType::Infinite("infinite"); + const LeaseDurationType LeaseDurationType::Fixed("fixed"); + const DeleteSnapshotsOption DeleteSnapshotsOption::Include("include"); + FileAttributes::FileAttributes(const std::string& value) + { + const std::string delimiter = " | "; + size_t cur = 0; + while (cur != std::string::npos) + { + auto delimiter_pos = value.find(delimiter, cur); + std::string v; + if (delimiter_pos == std::string::npos) + { + v = value.substr(cur); + cur = delimiter_pos; + } + else + { + v = value.substr(cur, delimiter_pos - cur); + cur = delimiter_pos + delimiter.size(); + } + if (!v.empty()) + { + m_value.push_back(std::move(v)); + } + } + std::sort(m_value.begin(), m_value.end()); + } + FileAttributes FileAttributes::operator|(const FileAttributes& other) const + { + FileAttributes ret; + std::set_union( + m_value.begin(), + m_value.end(), + other.m_value.begin(), + other.m_value.end(), + std::back_inserter(ret.m_value)); + return ret; + } + FileAttributes FileAttributes::operator&(const FileAttributes& other) const + { + FileAttributes ret; + std::set_intersection( + m_value.begin(), + m_value.end(), + other.m_value.begin(), + other.m_value.end(), + std::back_inserter(ret.m_value)); + return ret; + } + FileAttributes FileAttributes::operator^(const FileAttributes& other) const + { + FileAttributes ret; + std::set_symmetric_difference( + m_value.begin(), + m_value.end(), + other.m_value.begin(), + other.m_value.end(), + std::back_inserter(ret.m_value)); + return ret; + } + std::string FileAttributes::ToString() const + { + std::string ret; + for (const auto& v : m_value) + { + ret += (ret.empty() ? "" : " | ") + v; + } + return ret; + } + const FileAttributes FileAttributes::ReadOnly("ReadOnly"); + const FileAttributes FileAttributes::Hidden("Hidden"); + const FileAttributes FileAttributes::System("System"); + const FileAttributes FileAttributes::None("None"); + const FileAttributes FileAttributes::Directory("Directory"); + const FileAttributes FileAttributes::Archive("Archive"); + const FileAttributes FileAttributes::Temporary("Temporary"); + const FileAttributes FileAttributes::Offline("Offline"); + const FileAttributes FileAttributes::NotContentIndexed("NotContentIndexed"); + const FileAttributes FileAttributes::NoScrubData("NoScrubData"); + const CopyStatus CopyStatus::Pending("pending"); + const CopyStatus CopyStatus::Success("success"); + const CopyStatus CopyStatus::Aborted("aborted"); + const CopyStatus CopyStatus::Failed("failed"); + const PermissionCopyMode PermissionCopyMode::Source("source"); + const PermissionCopyMode PermissionCopyMode::Override("override"); + } // namespace Models + namespace _detail { + Response ServiceClient::SetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetServicePropertiesOptions& options, + const Core::Context& context) + { + std::string xmlBody; + { + _internal::XmlWriter writer; + writer.Write( + _internal::XmlNode{_internal::XmlNodeType::StartTag, "StorageServiceProperties"}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "HourMetrics"}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Version", + options.ShareServiceProperties.HourMetrics.Version}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Enabled", + options.ShareServiceProperties.HourMetrics.Enabled ? "true" : "false"}); + if (options.ShareServiceProperties.HourMetrics.IncludeApis.HasValue()) + { + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "IncludeAPIs", + options.ShareServiceProperties.HourMetrics.IncludeApis.Value() ? "true" : "false"}); + } + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "RetentionPolicy"}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Enabled", + options.ShareServiceProperties.HourMetrics.RetentionPolicy.Enabled ? "true" : "false"}); + if (options.ShareServiceProperties.HourMetrics.RetentionPolicy.Days.HasValue()) + { + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Days", + std::to_string( + options.ShareServiceProperties.HourMetrics.RetentionPolicy.Days.Value())}); + } + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "MinuteMetrics"}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Version", + options.ShareServiceProperties.MinuteMetrics.Version}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Enabled", + options.ShareServiceProperties.MinuteMetrics.Enabled ? "true" : "false"}); + if (options.ShareServiceProperties.MinuteMetrics.IncludeApis.HasValue()) + { + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "IncludeAPIs", + options.ShareServiceProperties.MinuteMetrics.IncludeApis.Value() ? "true" : "false"}); + } + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "RetentionPolicy"}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Enabled", + options.ShareServiceProperties.MinuteMetrics.RetentionPolicy.Enabled ? "true" + : "false"}); + if (options.ShareServiceProperties.MinuteMetrics.RetentionPolicy.Days.HasValue()) + { + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Days", + std::to_string( + options.ShareServiceProperties.MinuteMetrics.RetentionPolicy.Days.Value())}); + } + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Cors"}); + for (const auto& i1 : options.ShareServiceProperties.Cors) + { + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "CorsRule"}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, "AllowedOrigins", i1.AllowedOrigins}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, "AllowedMethods", i1.AllowedMethods}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, "AllowedHeaders", i1.AllowedHeaders}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, "ExposedHeaders", i1.ExposedHeaders}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "MaxAgeInSeconds", + std::to_string(i1.MaxAgeInSeconds)}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + } + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + if (options.ShareServiceProperties.Protocol.HasValue()) + { + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Protocol"}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Settings"}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Multichannel"}); + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Enabled", + options.ShareServiceProperties.Protocol.Value().Settings.Multichannel.Enabled + ? "true" + : "false"}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + } + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::End}); + xmlBody = writer.GetDocument(); + } + Core::IO::MemoryBodyStream requestBody( + reinterpret_cast(xmlBody.data()), xmlBody.length()); + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url, &requestBody); + request.SetHeader("Content-Type", "application/xml; charset=UTF-8"); + request.SetHeader("Content-Length", std::to_string(requestBody.Length())); + request.GetUrl().AppendQueryParameter("restype", "service"); + request.GetUrl().AppendQueryParameter("comp", "properties"); + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetServicePropertiesResult response; + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ServiceClient::GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetServicePropertiesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("restype", "service"); + request.GetUrl().AppendQueryParameter("comp", "properties"); + request.SetHeader("x-ms-version", "2020-02-10"); + (void)options; + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::ShareServiceProperties response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kStorageServiceProperties, + kHourMetrics, + kVersion, + kEnabled, + kIncludeAPIs, + kRetentionPolicy, + kDays, + kMinuteMetrics, + kCors, + kCorsRule, + kAllowedOrigins, + kAllowedMethods, + kAllowedHeaders, + kExposedHeaders, + kMaxAgeInSeconds, + kProtocol, + kSettings, + kMultichannel, + }; + const std::unordered_map XmlTagEnumMap{ + {"StorageServiceProperties", XmlTagEnum::kStorageServiceProperties}, + {"HourMetrics", XmlTagEnum::kHourMetrics}, + {"Version", XmlTagEnum::kVersion}, + {"Enabled", XmlTagEnum::kEnabled}, + {"IncludeAPIs", XmlTagEnum::kIncludeAPIs}, + {"RetentionPolicy", XmlTagEnum::kRetentionPolicy}, + {"Days", XmlTagEnum::kDays}, + {"MinuteMetrics", XmlTagEnum::kMinuteMetrics}, + {"Cors", XmlTagEnum::kCors}, + {"CorsRule", XmlTagEnum::kCorsRule}, + {"AllowedOrigins", XmlTagEnum::kAllowedOrigins}, + {"AllowedMethods", XmlTagEnum::kAllowedMethods}, + {"AllowedHeaders", XmlTagEnum::kAllowedHeaders}, + {"ExposedHeaders", XmlTagEnum::kExposedHeaders}, + {"MaxAgeInSeconds", XmlTagEnum::kMaxAgeInSeconds}, + {"Protocol", XmlTagEnum::kProtocol}, + {"Settings", XmlTagEnum::kSettings}, + {"Multichannel", XmlTagEnum::kMultichannel}, + }; + std::vector xmlPath; + Models::CorsRule vectorElement1; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + if (xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kProtocol) + { + response.Protocol = Models::ProtocolSettings(); + } + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kHourMetrics && xmlPath[2] == XmlTagEnum::kVersion) + { + response.HourMetrics.Version = node.Value; + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kHourMetrics && xmlPath[2] == XmlTagEnum::kEnabled) + { + response.HourMetrics.Enabled = node.Value == std::string("true"); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kHourMetrics && xmlPath[2] == XmlTagEnum::kIncludeAPIs) + { + response.HourMetrics.IncludeApis = node.Value == std::string("true"); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kHourMetrics + && xmlPath[2] == XmlTagEnum::kRetentionPolicy && xmlPath[3] == XmlTagEnum::kEnabled) + { + response.HourMetrics.RetentionPolicy.Enabled = node.Value == std::string("true"); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kHourMetrics + && xmlPath[2] == XmlTagEnum::kRetentionPolicy && xmlPath[3] == XmlTagEnum::kDays) + { + response.HourMetrics.RetentionPolicy.Days = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kMinuteMetrics && xmlPath[2] == XmlTagEnum::kVersion) + { + response.MinuteMetrics.Version = node.Value; + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kMinuteMetrics && xmlPath[2] == XmlTagEnum::kEnabled) + { + response.MinuteMetrics.Enabled = node.Value == std::string("true"); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kMinuteMetrics + && xmlPath[2] == XmlTagEnum::kIncludeAPIs) + { + response.MinuteMetrics.IncludeApis = node.Value == std::string("true"); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kMinuteMetrics + && xmlPath[2] == XmlTagEnum::kRetentionPolicy && xmlPath[3] == XmlTagEnum::kEnabled) + { + response.MinuteMetrics.RetentionPolicy.Enabled = node.Value == std::string("true"); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kMinuteMetrics + && xmlPath[2] == XmlTagEnum::kRetentionPolicy && xmlPath[3] == XmlTagEnum::kDays) + { + response.MinuteMetrics.RetentionPolicy.Days = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kCors && xmlPath[2] == XmlTagEnum::kCorsRule + && xmlPath[3] == XmlTagEnum::kAllowedOrigins) + { + vectorElement1.AllowedOrigins = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kCors && xmlPath[2] == XmlTagEnum::kCorsRule + && xmlPath[3] == XmlTagEnum::kAllowedMethods) + { + vectorElement1.AllowedMethods = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kCors && xmlPath[2] == XmlTagEnum::kCorsRule + && xmlPath[3] == XmlTagEnum::kAllowedHeaders) + { + vectorElement1.AllowedHeaders = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kCors && xmlPath[2] == XmlTagEnum::kCorsRule + && xmlPath[3] == XmlTagEnum::kExposedHeaders) + { + vectorElement1.ExposedHeaders = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kCors && xmlPath[2] == XmlTagEnum::kCorsRule + && xmlPath[3] == XmlTagEnum::kMaxAgeInSeconds) + { + vectorElement1.MaxAgeInSeconds = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kProtocol && xmlPath[2] == XmlTagEnum::kSettings + && xmlPath[3] == XmlTagEnum::kMultichannel && xmlPath[4] == XmlTagEnum::kEnabled) + { + response.Protocol.Value().Settings.Multichannel.Enabled + = node.Value == std::string("true"); + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kStorageServiceProperties + && xmlPath[1] == XmlTagEnum::kCors && xmlPath[2] == XmlTagEnum::kCorsRule) + { + response.Cors.push_back(std::move(vectorElement1)); + vectorElement1 = Models::CorsRule(); + } + xmlPath.pop_back(); + } + } + } + return Response(std::move(response), std::move(pRawResponse)); + } + Response ServiceClient::ListSharesSegment( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListServiceSharesSegmentOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("comp", "list"); + if (options.Prefix.HasValue() && !options.Prefix.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "prefix", _internal::UrlEncodeQueryParameter(options.Prefix.Value())); + } + if (options.Marker.HasValue() && !options.Marker.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "marker", _internal::UrlEncodeQueryParameter(options.Marker.Value())); + } + if (options.MaxResults.HasValue()) + { + request.GetUrl().AppendQueryParameter( + "maxresults", std::to_string(options.MaxResults.Value())); + } + if (options.Include.HasValue() + && !ListSharesIncludeFlagsToString(options.Include.Value()).empty()) + { + request.GetUrl().AppendQueryParameter( + "include", + _internal::UrlEncodeQueryParameter( + ListSharesIncludeFlagsToString(options.Include.Value()))); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ListSharesResponse response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kEnumerationResults, + kPrefix, + kMarker, + kMaxResults, + kShares, + kShare, + kName, + kSnapshot, + kDeleted, + kVersion, + kMetadata, + kProperties, + kLastModified, + kEtag, + kQuota, + kProvisionedIops, + kProvisionedIngressMBps, + kProvisionedEgressMBps, + kNextAllowedQuotaDowngradeTime, + kDeletedTime, + kRemainingRetentionDays, + kAccessTier, + kAccessTierChangeTime, + kAccessTierTransitionState, + kLeaseStatus, + kLeaseState, + kLeaseDuration, + kNextMarker, + }; + const std::unordered_map XmlTagEnumMap{ + {"EnumerationResults", XmlTagEnum::kEnumerationResults}, + {"Prefix", XmlTagEnum::kPrefix}, + {"Marker", XmlTagEnum::kMarker}, + {"MaxResults", XmlTagEnum::kMaxResults}, + {"Shares", XmlTagEnum::kShares}, + {"Share", XmlTagEnum::kShare}, + {"Name", XmlTagEnum::kName}, + {"Snapshot", XmlTagEnum::kSnapshot}, + {"Deleted", XmlTagEnum::kDeleted}, + {"Version", XmlTagEnum::kVersion}, + {"Metadata", XmlTagEnum::kMetadata}, + {"Properties", XmlTagEnum::kProperties}, + {"Last-Modified", XmlTagEnum::kLastModified}, + {"Etag", XmlTagEnum::kEtag}, + {"Quota", XmlTagEnum::kQuota}, + {"ProvisionedIops", XmlTagEnum::kProvisionedIops}, + {"ProvisionedIngressMBps", XmlTagEnum::kProvisionedIngressMBps}, + {"ProvisionedEgressMBps", XmlTagEnum::kProvisionedEgressMBps}, + {"NextAllowedQuotaDowngradeTime", XmlTagEnum::kNextAllowedQuotaDowngradeTime}, + {"DeletedTime", XmlTagEnum::kDeletedTime}, + {"RemainingRetentionDays", XmlTagEnum::kRemainingRetentionDays}, + {"AccessTier", XmlTagEnum::kAccessTier}, + {"AccessTierChangeTime", XmlTagEnum::kAccessTierChangeTime}, + {"AccessTierTransitionState", XmlTagEnum::kAccessTierTransitionState}, + {"LeaseStatus", XmlTagEnum::kLeaseStatus}, + {"LeaseState", XmlTagEnum::kLeaseState}, + {"LeaseDuration", XmlTagEnum::kLeaseDuration}, + {"NextMarker", XmlTagEnum::kNextMarker}, + }; + std::vector xmlPath; + Models::ShareItem vectorElement1; + std::string mapKey2; + std::string mapValue3; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + if (xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kMetadata) + { + mapKey2 = node.Name; + } + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kPrefix) + { + response.Prefix = node.Value; + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kMarker) + { + response.Marker = node.Value; + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kMaxResults) + { + response.MaxResults = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kName) + { + vectorElement1.Name = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kSnapshot) + { + vectorElement1.Snapshot = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kDeleted) + { + vectorElement1.Deleted = node.Value == std::string("true"); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kVersion) + { + vectorElement1.Version = node.Value; + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kMetadata) + { + mapValue3 = node.Value; + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties && xmlPath[4] == XmlTagEnum::kLastModified) + { + vectorElement1.Details.LastModified + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties && xmlPath[4] == XmlTagEnum::kEtag) + { + vectorElement1.Details.Etag = ETag(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties && xmlPath[4] == XmlTagEnum::kQuota) + { + vectorElement1.Details.Quota = std::stoll(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kProvisionedIops) + { + vectorElement1.Details.ProvisionedIops = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kProvisionedIngressMBps) + { + vectorElement1.Details.ProvisionedIngressMBps = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kProvisionedEgressMBps) + { + vectorElement1.Details.ProvisionedEgressMBps = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kNextAllowedQuotaDowngradeTime) + { + vectorElement1.Details.NextAllowedQuotaDowngradeTime + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties && xmlPath[4] == XmlTagEnum::kDeletedTime) + { + vectorElement1.Details.DeletedOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kRemainingRetentionDays) + { + vectorElement1.Details.RemainingRetentionDays = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties && xmlPath[4] == XmlTagEnum::kAccessTier) + { + vectorElement1.Details.AccessTier = Models::AccessTier(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kAccessTierChangeTime) + { + vectorElement1.Details.AccessTierChangedOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kAccessTierTransitionState) + { + vectorElement1.Details.AccessTierTransitionState = node.Value; + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties && xmlPath[4] == XmlTagEnum::kLeaseStatus) + { + vectorElement1.Details.LeaseStatus = Models::LeaseStatus(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties && xmlPath[4] == XmlTagEnum::kLeaseState) + { + vectorElement1.Details.LeaseState = Models::LeaseState(node.Value); + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kLeaseDuration) + { + vectorElement1.Details.LeaseDuration = Models::LeaseDurationType(node.Value); + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kNextMarker) + { + response.NextMarker = node.Value; + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + if (xmlPath.size() == 1 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && node.Name == "ServiceEndpoint") + { + response.ServiceEndpoint = node.Value; + } + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare + && xmlPath[3] == XmlTagEnum::kMetadata) + { + vectorElement1.Metadata[std::move(mapKey2)] = std::move(mapValue3); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare) + { + response.ShareItems.push_back(std::move(vectorElement1)); + vectorElement1 = Models::ShareItem(); + } + xmlPath.pop_back(); + } + } + } + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::Create( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateShareOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + if (options.Quota.HasValue()) + { + request.SetHeader("x-ms-share-quota", std::to_string(options.Quota.Value())); + } + if (options.AccessTier.HasValue() && !options.AccessTier.Value().ToString().empty()) + { + request.SetHeader("x-ms-access-tier", options.AccessTier.Value().ToString()); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::CreateShareResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response(std::move(response), std::move(pRawResponse)); + } + Response ShareClient::GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetSharePropertiesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::ShareProperties response; + for (auto i = pRawResponse->GetHeaders().lower_bound("x-ms-meta-"); + i != pRawResponse->GetHeaders().end() && i->first.substr(0, 10) == "x-ms-meta-"; + ++i) + { + response.Metadata.emplace(i->first.substr(10), i->second); + } + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.Quota = std::stoll(pRawResponse->GetHeaders().at("x-ms-share-quota")); + if (pRawResponse->GetHeaders().count("x-ms-share-provisioned-iops") != 0) + { + response.ProvisionedIops + = std::stoi(pRawResponse->GetHeaders().at("x-ms-share-provisioned-iops")); + } + if (pRawResponse->GetHeaders().count("x-ms-share-provisioned-ingress-mbps") != 0) + { + response.ProvisionedIngressMBps + = std::stoi(pRawResponse->GetHeaders().at("x-ms-share-provisioned-ingress-mbps")); + } + if (pRawResponse->GetHeaders().count("x-ms-share-provisioned-egress-mbps") != 0) + { + response.ProvisionedEgressMBps + = std::stoi(pRawResponse->GetHeaders().at("x-ms-share-provisioned-egress-mbps")); + } + if (pRawResponse->GetHeaders().count("x-ms-share-next-allowed-quota-downgrade-time") != 0) + { + response.NextAllowedQuotaDowngradeTime = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-share-next-allowed-quota-downgrade-time"), + Azure::DateTime::DateFormat::Rfc1123); + } + if (pRawResponse->GetHeaders().count("x-ms-lease-duration") != 0) + { + response.LeaseDuration + = Models::LeaseDurationType(pRawResponse->GetHeaders().at("x-ms-lease-duration")); + } + if (pRawResponse->GetHeaders().count("x-ms-lease-state") != 0) + { + response.LeaseState = Models::LeaseState(pRawResponse->GetHeaders().at("x-ms-lease-state")); + } + if (pRawResponse->GetHeaders().count("x-ms-lease-status") != 0) + { + response.LeaseStatus + = Models::LeaseStatus(pRawResponse->GetHeaders().at("x-ms-lease-status")); + } + if (pRawResponse->GetHeaders().count("x-ms-access-tier") != 0) + { + response.AccessTier = Models::AccessTier(pRawResponse->GetHeaders().at("x-ms-access-tier")); + } + if (pRawResponse->GetHeaders().count("x-ms-access-tier-change-time") != 0) + { + response.AccessTierChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-access-tier-change-time"), + Azure::DateTime::DateFormat::Rfc1123); + } + if (pRawResponse->GetHeaders().count("x-ms-access-tier-transition-state") != 0) + { + response.AccessTierTransitionState + = pRawResponse->GetHeaders().at("x-ms-access-tier-transition-state"); + } + return Response(std::move(response), std::move(pRawResponse)); + } + Response ShareClient::Delete( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DeleteShareOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Delete, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.DeleteSnapshots.HasValue() && !options.DeleteSnapshots.Value().ToString().empty()) + { + request.SetHeader("x-ms-delete-snapshots", options.DeleteSnapshots.Value().ToString()); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::DeleteShareResult response; + return Response(std::move(response), std::move(pRawResponse)); + } + Response ShareClient::AcquireLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const AcquireShareLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "acquire"); + request.GetUrl().AppendQueryParameter("restype", "share"); + if (options.Duration.HasValue()) + { + request.SetHeader("x-ms-lease-duration", std::to_string(options.Duration.Value())); + } + if (options.ProposedLeaseId.HasValue() && !options.ProposedLeaseId.Value().empty()) + { + request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::AcquireShareLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.LeaseId = pRawResponse->GetHeaders().at("x-ms-lease-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::ReleaseLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ReleaseShareLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "release"); + request.GetUrl().AppendQueryParameter("restype", "share"); + if (!options.LeaseId.empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ReleaseShareLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::ChangeLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ChangeShareLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "change"); + request.GetUrl().AppendQueryParameter("restype", "share"); + if (!options.LeaseId.empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId); + } + if (options.ProposedLeaseId.HasValue() && !options.ProposedLeaseId.Value().empty()) + { + request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ChangeShareLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.LeaseId = pRawResponse->GetHeaders().at("x-ms-lease-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::RenewLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const RenewShareLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "renew"); + request.GetUrl().AppendQueryParameter("restype", "share"); + if (!options.LeaseId.empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::RenewShareLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.LeaseId = pRawResponse->GetHeaders().at("x-ms-lease-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::BreakLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const BreakShareLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "break"); + request.GetUrl().AppendQueryParameter("restype", "share"); + if (options.BreakPeriod.HasValue()) + { + request.SetHeader("x-ms-lease-break-period", std::to_string(options.BreakPeriod.Value())); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::BreakShareLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.LeaseTime = std::stoi(pRawResponse->GetHeaders().at("x-ms-lease-time")); + response.LeaseId = pRawResponse->GetHeaders().at("x-ms-lease-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::CreateSnapshot( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateShareSnapshotOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "snapshot"); + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::CreateShareSnapshotResult response; + response.Snapshot = pRawResponse->GetHeaders().at("x-ms-snapshot"); + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::CreatePermission( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateSharePermissionOptions& options, + const Core::Context& context) + { + std::string jsonBody; + { + auto jsonRoot = Core::Json::_internal::json::object(); + jsonRoot["permission"] = options.SharePermission.Permission; + jsonBody = jsonRoot.dump(); + } + Core::IO::MemoryBodyStream requestBody( + reinterpret_cast(jsonBody.data()), jsonBody.length()); + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url, &requestBody); + request.SetHeader("Content-Type", "application/json"); + request.SetHeader("Content-Length", std::to_string(requestBody.Length())); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "filepermission"); + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::CreateSharePermissionResult response; + response.FilePermissionKey = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::GetPermission( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetSharePermissionOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "filepermission"); + if (!options.FilePermissionKey.empty()) + { + request.SetHeader("x-ms-file-permission-key", options.FilePermissionKey); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::SharePermission response; + { + const auto& responseBody = pRawResponse->GetBody(); + auto jsonRoot + = Core::Json::_internal::json::parse(responseBody.begin(), responseBody.end()); + response.Permission = jsonRoot["permission"].get(); + } + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::SetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetSharePropertiesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "properties"); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Quota.HasValue()) + { + request.SetHeader("x-ms-share-quota", std::to_string(options.Quota.Value())); + } + if (options.AccessTier.HasValue() && !options.AccessTier.Value().ToString().empty()) + { + request.SetHeader("x-ms-access-tier", options.AccessTier.Value().ToString()); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetSharePropertiesResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::SetMetadata( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetShareMetadataOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "metadata"); + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetShareMetadataResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response(std::move(response), std::move(pRawResponse)); + } + Response ShareClient::GetAccessPolicy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetShareAccessPolicyOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "acl"); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::ShareAccessPolicy response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kSignedIdentifiers, + kSignedIdentifier, + kId, + kAccessPolicy, + kStart, + kExpiry, + kPermission, + }; + const std::unordered_map XmlTagEnumMap{ + {"SignedIdentifiers", XmlTagEnum::kSignedIdentifiers}, + {"SignedIdentifier", XmlTagEnum::kSignedIdentifier}, + {"Id", XmlTagEnum::kId}, + {"AccessPolicy", XmlTagEnum::kAccessPolicy}, + {"Start", XmlTagEnum::kStart}, + {"Expiry", XmlTagEnum::kExpiry}, + {"Permission", XmlTagEnum::kPermission}, + }; + std::vector xmlPath; + Models::SignedIdentifier vectorElement1; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kSignedIdentifiers + && xmlPath[1] == XmlTagEnum::kSignedIdentifier && xmlPath[2] == XmlTagEnum::kId) + { + vectorElement1.Id = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kSignedIdentifiers + && xmlPath[1] == XmlTagEnum::kSignedIdentifier + && xmlPath[2] == XmlTagEnum::kAccessPolicy && xmlPath[3] == XmlTagEnum::kStart) + { + vectorElement1.Policy.StartsOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc3339); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kSignedIdentifiers + && xmlPath[1] == XmlTagEnum::kSignedIdentifier + && xmlPath[2] == XmlTagEnum::kAccessPolicy && xmlPath[3] == XmlTagEnum::kExpiry) + { + vectorElement1.Policy.ExpiresOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc3339); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kSignedIdentifiers + && xmlPath[1] == XmlTagEnum::kSignedIdentifier + && xmlPath[2] == XmlTagEnum::kAccessPolicy && xmlPath[3] == XmlTagEnum::kPermission) + { + vectorElement1.Policy.Permission = node.Value; + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kSignedIdentifiers + && xmlPath[1] == XmlTagEnum::kSignedIdentifier) + { + response.SignedIdentifiers.push_back(std::move(vectorElement1)); + vectorElement1 = Models::SignedIdentifier(); + } + xmlPath.pop_back(); + } + } + } + return Response(std::move(response), std::move(pRawResponse)); + } + Response ShareClient::SetAccessPolicy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetShareAccessPolicyOptions& options, + const Core::Context& context) + { + std::string xmlBody; + { + _internal::XmlWriter writer; + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "SignedIdentifiers"}); + for (const auto& i1 : options.ShareAcl) + { + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "SignedIdentifier"}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "Id", i1.Id}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::StartTag, "AccessPolicy"}); + if (i1.Policy.StartsOn.HasValue()) + { + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Start", + i1.Policy.StartsOn.Value().ToString( + Azure::DateTime::DateFormat::Rfc3339, + Azure::DateTime::TimeFractionFormat::AllDigits)}); + } + if (i1.Policy.ExpiresOn.HasValue()) + { + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, + "Expiry", + i1.Policy.ExpiresOn.Value().ToString( + Azure::DateTime::DateFormat::Rfc3339, + Azure::DateTime::TimeFractionFormat::AllDigits)}); + } + writer.Write(_internal::XmlNode{ + _internal::XmlNodeType::StartTag, "Permission", i1.Policy.Permission}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + } + writer.Write(_internal::XmlNode{_internal::XmlNodeType::EndTag}); + writer.Write(_internal::XmlNode{_internal::XmlNodeType::End}); + xmlBody = writer.GetDocument(); + } + Core::IO::MemoryBodyStream requestBody( + reinterpret_cast(xmlBody.data()), xmlBody.length()); + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url, &requestBody); + request.SetHeader("Content-Type", "application/xml; charset=UTF-8"); + request.SetHeader("Content-Length", std::to_string(requestBody.Length())); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "acl"); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetShareAccessPolicyResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response ShareClient::GetStatistics( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetShareStatisticsOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("restype", "share"); + request.GetUrl().AppendQueryParameter("comp", "stats"); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::ShareStatistics response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kShareStats, + kShareUsageBytes, + }; + const std::unordered_map XmlTagEnumMap{ + {"ShareStats", XmlTagEnum::kShareStats}, + {"ShareUsageBytes", XmlTagEnum::kShareUsageBytes}, + }; + std::vector xmlPath; + + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kShareStats + && xmlPath[1] == XmlTagEnum::kShareUsageBytes) + { + response.ShareUsageInBytes = std::stoll(node.Value); + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + + xmlPath.pop_back(); + } + } + } + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response(std::move(response), std::move(pRawResponse)); + } + Response DirectoryClient::Create( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateDirectoryOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("restype", "directory"); + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.FilePermission.HasValue() && !options.FilePermission.Value().empty()) + { + request.SetHeader("x-ms-file-permission", options.FilePermission.Value()); + } + if (options.FilePermissionKey.HasValue() && !options.FilePermissionKey.Value().empty()) + { + request.SetHeader("x-ms-file-permission-key", options.FilePermissionKey.Value()); + } + if (!options.FileAttributes.empty()) + { + request.SetHeader("x-ms-file-attributes", options.FileAttributes); + } + if (!options.FileCreationTime.empty()) + { + request.SetHeader("x-ms-file-creation-time", options.FileCreationTime); + } + if (!options.FileLastWriteTime.empty()) + { + request.SetHeader("x-ms-file-last-write-time", options.FileLastWriteTime); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::CreateDirectoryResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + if (pRawResponse->GetHeaders().count("x-ms-file-permission-key") != 0) + { + response.SmbProperties.PermissionKey + = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + } + response.SmbProperties.Attributes + = Models::FileAttributes(pRawResponse->GetHeaders().at("x-ms-file-attributes")); + if (pRawResponse->GetHeaders().count("x-ms-file-creation-time") != 0) + { + response.SmbProperties.CreatedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-creation-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-last-write-time") != 0) + { + response.SmbProperties.LastWrittenOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-last-write-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-change-time") != 0) + { + response.SmbProperties.ChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-change-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + response.SmbProperties.FileId = pRawResponse->GetHeaders().at("x-ms-file-id"); + response.SmbProperties.ParentFileId = pRawResponse->GetHeaders().at("x-ms-file-parent-id"); + return Response(std::move(response), std::move(pRawResponse)); + } + Response DirectoryClient::GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetDirectoryPropertiesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("restype", "directory"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::DirectoryProperties response; + for (auto i = pRawResponse->GetHeaders().lower_bound("x-ms-meta-"); + i != pRawResponse->GetHeaders().end() && i->first.substr(0, 10) == "x-ms-meta-"; + ++i) + { + response.Metadata.emplace(i->first.substr(10), i->second); + } + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-server-encrypted") == std::string("true"); + response.SmbProperties.Attributes + = Models::FileAttributes(pRawResponse->GetHeaders().at("x-ms-file-attributes")); + if (pRawResponse->GetHeaders().count("x-ms-file-creation-time") != 0) + { + response.SmbProperties.CreatedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-creation-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-last-write-time") != 0) + { + response.SmbProperties.LastWrittenOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-last-write-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-change-time") != 0) + { + response.SmbProperties.ChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-change-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-permission-key") != 0) + { + response.SmbProperties.PermissionKey + = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + } + response.SmbProperties.FileId = pRawResponse->GetHeaders().at("x-ms-file-id"); + response.SmbProperties.ParentFileId = pRawResponse->GetHeaders().at("x-ms-file-parent-id"); + return Response(std::move(response), std::move(pRawResponse)); + } + Response DirectoryClient::Delete( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DeleteDirectoryOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Delete, url); + request.GetUrl().AppendQueryParameter("restype", "directory"); + request.SetHeader("x-ms-version", "2020-02-10"); + (void)options; + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::DeleteDirectoryResult response; + return Response(std::move(response), std::move(pRawResponse)); + } + Response DirectoryClient::SetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetDirectoryPropertiesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("restype", "directory"); + request.GetUrl().AppendQueryParameter("comp", "properties"); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.FilePermission.HasValue() && !options.FilePermission.Value().empty()) + { + request.SetHeader("x-ms-file-permission", options.FilePermission.Value()); + } + if (options.FilePermissionKey.HasValue() && !options.FilePermissionKey.Value().empty()) + { + request.SetHeader("x-ms-file-permission-key", options.FilePermissionKey.Value()); + } + if (!options.FileAttributes.empty()) + { + request.SetHeader("x-ms-file-attributes", options.FileAttributes); + } + if (!options.FileCreationTime.empty()) + { + request.SetHeader("x-ms-file-creation-time", options.FileCreationTime); + } + if (!options.FileLastWriteTime.empty()) + { + request.SetHeader("x-ms-file-last-write-time", options.FileLastWriteTime); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetDirectoryPropertiesResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + if (pRawResponse->GetHeaders().count("x-ms-file-permission-key") != 0) + { + response.SmbProperties.PermissionKey + = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + } + response.SmbProperties.Attributes + = Models::FileAttributes(pRawResponse->GetHeaders().at("x-ms-file-attributes")); + if (pRawResponse->GetHeaders().count("x-ms-file-creation-time") != 0) + { + response.SmbProperties.CreatedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-creation-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-last-write-time") != 0) + { + response.SmbProperties.LastWrittenOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-last-write-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-change-time") != 0) + { + response.SmbProperties.ChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-change-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + response.SmbProperties.FileId = pRawResponse->GetHeaders().at("x-ms-file-id"); + response.SmbProperties.ParentFileId = pRawResponse->GetHeaders().at("x-ms-file-parent-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response DirectoryClient::SetMetadata( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetDirectoryMetadataOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("restype", "directory"); + request.GetUrl().AppendQueryParameter("comp", "metadata"); + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetDirectoryMetadataResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response + DirectoryClient::ListFilesAndDirectoriesSegment( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListDirectoryFilesAndDirectoriesSegmentOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("restype", "directory"); + request.GetUrl().AppendQueryParameter("comp", "list"); + if (options.Prefix.HasValue() && !options.Prefix.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "prefix", _internal::UrlEncodeQueryParameter(options.Prefix.Value())); + } + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + if (options.Marker.HasValue() && !options.Marker.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "marker", _internal::UrlEncodeQueryParameter(options.Marker.Value())); + } + if (options.MaxResults.HasValue()) + { + request.GetUrl().AppendQueryParameter( + "maxresults", std::to_string(options.MaxResults.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ListFilesAndDirectoriesSegmentResponse response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kEnumerationResults, + kPrefix, + kMarker, + kMaxResults, + kEntries, + kDirectory, + kName, + kFile, + kProperties, + kContentLength, + kNextMarker, + }; + const std::unordered_map XmlTagEnumMap{ + {"EnumerationResults", XmlTagEnum::kEnumerationResults}, + {"Prefix", XmlTagEnum::kPrefix}, + {"Marker", XmlTagEnum::kMarker}, + {"MaxResults", XmlTagEnum::kMaxResults}, + {"Entries", XmlTagEnum::kEntries}, + {"Directory", XmlTagEnum::kDirectory}, + {"Name", XmlTagEnum::kName}, + {"File", XmlTagEnum::kFile}, + {"Properties", XmlTagEnum::kProperties}, + {"Content-Length", XmlTagEnum::kContentLength}, + {"NextMarker", XmlTagEnum::kNextMarker}, + }; + std::vector xmlPath; + Models::DirectoryItem vectorElement1; + Models::FileItem vectorElement2; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kPrefix) + { + response.Prefix = node.Value; + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kMarker) + { + response.Marker = node.Value; + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kMaxResults) + { + response.MaxResults = std::stoi(node.Value); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kEntries && xmlPath[2] == XmlTagEnum::kDirectory + && xmlPath[3] == XmlTagEnum::kName) + { + vectorElement1.Name = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kEntries && xmlPath[2] == XmlTagEnum::kFile + && xmlPath[3] == XmlTagEnum::kName) + { + vectorElement2.Name = node.Value; + } + else if ( + xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kEntries && xmlPath[2] == XmlTagEnum::kFile + && xmlPath[3] == XmlTagEnum::kProperties + && xmlPath[4] == XmlTagEnum::kContentLength) + { + vectorElement2.Details.FileSize = std::stoll(node.Value); + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kNextMarker) + { + response.NextMarker = node.Value; + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + if (xmlPath.size() == 1 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && node.Name == "ServiceEndpoint") + { + response.ServiceEndpoint = node.Value; + } + else if ( + xmlPath.size() == 1 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && node.Name == "ShareName") + { + response.ShareName = node.Value; + } + else if ( + xmlPath.size() == 1 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && node.Name == "ShareSnapshot") + { + response.ShareSnapshot = node.Value; + } + else if ( + xmlPath.size() == 1 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && node.Name == "DirectoryPath") + { + response.DirectoryPath = node.Value; + } + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kEntries && xmlPath[2] == XmlTagEnum::kDirectory) + { + response.Segment.DirectoryItems.push_back(std::move(vectorElement1)); + vectorElement1 = Models::DirectoryItem(); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kEntries && xmlPath[2] == XmlTagEnum::kFile) + { + response.Segment.FileItems.push_back(std::move(vectorElement2)); + vectorElement2 = Models::FileItem(); + } + xmlPath.pop_back(); + } + } + } + return Response( + std::move(response), std::move(pRawResponse)); + } + Response DirectoryClient::ListHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListDirectoryHandlesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("comp", "listhandles"); + if (options.Marker.HasValue() && !options.Marker.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "marker", _internal::UrlEncodeQueryParameter(options.Marker.Value())); + } + if (options.MaxResults.HasValue()) + { + request.GetUrl().AppendQueryParameter( + "maxresults", std::to_string(options.MaxResults.Value())); + } + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + if (options.Recursive.HasValue()) + { + request.SetHeader("x-ms-recursive", options.Recursive.Value() ? "true" : "false"); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ListHandlesResponse response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kEnumerationResults, + kHandleList, + kHandle, + kHandleId, + kPath, + kFileId, + kParentId, + kSessionId, + kClientIp, + kOpenTime, + kLastReconnectTime, + kNextMarker, + }; + const std::unordered_map XmlTagEnumMap{ + {"EnumerationResults", XmlTagEnum::kEnumerationResults}, + {"HandleList", XmlTagEnum::kHandleList}, + {"Handle", XmlTagEnum::kHandle}, + {"HandleId", XmlTagEnum::kHandleId}, + {"Path", XmlTagEnum::kPath}, + {"FileId", XmlTagEnum::kFileId}, + {"ParentId", XmlTagEnum::kParentId}, + {"SessionId", XmlTagEnum::kSessionId}, + {"ClientIp", XmlTagEnum::kClientIp}, + {"OpenTime", XmlTagEnum::kOpenTime}, + {"LastReconnectTime", XmlTagEnum::kLastReconnectTime}, + {"NextMarker", XmlTagEnum::kNextMarker}, + }; + std::vector xmlPath; + Models::HandleItem vectorElement1; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kHandleId) + { + vectorElement1.HandleId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kPath) + { + vectorElement1.Path = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kFileId) + { + vectorElement1.FileId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kParentId) + { + vectorElement1.ParentId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kSessionId) + { + vectorElement1.SessionId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kClientIp) + { + vectorElement1.ClientIp = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kOpenTime) + { + vectorElement1.OpenedOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kLastReconnectTime) + { + vectorElement1.LastReconnectedOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kNextMarker) + { + response.NextMarker = node.Value; + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle) + { + response.HandleList.push_back(std::move(vectorElement1)); + vectorElement1 = Models::HandleItem(); + } + xmlPath.pop_back(); + } + } + } + return Response( + std::move(response), std::move(pRawResponse)); + } + Response DirectoryClient::ForceCloseHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ForceDirectoryCloseHandlesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "forceclosehandles"); + if (options.Marker.HasValue() && !options.Marker.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "marker", _internal::UrlEncodeQueryParameter(options.Marker.Value())); + } + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + if (!options.HandleId.empty()) + { + request.SetHeader("x-ms-handle-id", options.HandleId); + } + if (options.Recursive.HasValue()) + { + request.SetHeader("x-ms-recursive", options.Recursive.Value() ? "true" : "false"); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ForceCloseDirectoryHandlesResult response; + if (pRawResponse->GetHeaders().count("x-ms-marker") != 0) + { + response.ContinuationToken = pRawResponse->GetHeaders().at("x-ms-marker"); + } + response.NumberOfHandlesClosed + = std::stoi(pRawResponse->GetHeaders().at("x-ms-number-of-handles-closed")); + response.NumberOfHandlesFailedToClose + = std::stoi(pRawResponse->GetHeaders().at("x-ms-number-of-handles-failed")); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::Create( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const CreateFileOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.SetHeader("x-ms-version", "2020-02-10"); + request.SetHeader("x-ms-content-length", std::to_string(options.FileContentLength)); + request.SetHeader("x-ms-type", "file"); + if (options.FileContentType.HasValue() && !options.FileContentType.Value().empty()) + { + request.SetHeader("x-ms-content-type", options.FileContentType.Value()); + } + if (options.FileContentEncoding.HasValue() && !options.FileContentEncoding.Value().empty()) + { + request.SetHeader("x-ms-content-encoding", options.FileContentEncoding.Value()); + } + if (options.FileContentLanguage.HasValue() && !options.FileContentLanguage.Value().empty()) + { + request.SetHeader("x-ms-content-language", options.FileContentLanguage.Value()); + } + if (options.FileCacheControl.HasValue() && !options.FileCacheControl.Value().empty()) + { + request.SetHeader("x-ms-cache-control", options.FileCacheControl.Value()); + } + if (options.FileContentMD5.HasValue() + && !Core::Convert::Base64Encode(options.FileContentMD5.Value()).empty()) + { + request.SetHeader( + "x-ms-content-md5", Core::Convert::Base64Encode(options.FileContentMD5.Value())); + } + if (options.FileContentDisposition.HasValue() + && !options.FileContentDisposition.Value().empty()) + { + request.SetHeader("x-ms-content-disposition", options.FileContentDisposition.Value()); + } + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + if (options.FilePermission.HasValue() && !options.FilePermission.Value().empty()) + { + request.SetHeader("x-ms-file-permission", options.FilePermission.Value()); + } + if (options.FilePermissionKey.HasValue() && !options.FilePermissionKey.Value().empty()) + { + request.SetHeader("x-ms-file-permission-key", options.FilePermissionKey.Value()); + } + if (!options.FileAttributes.empty()) + { + request.SetHeader("x-ms-file-attributes", options.FileAttributes); + } + if (!options.FileCreationTime.empty()) + { + request.SetHeader("x-ms-file-creation-time", options.FileCreationTime); + } + if (!options.FileLastWriteTime.empty()) + { + request.SetHeader("x-ms-file-last-write-time", options.FileLastWriteTime); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::CreateFileResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + if (pRawResponse->GetHeaders().count("x-ms-file-permission-key") != 0) + { + response.SmbProperties.PermissionKey + = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + } + response.SmbProperties.Attributes + = Models::FileAttributes(pRawResponse->GetHeaders().at("x-ms-file-attributes")); + if (pRawResponse->GetHeaders().count("x-ms-file-creation-time") != 0) + { + response.SmbProperties.CreatedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-creation-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-last-write-time") != 0) + { + response.SmbProperties.LastWrittenOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-last-write-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-change-time") != 0) + { + response.SmbProperties.ChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-change-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + response.SmbProperties.FileId = pRawResponse->GetHeaders().at("x-ms-file-id"); + response.SmbProperties.ParentFileId = pRawResponse->GetHeaders().at("x-ms-file-parent-id"); + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::Download( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DownloadFileOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url, false); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Range.HasValue() && !options.Range.Value().empty()) + { + request.SetHeader("x-ms-range", options.Range.Value()); + } + if (options.RangeGetContentMD5.HasValue()) + { + request.SetHeader( + "x-ms-range-get-content-md5", options.RangeGetContentMD5.Value() ? "true" : "false"); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (!(httpStatusCode == Core::Http::HttpStatusCode::Ok + || httpStatusCode == Core::Http::HttpStatusCode::PartialContent)) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::DownloadFileResult response; + response.BodyStream = pRawResponse->ExtractBodyStream(); + response.Details.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + for (auto i = pRawResponse->GetHeaders().lower_bound("x-ms-meta-"); + i != pRawResponse->GetHeaders().end() && i->first.substr(0, 10) == "x-ms-meta-"; + ++i) + { + response.Details.Metadata.emplace(i->first.substr(10), i->second); + } + if (pRawResponse->GetHeaders().count("Content-Type") != 0) + { + response.HttpHeaders.ContentType = pRawResponse->GetHeaders().at("Content-Type"); + } + response.Details.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + if (httpStatusCode == Core::Http::HttpStatusCode::Ok) + { + if (pRawResponse->GetHeaders().count("Content-MD5") != 0) + { + response.HttpHeaders.ContentHash.Value + = Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("Content-MD5")); + response.HttpHeaders.ContentHash.Algorithm = HashAlgorithm::Md5; + } + } + if (httpStatusCode == Core::Http::HttpStatusCode::Ok) + { + if (pRawResponse->GetHeaders().count("Content-MD5") != 0) + { + response.TransactionalContentHash = ContentHash(); + response.TransactionalContentHash.Value().Value + = Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("Content-MD5")); + response.TransactionalContentHash.Value().Algorithm = HashAlgorithm::Md5; + } + } + if (pRawResponse->GetHeaders().count("Content-Encoding") != 0) + { + response.HttpHeaders.ContentEncoding = pRawResponse->GetHeaders().at("Content-Encoding"); + } + if (pRawResponse->GetHeaders().count("Cache-Control") != 0) + { + response.HttpHeaders.CacheControl = pRawResponse->GetHeaders().at("Cache-Control"); + } + if (pRawResponse->GetHeaders().count("Content-Disposition") != 0) + { + response.HttpHeaders.ContentDisposition + = pRawResponse->GetHeaders().at("Content-Disposition"); + } + if (pRawResponse->GetHeaders().count("Content-Language") != 0) + { + response.HttpHeaders.ContentLanguage = pRawResponse->GetHeaders().at("Content-Language"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-completion-time") != 0) + { + response.Details.CopyCompletedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-copy-completion-time"), + Azure::DateTime::DateFormat::Rfc1123); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-status-description") != 0) + { + response.Details.CopyStatusDescription + = pRawResponse->GetHeaders().at("x-ms-copy-status-description"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-id") != 0) + { + response.Details.CopyId = pRawResponse->GetHeaders().at("x-ms-copy-id"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-progress") != 0) + { + response.Details.CopyProgress = pRawResponse->GetHeaders().at("x-ms-copy-progress"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-source") != 0) + { + response.Details.CopySource = pRawResponse->GetHeaders().at("x-ms-copy-source"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-status") != 0) + { + response.Details.CopyStatus + = Models::CopyStatus(pRawResponse->GetHeaders().at("x-ms-copy-status")); + } + if (pRawResponse->GetHeaders().count("x-ms-content-md5") != 0) + { + response.HttpHeaders.ContentHash.Value + = Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("x-ms-content-md5")); + response.HttpHeaders.ContentHash.Algorithm = HashAlgorithm::Md5; + } + response.Details.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-server-encrypted") == std::string("true"); + response.Details.SmbProperties.Attributes + = Models::FileAttributes(pRawResponse->GetHeaders().at("x-ms-file-attributes")); + if (pRawResponse->GetHeaders().count("x-ms-file-creation-time") != 0) + { + response.Details.SmbProperties.CreatedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-creation-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-last-write-time") != 0) + { + response.Details.SmbProperties.LastWrittenOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-last-write-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-change-time") != 0) + { + response.Details.SmbProperties.ChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-change-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-permission-key") != 0) + { + response.Details.SmbProperties.PermissionKey + = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + } + response.Details.SmbProperties.FileId = pRawResponse->GetHeaders().at("x-ms-file-id"); + response.Details.SmbProperties.ParentFileId + = pRawResponse->GetHeaders().at("x-ms-file-parent-id"); + if (pRawResponse->GetHeaders().count("x-ms-lease-duration") != 0) + { + response.Details.LeaseDuration + = Models::LeaseDurationType(pRawResponse->GetHeaders().at("x-ms-lease-duration")); + } + if (pRawResponse->GetHeaders().count("x-ms-lease-state") != 0) + { + response.Details.LeaseState + = Models::LeaseState(pRawResponse->GetHeaders().at("x-ms-lease-state")); + } + if (pRawResponse->GetHeaders().count("x-ms-lease-status") != 0) + { + response.Details.LeaseStatus + = Models::LeaseStatus(pRawResponse->GetHeaders().at("x-ms-lease-status")); + } + if (httpStatusCode == Core::Http::HttpStatusCode::PartialContent) + { + if (pRawResponse->GetHeaders().count("Content-MD5") != 0) + { + response.TransactionalContentHash = ContentHash(); + response.TransactionalContentHash.Value().Value + = Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("Content-MD5")); + response.TransactionalContentHash.Value().Algorithm = HashAlgorithm::Md5; + } + } + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::GetProperties( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetFilePropertiesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Head, url); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::FileProperties response; + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + for (auto i = pRawResponse->GetHeaders().lower_bound("x-ms-meta-"); + i != pRawResponse->GetHeaders().end() && i->first.substr(0, 10) == "x-ms-meta-"; + ++i) + { + response.Metadata.emplace(i->first.substr(10), i->second); + } + response.FileSize = std::stoll(pRawResponse->GetHeaders().at("Content-Length")); + if (pRawResponse->GetHeaders().count("Content-Type") != 0) + { + response.HttpHeaders.ContentType = pRawResponse->GetHeaders().at("Content-Type"); + } + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + if (pRawResponse->GetHeaders().count("Content-MD5") != 0) + { + response.HttpHeaders.ContentHash.Value + = Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("Content-MD5")); + response.HttpHeaders.ContentHash.Algorithm = HashAlgorithm::Md5; + } + if (pRawResponse->GetHeaders().count("Content-Encoding") != 0) + { + response.HttpHeaders.ContentEncoding = pRawResponse->GetHeaders().at("Content-Encoding"); + } + if (pRawResponse->GetHeaders().count("Cache-Control") != 0) + { + response.HttpHeaders.CacheControl = pRawResponse->GetHeaders().at("Cache-Control"); + } + if (pRawResponse->GetHeaders().count("Content-Disposition") != 0) + { + response.HttpHeaders.ContentDisposition + = pRawResponse->GetHeaders().at("Content-Disposition"); + } + if (pRawResponse->GetHeaders().count("Content-Language") != 0) + { + response.HttpHeaders.ContentLanguage = pRawResponse->GetHeaders().at("Content-Language"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-completion-time") != 0) + { + response.CopyCompletedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-copy-completion-time"), + Azure::DateTime::DateFormat::Rfc1123); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-status-description") != 0) + { + response.CopyStatusDescription + = pRawResponse->GetHeaders().at("x-ms-copy-status-description"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-id") != 0) + { + response.CopyId = pRawResponse->GetHeaders().at("x-ms-copy-id"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-progress") != 0) + { + response.CopyProgress = pRawResponse->GetHeaders().at("x-ms-copy-progress"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-source") != 0) + { + response.CopySource = pRawResponse->GetHeaders().at("x-ms-copy-source"); + } + if (pRawResponse->GetHeaders().count("x-ms-copy-status") != 0) + { + response.CopyStatus = Models::CopyStatus(pRawResponse->GetHeaders().at("x-ms-copy-status")); + } + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-server-encrypted") == std::string("true"); + response.SmbProperties.Attributes + = Models::FileAttributes(pRawResponse->GetHeaders().at("x-ms-file-attributes")); + if (pRawResponse->GetHeaders().count("x-ms-file-creation-time") != 0) + { + response.SmbProperties.CreatedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-creation-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-last-write-time") != 0) + { + response.SmbProperties.LastWrittenOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-last-write-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-change-time") != 0) + { + response.SmbProperties.ChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-change-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-permission-key") != 0) + { + response.SmbProperties.PermissionKey + = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + } + response.SmbProperties.FileId = pRawResponse->GetHeaders().at("x-ms-file-id"); + response.SmbProperties.ParentFileId = pRawResponse->GetHeaders().at("x-ms-file-parent-id"); + if (pRawResponse->GetHeaders().count("x-ms-lease-duration") != 0) + { + response.LeaseDuration + = Models::LeaseDurationType(pRawResponse->GetHeaders().at("x-ms-lease-duration")); + } + if (pRawResponse->GetHeaders().count("x-ms-lease-state") != 0) + { + response.LeaseState = Models::LeaseState(pRawResponse->GetHeaders().at("x-ms-lease-state")); + } + if (pRawResponse->GetHeaders().count("x-ms-lease-status") != 0) + { + response.LeaseStatus + = Models::LeaseStatus(pRawResponse->GetHeaders().at("x-ms-lease-status")); + } + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::Delete( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const DeleteFileOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Delete, url); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::DeleteFileResult response; + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::SetHttpHeaders( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetFileHttpHeadersOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "properties"); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.FileContentLength.HasValue()) + { + request.SetHeader("x-ms-content-length", std::to_string(options.FileContentLength.Value())); + } + if (options.FileContentType.HasValue() && !options.FileContentType.Value().empty()) + { + request.SetHeader("x-ms-content-type", options.FileContentType.Value()); + } + if (options.FileContentEncoding.HasValue() && !options.FileContentEncoding.Value().empty()) + { + request.SetHeader("x-ms-content-encoding", options.FileContentEncoding.Value()); + } + if (options.FileContentLanguage.HasValue() && !options.FileContentLanguage.Value().empty()) + { + request.SetHeader("x-ms-content-language", options.FileContentLanguage.Value()); + } + if (options.FileCacheControl.HasValue() && !options.FileCacheControl.Value().empty()) + { + request.SetHeader("x-ms-cache-control", options.FileCacheControl.Value()); + } + if (options.FileContentMD5.HasValue() + && !Core::Convert::Base64Encode(options.FileContentMD5.Value()).empty()) + { + request.SetHeader( + "x-ms-content-md5", Core::Convert::Base64Encode(options.FileContentMD5.Value())); + } + if (options.FileContentDisposition.HasValue() + && !options.FileContentDisposition.Value().empty()) + { + request.SetHeader("x-ms-content-disposition", options.FileContentDisposition.Value()); + } + if (options.FilePermission.HasValue() && !options.FilePermission.Value().empty()) + { + request.SetHeader("x-ms-file-permission", options.FilePermission.Value()); + } + if (options.FilePermissionKey.HasValue() && !options.FilePermissionKey.Value().empty()) + { + request.SetHeader("x-ms-file-permission-key", options.FilePermissionKey.Value()); + } + if (!options.FileAttributes.empty()) + { + request.SetHeader("x-ms-file-attributes", options.FileAttributes); + } + if (!options.FileCreationTime.empty()) + { + request.SetHeader("x-ms-file-creation-time", options.FileCreationTime); + } + if (!options.FileLastWriteTime.empty()) + { + request.SetHeader("x-ms-file-last-write-time", options.FileLastWriteTime); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetFilePropertiesResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + if (pRawResponse->GetHeaders().count("x-ms-file-permission-key") != 0) + { + response.SmbProperties.PermissionKey + = pRawResponse->GetHeaders().at("x-ms-file-permission-key"); + } + response.SmbProperties.Attributes + = Models::FileAttributes(pRawResponse->GetHeaders().at("x-ms-file-attributes")); + if (pRawResponse->GetHeaders().count("x-ms-file-creation-time") != 0) + { + response.SmbProperties.CreatedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-creation-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-last-write-time") != 0) + { + response.SmbProperties.LastWrittenOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-last-write-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + if (pRawResponse->GetHeaders().count("x-ms-file-change-time") != 0) + { + response.SmbProperties.ChangedOn = DateTime::Parse( + pRawResponse->GetHeaders().at("x-ms-file-change-time"), + Azure::DateTime::DateFormat::Rfc3339); + } + response.SmbProperties.FileId = pRawResponse->GetHeaders().at("x-ms-file-id"); + response.SmbProperties.ParentFileId = pRawResponse->GetHeaders().at("x-ms-file-parent-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::SetMetadata( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const SetFileMetadataOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "metadata"); + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::SetFileMetadataResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::AcquireLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const AcquireFileLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "acquire"); + if (options.Duration.HasValue()) + { + request.SetHeader("x-ms-lease-duration", std::to_string(options.Duration.Value())); + } + if (options.ProposedLeaseId.HasValue() && !options.ProposedLeaseId.Value().empty()) + { + request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::AcquireFileLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.LeaseId = pRawResponse->GetHeaders().at("x-ms-lease-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::ReleaseLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ReleaseFileLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "release"); + if (!options.LeaseId.empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ReleaseFileLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::ChangeLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ChangeFileLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "change"); + if (!options.LeaseId.empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId); + } + if (options.ProposedLeaseId.HasValue() && !options.ProposedLeaseId.Value().empty()) + { + request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ChangeFileLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.LeaseId = pRawResponse->GetHeaders().at("x-ms-lease-id"); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::BreakLease( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const BreakFileLeaseOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "lease"); + request.SetHeader("x-ms-lease-action", "break"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::BreakFileLeaseResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::UploadRange( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + Core::IO::BodyStream& requestBody, + const UploadFileRangeOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url, &requestBody); + request.GetUrl().AppendQueryParameter("comp", "range"); + if (!options.Range.empty()) + { + request.SetHeader("x-ms-range", options.Range); + } + if (!options.FileRangeWrite.empty()) + { + request.SetHeader("x-ms-write", options.FileRangeWrite); + } + request.SetHeader("Content-Length", std::to_string(requestBody.Length())); + if (options.ContentMD5.HasValue() + && !Core::Convert::Base64Encode(options.ContentMD5.Value()).empty()) + { + request.SetHeader("Content-MD5", Core::Convert::Base64Encode(options.ContentMD5.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::UploadFileRangeResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + if (pRawResponse->GetHeaders().count("Content-MD5") != 0) + { + response.TransactionalContentHash.Value + = Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("Content-MD5")); + response.TransactionalContentHash.Algorithm = HashAlgorithm::Md5; + } + if (pRawResponse->GetHeaders().count("x-ms-request-server-encrypted") != 0) + { + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + } + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::UploadRangeFromUri( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const UploadFileRangeFromUriOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "range"); + if (!options.Range.empty()) + { + request.SetHeader("x-ms-range", options.Range); + } + if (!options.CopySource.empty()) + { + request.SetHeader("x-ms-copy-source", options.CopySource); + } + if (options.SourceRange.HasValue() && !options.SourceRange.Value().empty()) + { + request.SetHeader("x-ms-source-range", options.SourceRange.Value()); + } + request.SetHeader("x-ms-write", "update"); + request.SetHeader("Content-Length", "0"); + if (options.SourceContentCrc64.HasValue() + && !Core::Convert::Base64Encode(options.SourceContentCrc64.Value()).empty()) + { + request.SetHeader( + "x-ms-source-content-crc64", + Core::Convert::Base64Encode(options.SourceContentCrc64.Value())); + } + if (options.SourceIfMatchCrc64.HasValue() + && !Core::Convert::Base64Encode(options.SourceIfMatchCrc64.Value()).empty()) + { + request.SetHeader( + "x-ms-source-if-match-crc64", + Core::Convert::Base64Encode(options.SourceIfMatchCrc64.Value())); + } + if (options.SourceIfNoneMatchCrc64.HasValue() + && !Core::Convert::Base64Encode(options.SourceIfNoneMatchCrc64.Value()).empty()) + { + request.SetHeader( + "x-ms-source-if-none-match-crc64", + Core::Convert::Base64Encode(options.SourceIfNoneMatchCrc64.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Created) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::UploadFileRangeFromUriResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + if (pRawResponse->GetHeaders().count("x-ms-content-crc64") != 0) + { + response.TransactionalContentHash.Value + = Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("x-ms-content-crc64")); + response.TransactionalContentHash.Algorithm = HashAlgorithm::Crc64; + } + if (pRawResponse->GetHeaders().count("x-ms-request-server-encrypted") != 0) + { + response.IsServerEncrypted + = pRawResponse->GetHeaders().at("x-ms-request-server-encrypted") == std::string("true"); + } + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::GetRangeList( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const GetFileRangeListOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("comp", "rangelist"); + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + if (options.Prevsharesnapshot.HasValue() && !options.Prevsharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "prevsharesnapshot", + _internal::UrlEncodeQueryParameter(options.Prevsharesnapshot.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.Range.HasValue() && !options.Range.Value().empty()) + { + request.SetHeader("x-ms-range", options.Range.Value()); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::GetFileRangeListResult response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kRanges, + kRange, + kStart, + kEnd, + kClearRange, + }; + const std::unordered_map XmlTagEnumMap{ + {"Ranges", XmlTagEnum::kRanges}, + {"Range", XmlTagEnum::kRange}, + {"Start", XmlTagEnum::kStart}, + {"End", XmlTagEnum::kEnd}, + {"ClearRange", XmlTagEnum::kClearRange}, + }; + std::vector xmlPath; + Core::Http::HttpRange vectorElement1; + Core::Http::HttpRange vectorElement2; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kRanges + && xmlPath[1] == XmlTagEnum::kRange && xmlPath[2] == XmlTagEnum::kStart) + { + vectorElement1.Offset = std::stoll(node.Value); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kRanges + && xmlPath[1] == XmlTagEnum::kRange && xmlPath[2] == XmlTagEnum::kEnd) + { + vectorElement1.Length = std::stoll(node.Value); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kRanges + && xmlPath[1] == XmlTagEnum::kClearRange && xmlPath[2] == XmlTagEnum::kStart) + { + vectorElement2.Offset = std::stoll(node.Value); + } + else if ( + xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kRanges + && xmlPath[1] == XmlTagEnum::kClearRange && xmlPath[2] == XmlTagEnum::kEnd) + { + vectorElement2.Length = std::stoll(node.Value); + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kRanges + && xmlPath[1] == XmlTagEnum::kRange) + { + vectorElement1.Length = vectorElement1.Length.Value() - vectorElement1.Offset + 1; + response.Ranges.push_back(std::move(vectorElement1)); + vectorElement1 = Core::Http::HttpRange(); + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kRanges + && xmlPath[1] == XmlTagEnum::kClearRange) + { + vectorElement2.Length = vectorElement2.Length.Value() - vectorElement2.Offset + 1; + response.ClearRanges.push_back(std::move(vectorElement2)); + vectorElement2 = Core::Http::HttpRange(); + } + xmlPath.pop_back(); + } + } + } + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.FileSize = std::stoll(pRawResponse->GetHeaders().at("x-ms-content-length")); + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::StartCopy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const StartFileCopyOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.SetHeader("x-ms-version", "2020-02-10"); + for (const auto& p : options.Metadata) + { + request.SetHeader("x-ms-meta-" + p.first, p.second); + } + if (!options.CopySource.empty()) + { + request.SetHeader("x-ms-copy-source", options.CopySource); + } + if (options.FilePermission.HasValue() && !options.FilePermission.Value().empty()) + { + request.SetHeader("x-ms-file-permission", options.FilePermission.Value()); + } + if (options.FilePermissionKey.HasValue() && !options.FilePermissionKey.Value().empty()) + { + request.SetHeader("x-ms-file-permission-key", options.FilePermissionKey.Value()); + } + if (options.FilePermissionCopyMode.HasValue() + && !options.FilePermissionCopyMode.Value().ToString().empty()) + { + request.SetHeader( + "x-ms-file-permission-copy-mode", options.FilePermissionCopyMode.Value().ToString()); + } + if (options.IgnoreReadOnly.HasValue()) + { + request.SetHeader( + "x-ms-file-copy-ignore-read-only", options.IgnoreReadOnly.Value() ? "true" : "false"); + } + if (options.FileAttributes.HasValue() && !options.FileAttributes.Value().empty()) + { + request.SetHeader("x-ms-file-attributes", options.FileAttributes.Value()); + } + if (options.FileCreationTime.HasValue() && !options.FileCreationTime.Value().empty()) + { + request.SetHeader("x-ms-file-creation-time", options.FileCreationTime.Value()); + } + if (options.FileLastWriteTime.HasValue() && !options.FileLastWriteTime.Value().empty()) + { + request.SetHeader("x-ms-file-last-write-time", options.FileLastWriteTime.Value()); + } + if (options.SetArchiveAttribute.HasValue()) + { + request.SetHeader( + "x-ms-file-copy-set-archive", options.SetArchiveAttribute.Value() ? "true" : "false"); + } + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::StartFileCopyResult response; + response.ETag = ETag(pRawResponse->GetHeaders().at("ETag")); + response.LastModified = DateTime::Parse( + pRawResponse->GetHeaders().at("Last-Modified"), Azure::DateTime::DateFormat::Rfc1123); + response.CopyId = pRawResponse->GetHeaders().at("x-ms-copy-id"); + response.CopyStatus = Models::CopyStatus(pRawResponse->GetHeaders().at("x-ms-copy-status")); + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::AbortCopy( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const AbortFileCopyOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "copy"); + if (!options.CopyId.empty()) + { + request.GetUrl().AppendQueryParameter( + "copyid", _internal::UrlEncodeQueryParameter(options.CopyId)); + } + request.SetHeader("x-ms-copy-action", "abort"); + request.SetHeader("x-ms-version", "2020-02-10"); + if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) + { + request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); + } + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::NoContent) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::AbortFileCopyResult response; + return Response(std::move(response), std::move(pRawResponse)); + } + Response FileClient::ListHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ListFileHandlesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); + request.GetUrl().AppendQueryParameter("comp", "listhandles"); + if (options.Marker.HasValue() && !options.Marker.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "marker", _internal::UrlEncodeQueryParameter(options.Marker.Value())); + } + if (options.MaxResults.HasValue()) + { + request.GetUrl().AppendQueryParameter( + "maxresults", std::to_string(options.MaxResults.Value())); + } + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ListHandlesResponse response; + { + const auto& responseBody = pRawResponse->GetBody(); + _internal::XmlReader reader( + reinterpret_cast(responseBody.data()), responseBody.size()); + enum class XmlTagEnum + { + kUnknown, + kEnumerationResults, + kHandleList, + kHandle, + kHandleId, + kPath, + kFileId, + kParentId, + kSessionId, + kClientIp, + kOpenTime, + kLastReconnectTime, + kNextMarker, + }; + const std::unordered_map XmlTagEnumMap{ + {"EnumerationResults", XmlTagEnum::kEnumerationResults}, + {"HandleList", XmlTagEnum::kHandleList}, + {"Handle", XmlTagEnum::kHandle}, + {"HandleId", XmlTagEnum::kHandleId}, + {"Path", XmlTagEnum::kPath}, + {"FileId", XmlTagEnum::kFileId}, + {"ParentId", XmlTagEnum::kParentId}, + {"SessionId", XmlTagEnum::kSessionId}, + {"ClientIp", XmlTagEnum::kClientIp}, + {"OpenTime", XmlTagEnum::kOpenTime}, + {"LastReconnectTime", XmlTagEnum::kLastReconnectTime}, + {"NextMarker", XmlTagEnum::kNextMarker}, + }; + std::vector xmlPath; + Models::HandleItem vectorElement1; + while (true) + { + auto node = reader.Read(); + if (node.Type == _internal::XmlNodeType::End) + { + break; + } + else if (node.Type == _internal::XmlNodeType::StartTag) + { + auto ite = XmlTagEnumMap.find(node.Name); + xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); + } + else if (node.Type == _internal::XmlNodeType::Text) + { + if (xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kHandleId) + { + vectorElement1.HandleId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kPath) + { + vectorElement1.Path = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kFileId) + { + vectorElement1.FileId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kParentId) + { + vectorElement1.ParentId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kSessionId) + { + vectorElement1.SessionId = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kClientIp) + { + vectorElement1.ClientIp = node.Value; + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kOpenTime) + { + vectorElement1.OpenedOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle + && xmlPath[3] == XmlTagEnum::kLastReconnectTime) + { + vectorElement1.LastReconnectedOn + = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); + } + else if ( + xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kNextMarker) + { + response.NextMarker = node.Value; + } + } + else if (node.Type == _internal::XmlNodeType::Attribute) + { + } + else if (node.Type == _internal::XmlNodeType::EndTag) + { + if (xmlPath.size() == 3 && xmlPath[0] == XmlTagEnum::kEnumerationResults + && xmlPath[1] == XmlTagEnum::kHandleList && xmlPath[2] == XmlTagEnum::kHandle) + { + response.HandleList.push_back(std::move(vectorElement1)); + vectorElement1 = Models::HandleItem(); + } + xmlPath.pop_back(); + } + } + } + return Response( + std::move(response), std::move(pRawResponse)); + } + Response FileClient::ForceCloseHandles( + Core::Http::_internal::HttpPipeline& pipeline, + const Core::Url& url, + const ForceFileCloseHandlesOptions& options, + const Core::Context& context) + { + auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); + request.GetUrl().AppendQueryParameter("comp", "forceclosehandles"); + if (options.Marker.HasValue() && !options.Marker.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "marker", _internal::UrlEncodeQueryParameter(options.Marker.Value())); + } + if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) + { + request.GetUrl().AppendQueryParameter( + "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); + } + if (!options.HandleId.empty()) + { + request.SetHeader("x-ms-handle-id", options.HandleId); + } + request.SetHeader("x-ms-version", "2020-02-10"); + auto pRawResponse = pipeline.Send(request, context); + auto httpStatusCode = pRawResponse->GetStatusCode(); + if (httpStatusCode != Core::Http::HttpStatusCode::Ok) + { + throw StorageException::CreateFromResponse(std::move(pRawResponse)); + } + Models::_detail::ForceFileCloseHandlesResult response; + if (pRawResponse->GetHeaders().count("x-ms-marker") != 0) + { + response.ContinuationToken = pRawResponse->GetHeaders().at("x-ms-marker"); + } + response.NumberOfHandlesClosed + = std::stoi(pRawResponse->GetHeaders().at("x-ms-number-of-handles-closed")); + response.NumberOfHandlesFailedToClose + = std::stoi(pRawResponse->GetHeaders().at("x-ms-number-of-handles-failed")); + return Response( + std::move(response), std::move(pRawResponse)); + } + } // namespace _detail +}}}} // namespace Azure::Storage::Files::Shares \ No newline at end of file diff --git a/sdk/storage/azure-storage-files-shares/src/share_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_client.cpp index 63594d5cc..4fd5fa301 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_client.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "azure/storage/files/shares/share_directory_client.hpp" #include "azure/storage/files/shares/share_file_client.hpp" @@ -101,12 +102,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const CreateShareOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Share::CreateOptions(); - protocolLayerOptions.Metadata = options.Metadata; - protocolLayerOptions.ShareQuota = options.ShareQuotaInGiB; - protocolLayerOptions.XMsAccessTier = options.AccessTier; - auto result = _detail::ShareRestClient::Share::Create( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::CreateShareOptions(); + protocolLayerOptions.Metadata + = std::map(options.Metadata.begin(), options.Metadata.end()); + protocolLayerOptions.Quota = options.ShareQuotaInGiB; + protocolLayerOptions.AccessTier = options.AccessTier; + auto result + = _detail::ShareClient::Create(*m_pipeline, m_shareUrl, protocolLayerOptions, context); Models::CreateShareResult ret; ret.Created = true; ret.ETag = std::move(result.Value.ETag); @@ -139,13 +141,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const DeleteShareOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Share::DeleteOptions(); + auto protocolLayerOptions = _detail::ShareClient::DeleteShareOptions(); if (options.DeleteSnapshots.HasValue() && options.DeleteSnapshots.Value()) { - protocolLayerOptions.XMsDeleteSnapshots = Models::DeleteSnapshotsOption::Include; + protocolLayerOptions.DeleteSnapshots = Models::DeleteSnapshotsOption::Include; } - auto result = _detail::ShareRestClient::Share::Delete( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto result + = _detail::ShareClient::Delete(*m_pipeline, m_shareUrl, protocolLayerOptions, context); Models::DeleteShareResult ret; ret.Deleted = true; return Azure::Response( @@ -176,10 +178,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const CreateShareSnapshotOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Share::CreateSnapshotOptions(); - protocolLayerOptions.Metadata = options.Metadata; - return _detail::ShareRestClient::Share::CreateSnapshot( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::CreateShareSnapshotOptions(); + protocolLayerOptions.Metadata + = std::map(options.Metadata.begin(), options.Metadata.end()); + return _detail::ShareClient::CreateSnapshot( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::GetProperties( @@ -187,20 +190,20 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Share::GetPropertiesOptions(); - return _detail::ShareRestClient::Share::GetProperties( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::GetSharePropertiesOptions(); + return _detail::ShareClient::GetProperties( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::SetProperties( const SetSharePropertiesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Share::SetPropertiesOptions(); - protocolLayerOptions.ShareQuota = options.ShareQuotaInGiB; - protocolLayerOptions.XMsAccessTier = options.AccessTier; - return _detail::ShareRestClient::Share::SetProperties( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::SetSharePropertiesOptions(); + protocolLayerOptions.Quota = options.ShareQuotaInGiB; + protocolLayerOptions.AccessTier = options.AccessTier; + return _detail::ShareClient::SetProperties( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::SetMetadata( @@ -209,10 +212,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Share::SetMetadataOptions(); - protocolLayerOptions.Metadata = metadata; - return _detail::ShareRestClient::Share::SetMetadata( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::SetShareMetadataOptions(); + protocolLayerOptions.Metadata + = std::map(metadata.begin(), metadata.end()); + return _detail::ShareClient::SetMetadata( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::GetAccessPolicy( @@ -220,9 +224,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Share::GetAccessPolicyOptions(); - return _detail::ShareRestClient::Share::GetAccessPolicy( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::GetShareAccessPolicyOptions(); + return _detail::ShareClient::GetAccessPolicy( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::SetAccessPolicy( @@ -231,10 +235,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Share::SetAccessPolicyOptions(); + auto protocolLayerOptions = _detail::ShareClient::SetShareAccessPolicyOptions(); protocolLayerOptions.ShareAcl = accessPolicy; - return _detail::ShareRestClient::Share::SetAccessPolicy( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + return _detail::ShareClient::SetAccessPolicy( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::GetStatistics( @@ -242,9 +246,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Share::GetStatisticsOptions(); - return _detail::ShareRestClient::Share::GetStatistics( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::GetShareStatisticsOptions(); + return _detail::ShareClient::GetStatistics( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::CreatePermission( @@ -253,10 +257,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Share::CreatePermissionOptions(); - protocolLayerOptions.Permission.FilePermission = permission; - return _detail::ShareRestClient::Share::CreatePermission( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::CreateSharePermissionOptions(); + protocolLayerOptions.SharePermission.Permission = permission; + return _detail::ShareClient::CreatePermission( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); } Azure::Response ShareClient::GetPermission( @@ -265,12 +269,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Share::GetPermissionOptions(); - protocolLayerOptions.FilePermissionKeyRequired = permissionKey; - auto result = _detail::ShareRestClient::Share::GetPermission( - m_shareUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ShareClient::GetSharePermissionOptions(); + protocolLayerOptions.FilePermissionKey = permissionKey; + auto result = _detail::ShareClient::GetPermission( + *m_pipeline, m_shareUrl, protocolLayerOptions, context); - return Azure::Response(result.Value.FilePermission, std::move(result.RawResponse)); + return Azure::Response(result.Value.Permission, std::move(result.RawResponse)); } }}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp index f2176ff6d..4097042cc 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "azure/storage/files/shares/share_file_client.hpp" @@ -116,13 +117,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const CreateDirectoryOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Directory::CreateOptions(); - protocolLayerOptions.Metadata = options.Metadata; - protocolLayerOptions.FileAttributes = options.SmbProperties.Attributes.ToString(); - if (protocolLayerOptions.FileAttributes.empty()) + auto protocolLayerOptions = _detail::DirectoryClient::CreateDirectoryOptions(); + protocolLayerOptions.Metadata + = std::map(options.Metadata.begin(), options.Metadata.end()); + if (options.SmbProperties.Attributes.GetValues().empty()) { protocolLayerOptions.FileAttributes = Models::FileAttributes::Directory.ToString(); } + else + { + protocolLayerOptions.FileAttributes = options.SmbProperties.Attributes.ToString(); + } if (options.SmbProperties.CreatedOn.HasValue()) { protocolLayerOptions.FileCreationTime = options.SmbProperties.CreatedOn.Value().ToString( @@ -153,8 +158,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } - auto result = _detail::ShareRestClient::Directory::Create( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto result = _detail::DirectoryClient::Create( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); Models::CreateDirectoryResult ret; ret.Created = true; ret.ETag = std::move(result.Value.ETag); @@ -193,9 +198,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Directory::DeleteOptions(); - auto result = _detail::ShareRestClient::Directory::Delete( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::DirectoryClient::DeleteDirectoryOptions(); + auto result = _detail::DirectoryClient::Delete( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); Models::DeleteDirectoryResult ret; ret.Deleted = true; return Azure::Response( @@ -229,9 +234,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Directory::GetPropertiesOptions(); - return _detail::ShareRestClient::Directory::GetProperties( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::DirectoryClient::GetDirectoryPropertiesOptions(); + return _detail::DirectoryClient::GetProperties( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); } Azure::Response ShareDirectoryClient::SetProperties( @@ -239,7 +244,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const SetDirectoryPropertiesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Directory::SetPropertiesOptions(); + auto protocolLayerOptions = _detail::DirectoryClient::SetDirectoryPropertiesOptions(); protocolLayerOptions.FileAttributes = smbProperties.Attributes.ToString(); if (protocolLayerOptions.FileAttributes.empty()) { @@ -275,8 +280,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { protocolLayerOptions.FilePermission = FilePreserveSmbProperties; } - return _detail::ShareRestClient::Directory::SetProperties( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + return _detail::DirectoryClient::SetProperties( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); } Azure::Response ShareDirectoryClient::SetMetadata( @@ -285,10 +290,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Directory::SetMetadataOptions(); - protocolLayerOptions.Metadata = std::move(metadata); - return _detail::ShareRestClient::Directory::SetMetadata( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::DirectoryClient::SetDirectoryMetadataOptions(); + protocolLayerOptions.Metadata + = std::map(metadata.begin(), metadata.end()); + return _detail::DirectoryClient::SetMetadata( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); } ListFilesAndDirectoriesPagedResponse ShareDirectoryClient::ListFilesAndDirectories( @@ -296,29 +302,26 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { auto protocolLayerOptions - = _detail::ShareRestClient::Directory::ListFilesAndDirectoriesSinglePageOptions(); + = _detail::DirectoryClient::ListDirectoryFilesAndDirectoriesSegmentOptions(); protocolLayerOptions.Prefix = options.Prefix; - if (options.ContinuationToken.HasValue() && !options.ContinuationToken.Value().empty()) - { - protocolLayerOptions.ContinuationToken = options.ContinuationToken; - } + protocolLayerOptions.Marker = options.ContinuationToken; protocolLayerOptions.MaxResults = options.PageSizeHint; - auto response = _detail::ShareRestClient::Directory::ListFilesAndDirectoriesSinglePage( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto response = _detail::DirectoryClient::ListFilesAndDirectoriesSegment( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); ListFilesAndDirectoriesPagedResponse pagedResponse; pagedResponse.ServiceEndpoint = std::move(response.Value.ServiceEndpoint); pagedResponse.ShareName = std::move(response.Value.ShareName); - pagedResponse.ShareSnapshot = std::move(response.Value.ShareSnapshot); + pagedResponse.ShareSnapshot = response.Value.ShareSnapshot.ValueOr(std::string()); pagedResponse.DirectoryPath = std::move(response.Value.DirectoryPath); pagedResponse.Prefix = std::move(response.Value.Prefix); - pagedResponse.Directories = std::move(response.Value.SinglePage.DirectoryItems); - pagedResponse.Files = std::move(response.Value.SinglePage.FileItems); + pagedResponse.Directories = std::move(response.Value.Segment.DirectoryItems); + pagedResponse.Files = std::move(response.Value.Segment.FileItems); pagedResponse.m_shareDirectoryClient = std::make_shared(*this); pagedResponse.m_operationOptions = options; pagedResponse.CurrentPageToken = options.ContinuationToken.ValueOr(std::string()); - pagedResponse.NextPageToken = response.Value.ContinuationToken; + pagedResponse.NextPageToken = response.Value.Marker; pagedResponse.RawResponse = std::move(response.RawResponse); return pagedResponse; @@ -328,15 +331,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ListDirectoryHandlesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Directory::ListHandlesOptions(); - if (options.ContinuationToken.HasValue() && !options.ContinuationToken.Value().empty()) - { - protocolLayerOptions.ContinuationToken = options.ContinuationToken; - } + auto protocolLayerOptions = _detail::DirectoryClient::ListDirectoryHandlesOptions(); + protocolLayerOptions.Marker = options.ContinuationToken; protocolLayerOptions.MaxResults = options.PageSizeHint; protocolLayerOptions.Recursive = options.Recursive; - auto response = _detail::ShareRestClient::Directory::ListHandles( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto response = _detail::DirectoryClient::ListHandles( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); ListDirectoryHandlesPagedResponse pagedResponse; @@ -344,7 +344,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { pagedResponse.m_shareDirectoryClient = std::make_shared(*this); pagedResponse.m_operationOptions = options; pagedResponse.CurrentPageToken = options.ContinuationToken.ValueOr(std::string()); - pagedResponse.NextPageToken = response.Value.ContinuationToken; + if (!response.Value.NextMarker.empty()) + { + pagedResponse.NextPageToken = response.Value.NextMarker; + } pagedResponse.RawResponse = std::move(response.RawResponse); return pagedResponse; @@ -356,10 +359,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::File::ForceCloseHandlesOptions(); + auto protocolLayerOptions = _detail::DirectoryClient::ForceDirectoryCloseHandlesOptions(); protocolLayerOptions.HandleId = handleId; - auto result = _detail::ShareRestClient::File::ForceCloseHandles( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto result = _detail::DirectoryClient::ForceCloseHandles( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); Models::ForceCloseDirectoryHandleResult ret; return Azure::Response( std::move(ret), std::move(result.RawResponse)); @@ -369,15 +372,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ForceCloseAllDirectoryHandlesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Directory::ForceCloseHandlesOptions(); + auto protocolLayerOptions = _detail::DirectoryClient::ForceDirectoryCloseHandlesOptions(); protocolLayerOptions.HandleId = FileAllHandles; - if (options.ContinuationToken.HasValue() && !options.ContinuationToken.Value().empty()) - { - protocolLayerOptions.ContinuationToken = options.ContinuationToken; - } + protocolLayerOptions.Marker = options.ContinuationToken; protocolLayerOptions.Recursive = options.Recursive; - auto response = _detail::ShareRestClient::Directory::ForceCloseHandles( - m_shareDirectoryUrl, *m_pipeline, context, protocolLayerOptions); + auto response = _detail::DirectoryClient::ForceCloseHandles( + *m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context); ForceCloseAllDirectoryHandlesPagedResponse pagedResponse; diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_attributes.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_attributes.cpp deleted file mode 100644 index dfb1d0ed6..000000000 --- a/sdk/storage/azure-storage-files-shares/src/share_file_attributes.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include "azure/storage/files/shares/share_file_attributes.hpp" - -#include -#include - -namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace Models { - - FileAttributes::FileAttributes(const std::string& value) - { - std::string::const_iterator cur = value.begin(); - while (cur != value.end()) - { - auto delimiter_pos - = std::find_if(cur, value.end(), [](char c) { return c == ' ' || c == '|'; }); - m_value.emplace_back(std::string(cur, delimiter_pos)); - while (delimiter_pos != value.end() && (*delimiter_pos == ' ' || *delimiter_pos == '|')) - { - ++delimiter_pos; - } - cur = delimiter_pos; - } - std::sort(m_value.begin(), m_value.end()); - } - - FileAttributes FileAttributes::operator|(const FileAttributes& other) const - { - FileAttributes ret; - std::set_union( - m_value.begin(), - m_value.end(), - other.m_value.begin(), - other.m_value.end(), - std::back_inserter(ret.m_value)); - return ret; - } - - FileAttributes FileAttributes::operator&(const FileAttributes& other) const - { - FileAttributes ret; - std::set_intersection( - m_value.begin(), - m_value.end(), - other.m_value.begin(), - other.m_value.end(), - std::back_inserter(ret.m_value)); - return ret; - } - - FileAttributes FileAttributes::operator^(const FileAttributes& other) const - { - FileAttributes ret; - std::set_symmetric_difference( - m_value.begin(), - m_value.end(), - other.m_value.begin(), - other.m_value.end(), - std::back_inserter(ret.m_value)); - return ret; - } - - std::string FileAttributes::ToString() const - { - std::string ret; - for (const auto& v : m_value) - { - if (!ret.empty()) - { - ret += " | "; - } - ret += v; - } - return ret; - } - - const FileAttributes FileAttributes::ReadOnly("ReadOnly"); - const FileAttributes FileAttributes::Hidden("Hidden"); - const FileAttributes FileAttributes::System("System"); - const FileAttributes FileAttributes::None("None"); - const FileAttributes FileAttributes::Directory("Directory"); - const FileAttributes FileAttributes::Archive("Archive"); - const FileAttributes FileAttributes::Temporary("Temporary"); - const FileAttributes FileAttributes::Offline("Offline"); - const FileAttributes FileAttributes::NotContentIndexed("NotContentIndexed"); - const FileAttributes FileAttributes::NoScrubData("NoScrubData"); - -}}}}} // namespace Azure::Storage::Files::Shares::Models diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index 8e07c002e..7c5df0047 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "azure/storage/files/shares/share_constants.hpp" @@ -106,8 +107,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const CreateFileOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::CreateOptions(); - protocolLayerOptions.Metadata = options.Metadata; + auto protocolLayerOptions = _detail::FileClient::CreateFileOptions(); + protocolLayerOptions.Metadata + = std::map(options.Metadata.begin(), options.Metadata.end()); protocolLayerOptions.FileAttributes = options.SmbProperties.Attributes.ToString(); if (protocolLayerOptions.FileAttributes.empty()) { @@ -143,7 +145,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } - protocolLayerOptions.XMsContentLength = fileSize; + protocolLayerOptions.FileContentLength = fileSize; if (!options.HttpHeaders.ContentType.empty()) { protocolLayerOptions.FileContentType = options.HttpHeaders.ContentType; @@ -169,11 +171,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { AZURE_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); - protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; + protocolLayerOptions.FileContentMD5 = options.HttpHeaders.ContentHash.Value; } - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - auto result = _detail::ShareRestClient::File::Create( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + auto result + = _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context); Models::CreateFileResult ret; ret.Created = true; ret.ETag = std::move(result.Value.ETag); @@ -188,10 +190,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const DeleteFileOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::DeleteOptions(); - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - auto result = _detail::ShareRestClient::File::Delete( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::FileClient::DeleteFileOptions(); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + auto result + = _detail::FileClient::Delete(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context); Models::DeleteFileResult ret; ret.Deleted = true; return Azure::Response(std::move(ret), std::move(result.RawResponse)); @@ -222,7 +224,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const DownloadFileOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::DownloadOptions(); + auto protocolLayerOptions = _detail::FileClient::DownloadFileOptions(); if (options.Range.HasValue()) { if (options.Range.Value().Length.HasValue()) @@ -245,17 +247,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { "This operation only supports MD5 content hash."); if (options.RangeHashAlgorithm.Value() == HashAlgorithm::Md5) { - protocolLayerOptions.GetRangeContentMd5 = true; + protocolLayerOptions.RangeGetContentMD5 = true; } } - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; - auto downloadResponse = _detail::ShareRestClient::File::Download( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + auto downloadResponse + = _detail::FileClient::Download(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context); { // In case network failure during reading the body - auto eTag = downloadResponse.Value.ETag; + auto eTag = downloadResponse.Value.Details.ETag; auto retryFunction = [this, options, eTag](int64_t retryOffset, const Azure::Core::Context& context) @@ -282,28 +284,31 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { downloadResponse.Value.BodyStream = std::make_unique<_internal::ReliableStream>( std::move(downloadResponse.Value.BodyStream), reliableStreamOptions, retryFunction); } - Models::DownloadFileResult ret; - ret.BodyStream = std::move(downloadResponse.Value.BodyStream); - ret.ContentRange = std::move(downloadResponse.Value.ContentRange); - ret.FileSize = downloadResponse.Value.FileSize; - ret.TransactionalContentHash = std::move(downloadResponse.Value.TransactionalContentHash); - ret.HttpHeaders = std::move(downloadResponse.Value.HttpHeaders); - ret.Details.LastModified = std::move(downloadResponse.Value.LastModified); - ret.Details.Metadata = std::move(downloadResponse.Value.Metadata); - ret.Details.ETag = std::move(downloadResponse.Value.ETag); - ret.Details.CopyCompletedOn = std::move(downloadResponse.Value.CopyCompletedOn); - ret.Details.CopyStatusDescription = std::move(downloadResponse.Value.CopyStatusDescription); - ret.Details.CopyId = std::move(downloadResponse.Value.CopyId); - ret.Details.CopyProgress = std::move(downloadResponse.Value.CopyProgress); - ret.Details.CopySource = std::move(downloadResponse.Value.CopySource); - ret.Details.CopyStatus = std::move(downloadResponse.Value.CopyStatus); - ret.Details.IsServerEncrypted = downloadResponse.Value.IsServerEncrypted; - ret.Details.SmbProperties = std::move(downloadResponse.Value.SmbProperties); - ret.Details.LeaseDuration = std::move(downloadResponse.Value.LeaseDuration); - ret.Details.LeaseState = std::move(downloadResponse.Value.LeaseState); - ret.Details.LeaseStatus = std::move(downloadResponse.Value.LeaseStatus); - return Azure::Response( - std::move(ret), std::move(downloadResponse.RawResponse)); + if (downloadResponse.RawResponse->GetStatusCode() == Azure::Core::Http::HttpStatusCode::Ok) + { + downloadResponse.Value.FileSize = std::stoll( + downloadResponse.RawResponse->GetHeaders().at(_internal::HttpHeaderContentLength)); + downloadResponse.Value.ContentRange.Offset = 0; + downloadResponse.Value.ContentRange.Length = downloadResponse.Value.FileSize; + } + else if ( + downloadResponse.RawResponse->GetStatusCode() + == Azure::Core::Http::HttpStatusCode::PartialContent) + { + const std::string& contentRange + = downloadResponse.RawResponse->GetHeaders().at(_internal::HttpHeaderContentRange); + auto bytes_pos = contentRange.find("bytes "); + auto dash_pos = contentRange.find("-", bytes_pos + 6); + auto slash_pos = contentRange.find("/", dash_pos + 1); + const int64_t rangeStartOffset = std::stoll( + std::string(contentRange.begin() + bytes_pos + 6, contentRange.begin() + dash_pos)); + const int64_t rangeEndOffset = std::stoll( + std::string(contentRange.begin() + dash_pos + 1, contentRange.begin() + slash_pos)); + downloadResponse.Value.ContentRange + = Azure::Core::Http::HttpRange{rangeStartOffset, rangeEndOffset - rangeStartOffset + 1}; + downloadResponse.Value.FileSize = std::stoll(contentRange.substr(slash_pos + 1)); + } + return downloadResponse; } StartFileCopyOperation ShareFileClient::StartCopy( @@ -311,33 +316,39 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const StartFileCopyOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::StartCopyOptions(); - protocolLayerOptions.Metadata = options.Metadata; + auto protocolLayerOptions = _detail::FileClient::StartFileCopyOptions(); + protocolLayerOptions.Metadata + = std::map(options.Metadata.begin(), options.Metadata.end()); protocolLayerOptions.CopySource = std::move(copySource); - protocolLayerOptions.FileCopyFileAttributes = options.SmbProperties.Attributes.ToString(); - if (options.SmbProperties.CreatedOn.HasValue()) + if (options.SmbProperties.Attributes.GetValues().empty()) { - protocolLayerOptions.FileCopyFileCreationTime - = options.SmbProperties.CreatedOn.Value().ToString( - Azure::DateTime::DateFormat::Rfc3339, DateTime::TimeFractionFormat::AllDigits); + protocolLayerOptions.FileAttributes = FileCopySourceTime; } else { - protocolLayerOptions.FileCopyFileCreationTime = std::string(FileCopySourceTime); + protocolLayerOptions.FileAttributes = options.SmbProperties.Attributes.ToString(); + } + if (options.SmbProperties.CreatedOn.HasValue()) + { + protocolLayerOptions.FileCreationTime = options.SmbProperties.CreatedOn.Value().ToString( + Azure::DateTime::DateFormat::Rfc3339, DateTime::TimeFractionFormat::AllDigits); + } + else + { + protocolLayerOptions.FileCreationTime = std::string(FileCopySourceTime); } if (options.SmbProperties.LastWrittenOn.HasValue()) { - protocolLayerOptions.FileCopyFileLastWriteTime - = options.SmbProperties.LastWrittenOn.Value().ToString( - Azure::DateTime::DateFormat::Rfc3339, DateTime::TimeFractionFormat::AllDigits); + protocolLayerOptions.FileLastWriteTime = options.SmbProperties.LastWrittenOn.Value().ToString( + Azure::DateTime::DateFormat::Rfc3339, DateTime::TimeFractionFormat::AllDigits); } else { - protocolLayerOptions.FileCopyFileLastWriteTime = std::string(FileCopySourceTime); + protocolLayerOptions.FileLastWriteTime = std::string(FileCopySourceTime); } if (options.PermissionCopyMode.HasValue()) { - protocolLayerOptions.XMsFilePermissionCopyMode = options.PermissionCopyMode.Value(); + protocolLayerOptions.FilePermissionCopyMode = options.PermissionCopyMode.Value(); if (options.PermissionCopyMode.Value() == Models::PermissionCopyMode::Override) { if (options.Permission.HasValue()) @@ -356,13 +367,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.XMsFilePermissionCopyMode = Models::PermissionCopyMode::Source; + protocolLayerOptions.FilePermissionCopyMode = Models::PermissionCopyMode::Source; } - protocolLayerOptions.FileCopyIgnoreReadOnly = options.IgnoreReadOnly; - protocolLayerOptions.FileCopySetArchiveAttribute = options.SetArchiveAttribute; - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - auto response = _detail::ShareRestClient::File::StartCopy( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.IgnoreReadOnly = options.IgnoreReadOnly; + protocolLayerOptions.SetArchiveAttribute = options.SetArchiveAttribute; + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + auto response = _detail::FileClient::StartCopy( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); StartFileCopyOperation res; res.m_rawResponse = std::move(response.RawResponse); @@ -375,21 +386,21 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const AbortFileCopyOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::AbortCopyOptions(); + auto protocolLayerOptions = _detail::FileClient::AbortFileCopyOptions(); protocolLayerOptions.CopyId = std::move(copyId); - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - return _detail::ShareRestClient::File::AbortCopy( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + return _detail::FileClient::AbortCopy( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); } Azure::Response ShareFileClient::GetProperties( const GetFilePropertiesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::GetPropertiesOptions(); - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - return _detail::ShareRestClient::File::GetProperties( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::FileClient::GetFilePropertiesOptions(); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + return _detail::FileClient::GetProperties( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); } Azure::Response ShareFileClient::SetProperties( @@ -398,7 +409,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const SetFilePropertiesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::SetHttpHeadersOptions(); + auto protocolLayerOptions = _detail::FileClient::SetFileHttpHeadersOptions(); protocolLayerOptions.FileAttributes = smbProperties.Attributes.ToString(); if (protocolLayerOptions.FileAttributes.empty()) { @@ -422,8 +433,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { protocolLayerOptions.FileLastWriteTime = FilePreserveSmbProperties; } - protocolLayerOptions.XMsContentLength = options.Size; - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; + protocolLayerOptions.FileContentLength = options.Size; + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; if (options.Permission.HasValue()) { protocolLayerOptions.FilePermission = options.Permission; @@ -458,8 +469,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { protocolLayerOptions.FileContentDisposition = httpHeaders.ContentDisposition; } - return _detail::ShareRestClient::File::SetHttpHeaders( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + return _detail::FileClient::SetHttpHeaders( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); } Azure::Response ShareFileClient::SetMetadata( @@ -467,11 +478,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const SetFileMetadataOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::SetMetadataOptions(); - protocolLayerOptions.Metadata = std::move(metadata); - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - return _detail::ShareRestClient::File::SetMetadata( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::FileClient::SetFileMetadataOptions(); + protocolLayerOptions.Metadata + = std::map(metadata.begin(), metadata.end()); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + return _detail::FileClient::SetMetadata( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); } Azure::Response ShareFileClient::UploadRange( @@ -480,21 +492,20 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const UploadFileRangeOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::UploadRangeOptions(); - protocolLayerOptions.XMsWrite = _detail::FileRangeWrite::Update; - protocolLayerOptions.ContentLength = content.Length(); - protocolLayerOptions.XMsRange = std::string("bytes=") + std::to_string(offset) - + std::string("-") + std::to_string(offset + content.Length() - 1); + auto protocolLayerOptions = _detail::FileClient::UploadFileRangeOptions(); + protocolLayerOptions.FileRangeWrite = "update"; + protocolLayerOptions.Range = std::string("bytes=") + std::to_string(offset) + std::string("-") + + std::to_string(offset + content.Length() - 1); if (options.TransactionalContentHash.HasValue()) { AZURE_ASSERT_MSG( options.TransactionalContentHash.Value().Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); + protocolLayerOptions.ContentMD5 = options.TransactionalContentHash.Value().Value; } - protocolLayerOptions.ContentMd5 = options.TransactionalContentHash; - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - return _detail::ShareRestClient::File::UploadRange( - m_shareFileUrl, content, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + return _detail::FileClient::UploadRange( + *m_pipeline, m_shareFileUrl, content, protocolLayerOptions, context); } Azure::Response ShareFileClient::ClearRange( @@ -503,19 +514,18 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ClearFileRangeOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::UploadRangeOptions(); - protocolLayerOptions.XMsWrite = _detail::FileRangeWrite::Clear; - protocolLayerOptions.ContentLength = 0; - protocolLayerOptions.XMsRange = std::string("bytes=") + std::to_string(offset) - + std::string("-") + std::to_string(offset + length - 1); + auto protocolLayerOptions = _detail::FileClient::UploadFileRangeOptions(); + protocolLayerOptions.FileRangeWrite = "clear"; + protocolLayerOptions.Range = std::string("bytes=") + std::to_string(offset) + std::string("-") + + std::to_string(offset + length - 1); - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - auto response = _detail::ShareRestClient::File::UploadRange( + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + auto response = _detail::FileClient::UploadRange( + *m_pipeline, m_shareFileUrl, *Azure::Core::IO::_internal::NullBodyStream::GetNullBodyStream(), - *m_pipeline, - context, - protocolLayerOptions); + protocolLayerOptions, + context); Models::ClearFileRangeResult ret; ret.ETag = std::move(response.Value.ETag); ret.IsServerEncrypted = response.Value.IsServerEncrypted; @@ -528,26 +538,26 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const GetFileRangeListOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::GetRangeListOptions(); + auto protocolLayerOptions = _detail::FileClient::GetFileRangeListOptions(); if (options.Range.HasValue()) { if (options.Range.Value().Length.HasValue()) { - protocolLayerOptions.XMsRange = std::string("bytes=") + protocolLayerOptions.Range = std::string("bytes=") + std::to_string(options.Range.Value().Offset) + std::string("-") + std::to_string(options.Range.Value().Offset + options.Range.Value().Length.Value() - 1); } else { - protocolLayerOptions.XMsRange = std::string("bytes=") + protocolLayerOptions.Range = std::string("bytes=") + std::to_string(options.Range.Value().Offset) + std::string("-"); } } - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - return _detail::ShareRestClient::File::GetRangeList( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + return _detail::FileClient::GetRangeList( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); } Azure::Response ShareFileClient::GetRangeListDiff( @@ -555,41 +565,38 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const GetFileRangeListOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::GetRangeListOptions(); + auto protocolLayerOptions = _detail::FileClient::GetFileRangeListOptions(); if (options.Range.HasValue()) { if (options.Range.Value().Length.HasValue()) { - protocolLayerOptions.XMsRange = std::string("bytes=") + protocolLayerOptions.Range = std::string("bytes=") + std::to_string(options.Range.Value().Offset) + std::string("-") + std::to_string(options.Range.Value().Offset + options.Range.Value().Length.Value() - 1); } else { - protocolLayerOptions.XMsRange = std::string("bytes=") + protocolLayerOptions.Range = std::string("bytes=") + std::to_string(options.Range.Value().Offset) + std::string("-"); } } - protocolLayerOptions.PrevShareSnapshot = std::move(previousShareSnapshot); - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; - return _detail::ShareRestClient::File::GetRangeList( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.Prevsharesnapshot = std::move(previousShareSnapshot); + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; + return _detail::FileClient::GetRangeList( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); } ListFileHandlesPagedResponse ShareFileClient::ListHandles( const ListFileHandlesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::ListHandlesOptions(); - if (options.ContinuationToken.HasValue() && !options.ContinuationToken.Value().empty()) - { - protocolLayerOptions.ContinuationToken = options.ContinuationToken; - } + auto protocolLayerOptions = _detail::FileClient::ListFileHandlesOptions(); + protocolLayerOptions.Marker = options.ContinuationToken; protocolLayerOptions.MaxResults = options.PageSizeHint; - auto response = _detail::ShareRestClient::File::ListHandles( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + auto response = _detail::FileClient::ListHandles( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); ListFileHandlesPagedResponse pagedResponse; @@ -597,7 +604,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { pagedResponse.m_shareFileClient = std::make_shared(*this); pagedResponse.m_operationOptions = options; pagedResponse.CurrentPageToken = options.ContinuationToken.ValueOr(std::string()); - pagedResponse.NextPageToken = response.Value.ContinuationToken; + if (!response.Value.NextMarker.empty()) + { + pagedResponse.NextPageToken = response.Value.NextMarker; + } pagedResponse.RawResponse = std::move(response.RawResponse); return pagedResponse; @@ -609,10 +619,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::File::ForceCloseHandlesOptions(); + auto protocolLayerOptions = _detail::FileClient::ForceFileCloseHandlesOptions(); protocolLayerOptions.HandleId = handleId; - auto result = _detail::ShareRestClient::File::ForceCloseHandles( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + auto result = _detail::FileClient::ForceCloseHandles( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); return Azure::Response( Models::ForceCloseFileHandleResult(), std::move(result.RawResponse)); } @@ -621,14 +631,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ForceCloseAllFileHandlesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::File::ForceCloseHandlesOptions(); + auto protocolLayerOptions = _detail::FileClient::ForceFileCloseHandlesOptions(); protocolLayerOptions.HandleId = FileAllHandles; - if (options.ContinuationToken.HasValue() && !options.ContinuationToken.Value().empty()) - { - protocolLayerOptions.ContinuationToken = options.ContinuationToken; - } - auto response = _detail::ShareRestClient::File::ForceCloseHandles( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.Marker = options.ContinuationToken; + auto response = _detail::FileClient::ForceCloseHandles( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); ForceCloseAllFileHandlesPagedResponse pagedResponse; @@ -637,7 +644,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { pagedResponse.m_shareFileClient = std::make_shared(*this); pagedResponse.m_operationOptions = options; pagedResponse.CurrentPageToken = options.ContinuationToken.ValueOr(std::string()); - pagedResponse.NextPageToken = response.Value.ContinuationToken.ValueOr(std::string()); + pagedResponse.NextPageToken = response.Value.ContinuationToken; pagedResponse.RawResponse = std::move(response.RawResponse); return pagedResponse; @@ -880,8 +887,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const UploadFileFromOptions& options, const Azure::Core::Context& context) const { - _detail::ShareRestClient::File::CreateOptions protocolLayerOptions; - protocolLayerOptions.XMsContentLength = bufferSize; + _detail::FileClient::CreateFileOptions protocolLayerOptions; + protocolLayerOptions.FileContentLength = bufferSize; protocolLayerOptions.FileAttributes = options.SmbProperties.Attributes.ToString(); if (protocolLayerOptions.FileAttributes.empty()) { @@ -943,11 +950,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { AZURE_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); - protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; + protocolLayerOptions.FileContentMD5 = options.HttpHeaders.ContentHash.Value; } - protocolLayerOptions.Metadata = options.Metadata; - auto createResult = _detail::ShareRestClient::File::Create( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.Metadata + = std::map(options.Metadata.begin(), options.Metadata.end()); + auto createResult + = _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context); auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) { (void)chunkId; @@ -984,8 +992,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { _internal::FileReader fileReader(fileName); - _detail::ShareRestClient::File::CreateOptions protocolLayerOptions; - protocolLayerOptions.XMsContentLength = fileReader.GetFileSize(); + _detail::FileClient::CreateFileOptions protocolLayerOptions; + protocolLayerOptions.FileContentLength = fileReader.GetFileSize(); protocolLayerOptions.FileAttributes = options.SmbProperties.Attributes.ToString(); if (protocolLayerOptions.FileAttributes.empty()) { @@ -1047,11 +1055,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { AZURE_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); - protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; + protocolLayerOptions.FileContentMD5 = options.HttpHeaders.ContentHash.Value; } - protocolLayerOptions.Metadata = options.Metadata; - auto createResult = _detail::ShareRestClient::File::Create( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + protocolLayerOptions.Metadata + = std::map(options.Metadata.begin(), options.Metadata.end()); + auto createResult + = _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context); auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) { (void)chunkId; @@ -1091,41 +1100,40 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { AZURE_ASSERT_MSG(sourceRange.Length.HasValue(), "Source length cannot be null."); int64_t rangeLength = sourceRange.Length.Value(); - auto protocolLayerOptions = _detail::ShareRestClient::File::UploadRangeFromUrlOptions(); - protocolLayerOptions.TargetRange = std::string("bytes=") + std::to_string(destinationOffset) + auto protocolLayerOptions = _detail::FileClient::UploadFileRangeFromUriOptions(); + protocolLayerOptions.Range = std::string("bytes=") + std::to_string(destinationOffset) + std::string("-") + std::to_string(destinationOffset + rangeLength - 1); - protocolLayerOptions.ContentLength = 0; protocolLayerOptions.CopySource = sourceUri; - protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; + protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId; if (options.TransactionalContentHash.HasValue()) { AZURE_ASSERT_MSG( options.TransactionalContentHash.Value().Algorithm == HashAlgorithm::Crc64, "This operation only supports CRC64 content hash."); + protocolLayerOptions.SourceContentCrc64 = options.TransactionalContentHash.Value().Value; } - protocolLayerOptions.SourceContentCrc64 = options.TransactionalContentHash; if (options.SourceAccessCondition.IfMatchContentHash.HasValue()) { AZURE_ASSERT_MSG( options.SourceAccessCondition.IfMatchContentHash.Value().Algorithm == HashAlgorithm::Crc64, "This operation only supports CRC64 Source-If-Match condition."); + protocolLayerOptions.SourceIfMatchCrc64 + = options.SourceAccessCondition.IfMatchContentHash.Value().Value; } - protocolLayerOptions.SourceIfMatchCrc64 = options.SourceAccessCondition.IfMatchContentHash; if (options.SourceAccessCondition.IfNoneMatchContentHash.HasValue()) { AZURE_ASSERT_MSG( options.SourceAccessCondition.IfNoneMatchContentHash.Value().Algorithm == HashAlgorithm::Crc64, "This operation only supports CRC64 Source-If-None-Match condition."); + protocolLayerOptions.SourceIfNoneMatchCrc64 + = options.SourceAccessCondition.IfNoneMatchContentHash.Value().Value; } - protocolLayerOptions.SourceIfNoneMatchCrc64 - = options.SourceAccessCondition.IfNoneMatchContentHash; protocolLayerOptions.SourceRange = std::string("bytes=") + std::to_string(sourceRange.Offset) + std::string("-") + std::to_string(sourceRange.Offset + sourceRange.Length.Value() - 1); - protocolLayerOptions.XMsWrite = _detail::FileRangeWriteFromUrl::Update; - return _detail::ShareRestClient::File::UploadRangeFromUrl( - m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + return _detail::FileClient::UploadRangeFromUri( + *m_pipeline, m_shareFileUrl, protocolLayerOptions, context); } }}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp index 3863c5793..136a56408 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp @@ -22,15 +22,15 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; if (m_fileClient.HasValue()) { - _detail::ShareRestClient::File::AcquireLeaseOptions protocolLayerOptions; - protocolLayerOptions.ProposedLeaseIdOptional = GetLeaseId(); - protocolLayerOptions.LeaseDuration = static_cast(duration.count()); + _detail::FileClient::AcquireFileLeaseOptions protocolLayerOptions; + protocolLayerOptions.ProposedLeaseId = GetLeaseId(); + protocolLayerOptions.Duration = static_cast(duration.count()); - auto response = _detail::ShareRestClient::File::AcquireLease( - m_fileClient.Value().m_shareFileUrl, + auto response = _detail::FileClient::AcquireLease( *(m_fileClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_fileClient.Value().m_shareFileUrl, + protocolLayerOptions, + context); Models::AcquireLeaseResult ret; ret.ETag = std::move(response.Value.ETag); @@ -42,15 +42,15 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else if (m_shareClient.HasValue()) { - _detail::ShareRestClient::Share::AcquireLeaseOptions protocolLayerOptions; - protocolLayerOptions.ProposedLeaseIdOptional = GetLeaseId(); - protocolLayerOptions.LeaseDuration = static_cast(duration.count()); + _detail::ShareClient::AcquireShareLeaseOptions protocolLayerOptions; + protocolLayerOptions.ProposedLeaseId = GetLeaseId(); + protocolLayerOptions.Duration = static_cast(duration.count()); - auto response = _detail::ShareRestClient::Share::AcquireLease( - m_shareClient.Value().m_shareUrl, + auto response = _detail::ShareClient::AcquireLease( *(m_shareClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_shareClient.Value().m_shareUrl, + protocolLayerOptions, + context); Models::AcquireLeaseResult ret; ret.ETag = std::move(response.Value.ETag); @@ -73,19 +73,19 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; if (m_fileClient.HasValue()) { - AZURE_ASSERT_MSG(false, "Share lease doesn't support renew"); + AZURE_ASSERT_MSG(false, "File lease doesn't support renew"); AZURE_NOT_IMPLEMENTED(); } else if (m_shareClient.HasValue()) { - _detail::ShareRestClient::Share::RenewLeaseOptions protocolLayerOptions; - protocolLayerOptions.LeaseIdRequired = GetLeaseId(); + _detail::ShareClient::RenewShareLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseId = GetLeaseId(); - auto response = _detail::ShareRestClient::Share::RenewLease( - m_shareClient.Value().m_shareUrl, + auto response = _detail::ShareClient::RenewLease( *(m_shareClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_shareClient.Value().m_shareUrl, + protocolLayerOptions, + context); Models::RenewLeaseResult ret; ret.ETag = std::move(response.Value.ETag); @@ -108,14 +108,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; if (m_fileClient.HasValue()) { - _detail::ShareRestClient::File::ReleaseLeaseOptions protocolLayerOptions; - protocolLayerOptions.LeaseIdRequired = GetLeaseId(); + _detail::FileClient::ReleaseFileLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseId = GetLeaseId(); - auto response = _detail::ShareRestClient::File::ReleaseLease( - m_fileClient.Value().m_shareFileUrl, + auto response = _detail::FileClient::ReleaseLease( *(m_fileClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_fileClient.Value().m_shareFileUrl, + protocolLayerOptions, + context); Models::ReleaseLeaseResult ret; ret.ETag = std::move(response.Value.ETag); @@ -126,14 +126,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else if (m_shareClient.HasValue()) { - _detail::ShareRestClient::Share::ReleaseLeaseOptions protocolLayerOptions; - protocolLayerOptions.LeaseIdRequired = GetLeaseId(); + _detail::ShareClient::ReleaseShareLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseId = GetLeaseId(); - auto response = _detail::ShareRestClient::Share::ReleaseLease( - m_shareClient.Value().m_shareUrl, + auto response = _detail::ShareClient::ReleaseLease( *(m_shareClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_shareClient.Value().m_shareUrl, + protocolLayerOptions, + context); Models::ReleaseLeaseResult ret; ret.ETag = std::move(response.Value.ETag); @@ -156,15 +156,15 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; if (m_fileClient.HasValue()) { - _detail::ShareRestClient::File::ChangeLeaseOptions protocolLayerOptions; - protocolLayerOptions.LeaseIdRequired = GetLeaseId(); - protocolLayerOptions.ProposedLeaseIdOptional = proposedLeaseId; + _detail::FileClient::ChangeFileLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseId = GetLeaseId(); + protocolLayerOptions.ProposedLeaseId = proposedLeaseId; - auto response = _detail::ShareRestClient::File::ChangeLease( - m_fileClient.Value().m_shareFileUrl, + auto response = _detail::FileClient::ChangeLease( *(m_fileClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_fileClient.Value().m_shareFileUrl, + protocolLayerOptions, + context); { std::lock_guard guard(m_mutex); @@ -181,15 +181,15 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else if (m_shareClient.HasValue()) { - _detail::ShareRestClient::Share::ChangeLeaseOptions protocolLayerOptions; - protocolLayerOptions.LeaseIdRequired = GetLeaseId(); - protocolLayerOptions.ProposedLeaseIdOptional = proposedLeaseId; + _detail::ShareClient::ChangeShareLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseId = GetLeaseId(); + protocolLayerOptions.ProposedLeaseId = proposedLeaseId; - auto response = _detail::ShareRestClient::Share::ChangeLease( - m_shareClient.Value().m_shareUrl, + auto response = _detail::ShareClient::ChangeLease( *(m_shareClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_shareClient.Value().m_shareUrl, + protocolLayerOptions, + context); { std::lock_guard guard(m_mutex); @@ -217,13 +217,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; if (m_fileClient.HasValue()) { - _detail::ShareRestClient::File::BreakLeaseOptions protocolLayerOptions; + _detail::FileClient::BreakFileLeaseOptions protocolLayerOptions; - auto response = _detail::ShareRestClient::File::BreakLease( - m_fileClient.Value().m_shareFileUrl, + auto response = _detail::FileClient::BreakLease( *(m_fileClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_fileClient.Value().m_shareFileUrl, + protocolLayerOptions, + context); Models::BreakLeaseResult ret; ret.ETag = std::move(response.Value.ETag); @@ -234,13 +234,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else if (m_shareClient.HasValue()) { - _detail::ShareRestClient::Share::BreakLeaseOptions protocolLayerOptions; + _detail::ShareClient::BreakShareLeaseOptions protocolLayerOptions; + + auto response = _detail::ShareClient::BreakLease( - auto response = _detail::ShareRestClient::Share::BreakLease( - m_shareClient.Value().m_shareUrl, *(m_shareClient.Value().m_pipeline), - context, - protocolLayerOptions); + m_shareClient.Value().m_shareUrl, + protocolLayerOptions, + context); Models::BreakLeaseResult ret; ret.ETag = std::move(response.Value.ETag); diff --git a/sdk/storage/azure-storage-files-shares/src/share_rest_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_rest_client.cpp deleted file mode 100644 index 17688df29..000000000 --- a/sdk/storage/azure-storage-files-shares/src/share_rest_client.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include "azure/storage/files/shares/protocol/share_rest_client.hpp" - -namespace Azure { namespace Storage { namespace Files { namespace Shares { - namespace Models { - const AccessTier AccessTier::TransactionOptimized("TransactionOptimized"); - const AccessTier AccessTier::Hot("Hot"); - const AccessTier AccessTier::Cool("Cool"); - const AccessTier AccessTier::Premium("Premium"); - - const PermissionCopyMode PermissionCopyMode::Source("source"); - const PermissionCopyMode PermissionCopyMode::Override("override"); - - const DeleteSnapshotsOption DeleteSnapshotsOption::Include("include"); - - const LeaseDuration LeaseDuration::Infinite("infinite"); - const LeaseDuration LeaseDuration::Fixed("fixed"); - - const LeaseState LeaseState::Available("available"); - const LeaseState LeaseState::Leased("leased"); - const LeaseState LeaseState::Expired("expired"); - const LeaseState LeaseState::Breaking("breaking"); - const LeaseState LeaseState::Broken("broken"); - - const LeaseStatus LeaseStatus::Locked("locked"); - const LeaseStatus LeaseStatus::Unlocked("unlocked"); - - const CopyStatus CopyStatus::Pending("pending"); - const CopyStatus CopyStatus::Success("success"); - const CopyStatus CopyStatus::Aborted("aborted"); - const CopyStatus CopyStatus::Failed("failed"); - - } // namespace Models - namespace _detail { - const FileRangeWrite FileRangeWrite::Update("update"); - const FileRangeWrite FileRangeWrite::Clear("clear"); - - const FileRangeWriteFromUrl FileRangeWriteFromUrl::Update("update"); - - const LeaseAction LeaseAction::Acquire("acquire"); - const LeaseAction LeaseAction::Release("release"); - const LeaseAction LeaseAction::Change("change"); - const LeaseAction LeaseAction::Renew("renew"); - const LeaseAction LeaseAction::Break("break"); - - } // namespace _detail -}}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp index a73afb992..1ffba9cb5 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -87,25 +88,25 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ListSharesOptions& options, const Azure::Core::Context& context) const { - auto protocolLayerOptions = _detail::ShareRestClient::Service::ListSharesSinglePageOptions(); - protocolLayerOptions.IncludeFlags = options.ListSharesIncludeFlags; - if (options.ContinuationToken.HasValue() && !options.ContinuationToken.Value().empty()) - { - protocolLayerOptions.ContinuationToken = options.ContinuationToken; - } + auto protocolLayerOptions = _detail::ServiceClient::ListServiceSharesSegmentOptions(); + protocolLayerOptions.Include = options.ListSharesIncludeFlags; + protocolLayerOptions.Marker = options.ContinuationToken; protocolLayerOptions.MaxResults = options.PageSizeHint; protocolLayerOptions.Prefix = options.Prefix; - auto response = _detail::ShareRestClient::Service::ListSharesSinglePage( - m_serviceUrl, *m_pipeline, context, protocolLayerOptions); + auto response = _detail::ServiceClient::ListSharesSegment( + *m_pipeline, m_serviceUrl, protocolLayerOptions, context); ListSharesPagedResponse pagedResponse; pagedResponse.ServiceEndpoint = std::move(response.Value.ServiceEndpoint); - pagedResponse.Prefix = std::move(response.Value.Prefix); - pagedResponse.Shares = std::move(response.Value.Items); + pagedResponse.Prefix = response.Value.Prefix.ValueOr(std::string()); + pagedResponse.Shares = std::move(response.Value.ShareItems); pagedResponse.m_shareServiceClient = std::make_shared(*this); pagedResponse.m_operationOptions = options; pagedResponse.CurrentPageToken = options.ContinuationToken.ValueOr(std::string()); - pagedResponse.NextPageToken = response.Value.ContinuationToken; + if (!response.Value.NextMarker.empty()) + { + pagedResponse.NextPageToken = response.Value.NextMarker; + } pagedResponse.RawResponse = std::move(response.RawResponse); return pagedResponse; @@ -117,10 +118,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Service::SetPropertiesOptions(); - protocolLayerOptions.ServiceProperties = std::move(properties); - return _detail::ShareRestClient::Service::SetProperties( - m_serviceUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ServiceClient::SetServicePropertiesOptions(); + protocolLayerOptions.ShareServiceProperties = std::move(properties); + return _detail::ServiceClient::SetProperties( + *m_pipeline, m_serviceUrl, protocolLayerOptions, context); } Azure::Response ShareServiceClient::GetProperties( @@ -128,9 +129,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Azure::Core::Context& context) const { (void)options; - auto protocolLayerOptions = _detail::ShareRestClient::Service::GetPropertiesOptions(); - auto result = _detail::ShareRestClient::Service::GetProperties( - m_serviceUrl, *m_pipeline, context, protocolLayerOptions); + auto protocolLayerOptions = _detail::ServiceClient::GetServicePropertiesOptions(); + auto result = _detail::ServiceClient::GetProperties( + *m_pipeline, m_serviceUrl, protocolLayerOptions, context); Models::ShareServiceProperties ret; ret.Cors = std::move(result.Value.Cors); ret.HourMetrics = std::move(result.Value.HourMetrics); diff --git a/sdk/storage/azure-storage-files-shares/swagger/README.md b/sdk/storage/azure-storage-files-shares/swagger/README.md new file mode 100644 index 000000000..e4ce1a8d9 --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/swagger/README.md @@ -0,0 +1,919 @@ +# Azure Storage C++ Protocol Layer + +> see https://aka.ms/autorest + +## Configuration + +```yaml +package-name: azure-storage-files-shares +namespace: Azure::Storage::Files::Shares +output-folder: generated +clear-output-folder: true +input-file: https://raw.githubusercontent.com/Jinming-Hu/azure-storage-api-specs/main/Microsoft.FileStorage/preview/2020-02-10/file.json +``` + +## ModelFour Options + +```yaml +modelerfour: + naming: + property: pascal + parameter: pascal +``` + +## Customizations for Track 2 Generator + +See the [AutoRest samples](https://github.com/Azure/autorest/tree/master/Samples/3b-custom-transformations) +for more about how we're customizing things. + +### Fix Generator Warnings + +```yaml +directive: + - from: swagger-document + where: $.info + transform: > + delete $["x-ms-code-generation-settings"]; +``` + +### Delete Unused Query Parameters and Headers + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"].*.*.parameters + transform: > + $ = $.filter(p => !(p["$ref"] && (p["$ref"].endsWith("#/parameters/Timeout") || p["$ref"].endsWith("#/parameters/ClientRequestId")))); + - from: swagger-document + where: $["x-ms-paths"].*.*.responses.*.headers + transform: > + for (const h in $) { + if (["x-ms-client-request-id", "x-ms-request-id", "x-ms-version", "Date"].includes(h)) { + delete $[h]; + } + } +``` + +### Delete Unused Operations + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"] + transform: > + delete $["/{shareName}?restype=share&comp=undelete"].put; +``` + +### API Version + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + $.ApiVersion = { + "type": "string", + "x-ms-export": true, + "x-namespace": "_detail", + "x-ms-enum": { + "name": "ApiVersion", + "modelAsString": false + }, + "enum": ["2020-02-10"], + "description": "The version used for the operations to Azure storage services." + }; + - from: swagger-document + where: $.parameters + transform: > + $.ApiVersionParameter.enum[0] = "2020-02-10"; +``` + +### Rename Operations + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"] + transform: > + $["/{shareName}/{directory}/{fileName}?comp=range&fromURL"].put.operationId = "File_UploadRangeFromUri"; +``` + +### Define names for return types + +```yaml +directive: + - from: swagger-document + where: $ + transform: > + const operationReturnTypeNames = new Map(Object.entries({ + "Directory_ForceCloseHandles": "ForceCloseDirectoryHandlesResult", + })); + for (const url in $["x-ms-paths"]) { + for (const verb in $["x-ms-paths"][url]) { + const operation = $["x-ms-paths"][url][verb]; + if (!operationReturnTypeNames.has(operation.operationId)) { + continue; + } + const returnTypeName = operationReturnTypeNames.get(operation.operationId); + const status_codes = Object.keys(operation.responses).filter(s => s !== "default"); + const emptySchemaDefinition = { + "type": "object", + "x-ms-client-name": returnTypeName, + "x-ms-sealed": false, + "properties": { + "__placeHolder": {"type": "integer"} + } + }; + $.definitions[returnTypeName] = emptySchemaDefinition; + status_codes.map(i => { + operation.responses[i].schema = {"$ref": `#/definitions/${returnTypeName}`}; + }); + } + } +``` + +### Return Type namespace + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + $.ListHandlesResponse["x-namespace"] = "_detail"; + $.ListSharesResponse["x-namespace"] = "_detail"; + $.FilesAndDirectoriesListSegment["x-namespace"] = "_detail"; + $.ListFilesAndDirectoriesSegmentResponse["x-namespace"] = "_detail"; + - from: swagger-document + where: $ + transform: > + const operations = [ + "Share_AcquireLease", + "Share_ReleaseLease", + "Share_ChangeLease", + "Share_RenewLease", + "Share_BreakLease", + "File_AcquireLease", + "File_ReleaseLease", + "File_ChangeLease", + "File_BreakLease", + "File_StartCopy", + "Directory_ForceCloseHandles", + "File_ForceCloseHandles", + ]; + for (const url in $["x-ms-paths"]) { + for (const verb in $["x-ms-paths"][url]) { + if (!operations.includes($["x-ms-paths"][url][verb].operationId)) continue; + const operation = $["x-ms-paths"][url][verb]; + + const status_codes = Object.keys(operation.responses).filter(s => s !== "default"); + status_codes.forEach((status_code, i) => { + if (!operation.responses[status_code].schema) { + const operationId = operation.operationId; + const clientName = operationId.substr(0, operationId.indexOf("_")); + const operationName = operationId.substr(operationId.indexOf("_") + 1); + let operationWords = operationName.split(/(?=[A-Z])/); + operationWords.splice(1, 0, clientName); + const defaultReturnTypeName = operationWords.join("") + "Result"; + operation.responses[status_code].schema = { + "type": "object", + "x-ms-sealed": false, + "x-ms-client-name": defaultReturnTypeName, + "x-namespace": "_detail", + "properties": { + "__placeHolder": {"type": "integer"} + } + }; + } else if (operation.responses[status_code].schema["$ref"]) { + let obj = $; + for (const p of operation.responses[status_code].schema["$ref"].split("/").slice(1)) { + obj = obj[p]; + } + obj["x-namespace"] = "_detail"; + } else { + operation.responses[status_code].schema["x-namespace"] = "_detail"; + } + }); + } + } +``` + +### Global Changes for Definitions, Types etc. + +```yaml +directive: + - from: swagger-document + where: $.parameters + transform: > + $.ListSharesInclude.items["x-ms-enum"].name = "ListSharesIncludeFlags"; + $.AccessTierOptional.enum.push("Premium"); + $.AccessTierOptional["x-ms-enum"].name = "AccessTier"; + $.AccessTierOptional["x-ms-enum"].modelAsString = false; + $.DeleteSnapshots["x-ms-enum"].name = "DeleteSnapshotsOption"; + $.DeleteSnapshots.enum = ["__placeHolder", "include"]; + $.FileCopyPermissionCopyMode["x-ms-enum"].name = "PermissionCopyMode"; + $.MaxResults["x-ms-client-name"] = "MaxResults"; + delete $.FileCreationTime.format; + delete $.FileLastWriteTime.format; + - from: swagger-document + where: $.definitions + transform: > + $.ContentRange = {"type": "object", "x-ms-format": "range", properties: {"__placeHolder" : {"type": "integer"}}}; + $.Range = $.ContentRange; + $.ClearRange = $.Range; + $.LeaseStatus["x-ms-enum"]["name"] = "LeaseStatus"; + $.LeaseState["x-ms-enum"]["name"] = "LeaseState"; + $.FileAttributes = { + "type": "string", + "x-ms-separator": " | ", + "enum": ["ReadOnly", "Hidden", "System", "None", "Directory", "Archive", "Temporary", "Offline", "NotContentIndexed", "NoScrubData"], + "x-ms-enum": { + "name": "FileAttributes", + "modelAsString": false + }, + "description": "Attributes for a file or directory." + }; + $.FileSmbProperties = { + "type": "object", + "properties": { + "PermissionKey": {"type": "string", "x-nullable": true, "description": "Permission key for the directory or file."}, + "Attributes": {"$ref": "#/definitions/FileAttributes", "description": "Attributes for the file or directory."}, + "CreatedOn": {"type": "string", "format": "date-time", "x-nullable": true, "description": "Creation time for the file or directory."}, + "LastWrittenOn": {"type": "string", "format": "date-time", "x-nullable": true, "description": "Last write time for the file or directory."}, + "ChangedOn": {"type": "string", "format": "date-time", "x-nullable": true, "description": "Changed time for the file or directory."}, + "FileId": {"type": "string", "description": "The fileId of the file."}, + "ParentFileId": {"type": "string", "description": "The parentId of the file."} + }, + "description": "The SMB related properties for the file." + }; + $.AccessTier = { + "type": "string", + "enum": ["TransactionOptimized", "Hot", "Cool", "Premium"], + "x-ms-enum": { + "name": "AccessTier", + "modelAsString": false + }, + "description": "Specifies the access tier of the share." + }; + $.Metadata = {"type": "object", "x-ms-format": "caseinsensitivemap", properties: {"__placeHolder" : {"type": "integer"}}, "description": "A set of name-value pairs associated with the share or file."}; + $.CopyStatus = { + "type": "string", + "enum": ["pending", "success", "aborted", "failed"], + "x-ms-enum": { + "name": "CopyStatus", + "modelAsString": false + }, + "description": "Status of a copy operation." + }; + $.HashAlgorithm = { + "type": "string", + "x-ms-external": true, + "x-namespace": "::Azure::Storage", + "enum": ["Md5", "Crc64"], + "x-ms-enum": { + "name": "HashAlgorithm", + "modelAsString": false + } + }; + $.ContentHash = { + "type": "object", + "x-ms-external": true, + "x-namespace": "::Azure::Storage", + "properties": { + "Value": {"type": "string", "format": "byte", "x-ms-xml": {"name": "Content-MD5"}}, + "Algorithm": {"$ref": "#/definitions/HashAlgorithm", "x-ms-xml": {"name": ""}} + } + }; + $.FileHttpHeaders = { + "type": "object", + "properties": { + "Content-Type": {"type": "string", "description": "MIME content type of the file."}, + "Content-Encoding": {"type": "string", "description": "Specifies which content encodings have been applied to the file."}, + "Content-Language": {"type": "string", "description": "Specifies the natural languages used by this file."}, + "Content-Hash": {"$ref": "#/definitions/ContentHash", "x-ms-xml": {"name": "."}, "description": "Hash of the file content."}, + "Content-Disposition": {"type": "string", "description": "Conveys additional information about how to process the resource payload, and also can be used to attach additional metadata." }, + "Cache-Control": {"type": "string", "description": "Specifies directives for caching mechanisms." } + }, + "description": "Standard HTTP properties supported files." + }; + $.SharePermission["x-namespace"] = "_detail"; + - from: swagger-document + where: $["x-ms-paths"].*.*.responses.*.headers + transform: > + for (var header in $) { + if (header === "x-ms-lease-status") { + $[header]["x-ms-enum"]["name"] = "LeaseStatus"; + } + if (header === "x-ms-lease-state") { + $[header]["x-ms-enum"]["name"] = "LeaseState"; + } + if (header === "x-ms-copy-status") { + $[header]["x-ms-enum"]["name"] = "CopyStatus"; + } + if (header === "x-ms-meta") { + $[header]["x-ms-format"] = "caseinsensitivemap"; + } + } +``` + +### GetFileServiceProperties + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + $.Metrics["type"] = "object"; + delete $.Metrics.required; + $.Metrics.properties["IncludeAPIs"]["x-ms-client-name"] = "IncludeApis"; + $.Metrics.properties["IncludeAPIs"]["x-nullable"] = true; + $.SmbSettings = $.ShareSmbSettings; + delete $.ShareSmbSettings; + $.ShareProtocolSettings.properties["Smb"]["$ref"] = "#/definitions/SmbSettings"; + $.ShareProtocolSettings.properties["Settings"] = $.ShareProtocolSettings.properties["Smb"]; + delete $.ShareProtocolSettings.properties["Smb"]; + $.ProtocolSettings = $.ShareProtocolSettings; + delete $.ShareProtocolSettings; + $.StorageServiceProperties.properties["Protocol"]["$ref"] = "#/definitions/ProtocolSettings"; + $.ShareServiceProperties = $.StorageServiceProperties; + delete $.StorageServiceProperties; + $.ShareServiceProperties.xml = { "name": "StorageServiceProperties" }; + $.ShareServiceProperties.properties["Protocol"]["x-nullable"] = true; + - from: swagger-document + where: $.parameters + transform: > + $.ShareServiceProperties = $.StorageServiceProperties; + $.ShareServiceProperties.name = "ShareServiceProperties"; + $.ShareServiceProperties.schema["$ref"] = "#/definitions/ShareServiceProperties"; + delete $.StorageServiceProperties; + - from: swagger-document + where: $["x-ms-paths"]["/?restype=service&comp=properties"] + transform: > + $.put.parameters[0]["$ref"] = "#/parameters/ShareServiceProperties"; + $.get.responses["200"].schema["$ref"] = "#/definitions/ShareServiceProperties"; +``` + +### GetShareStatistics + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + delete $.ShareStats; + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}?restype=share&comp=stats"].get.responses["200"] + transform: > + $.schema = { + "description": "Stats for the share.", + "type": "object", + "x-ms-sealed": false, + "x-ms-client-name": "ShareStatistics", + "xml": {"name": "ShareStats"}, + "properties": { + "ShareUsageBytes": { + "description": "The approximate size of the data stored in bytes. Note that this value may not include all recently created or recently resized files.", + "type": "integer", + "format": "int64", + "x-ms-client-name": "ShareUsageInBytes" + } + } + }; +``` + +### ListShares + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + $.ListSharesResponse.properties["ShareItems"]["x-ms-xml"] = {"name": "Shares"}; + $.ShareItemDetails = $.ShareProperties; + delete $.ShareProperties; + $.ShareItemDetails.properties["Quota"]["format"] = "int64"; + $.ShareItemDetails.properties["AccessTierChangeTime"]["x-ms-client-name"] = "AccessTierChangedOn"; + $.ShareItemDetails.properties["AccessTier"] = {"$ref": "#/definitions/AccessTier"}; + $.ShareItemDetails.properties["DeletedTime"]["x-ms-client-name"] = "DeletedOn"; + $.ShareItemDetails.required.push("RemainingRetentionDays", "LeaseStatus", "LeaseState", "LeaseDuration"); + $.ShareItem.properties["Details"] = {"$ref": "#/definitions/ShareItemDetails", "x-ms-xml": {"name": "Properties"}}; + delete $.ShareItem.properties["Properties"]; + delete $.ShareItem.required; +``` + +### CreateShare + +```yaml +directive: + - from: swagger-document + where: $.parameters + transform: > + $.ShareQuota["format"] = "int64"; + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}?restype=share"].put.responses["201"] + transform: > + $.schema = { + "type": "object", + "x-ms-client-name": "CreateShareResult", + "x-ms-sealed": false, + "properties": { + "Created": {"type": "boolean", "x-ms-client-default": true, "x-ms-xml": {"name": ""}, "description": "Indicates if the share was successfully created by this operation."} + } + }; +``` + +### GetShareProperties + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}?restype=share"].get.responses["200"].headers + transform: > + $["x-ms-share-quota"]["format"] = "int64"; + $["x-ms-share-provisioned-iops"]["x-nullable"] = true; + $["x-ms-share-provisioned-ingress-mbps"]["x-nullable"] = true; + $["x-ms-share-provisioned-egress-mbps"]["x-nullable"] = true; + $["x-ms-share-next-allowed-quota-downgrade-time"]["x-nullable"] = true; + $["x-ms-lease-duration"]["x-nullable"] = true; + $["x-ms-lease-state"]["x-nullable"] = true; + $["x-ms-lease-status"]["x-nullable"] = true; + $["x-ms-access-tier-change-time"]["x-nullable"] = true; + $["x-ms-access-tier-change-time"]["x-ms-client-name"] = "AccessTierChangedOn"; + $["x-ms-access-tier-transition-state"]["x-nullable"] = true; + $["x-ms-access-tier-transition-state"].description = "Returns the transition state between access tiers, when present."; + $["x-ms-share-provisioned-iops"].description = "Returns the current share provisioned IOPS."; + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}?restype=share"].get.responses["200"] + transform: > + $.schema = { + "type": "object", + "x-ms-client-name": "ShareProperties", + "x-ms-sealed": false, + "properties": { + "AccessTier": {"$ref": "#/definitions/AccessTier", "x-nullable": true, "x-ms-xml": {"name": ""}} + } + }; +``` + +### GetShareAccessPolicy + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + $.AccessPolicy.required = ["Permission"]; + $.AccessPolicy.properties["Start"]["x-ms-client-name"] = "StartsOn"; + $.AccessPolicy.properties["Expiry"]["x-ms-client-name"] = "ExpiresOn"; + $.SignedIdentifier.properties["AccessPolicy"]["x-ms-client-name"] = "Policy"; + delete $.SignedIdentifier.required; + delete $.SignedIdentifiers.items.xml; + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}?restype=share&comp=acl"].get.responses["200"] + transform: > + $.schema = { + "type": "object", + "x-ms-client-name": "ShareAccessPolicy", + "x-ms-sealed": "false", + "xml": {"name": "."}, + "properties": { + "SignedIdentifiers": {"$ref": "#/definitions/SignedIdentifiers"} + } + }; +``` + +### DeleteShare + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}?restype=share"].delete.responses["202"] + transform: > + $.schema = { + "type": "object", + "x-ms-client-name": "DeleteShareResult", + "x-ms-sealed": false, + "properties": { + "Deleted": {"type": "boolean", "x-ms-client-default": true, "x-ms-xml": {"name": ""}, "description": "Indicates if the share was successfully deleted by this operation."}, + } + }; +``` + +### ListFilesAndDirectories + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + $.ListFilesAndDirectoriesSegmentResponse.properties["Segment"]["x-ms-xml"] = {"name": "Entries"}; + $.FileItemDetails = $.FileProperty; + $.FileItemDetails.properties["Content-Length"]["x-ms-client-name"] = "FileSize"; + delete $.FileProperty; + $.FileItem.properties["Details"] = {"$ref": "#/definitions/FileItemDetails"}; + delete $.FileItem.properties["Properties"]; + delete $.FileItem.required; + $.FilesAndDirectoriesListSegment.properties["DirectoryItems"]["x-ms-xml"] = {"name": "."}; + $.FilesAndDirectoriesListSegment.properties["FileItems"]["x-ms-xml"] = {"name": "."}; + $.FileItem.properties["Details"]["x-ms-xml"] = {"name": "Properties"}; +``` + +### ListHandles + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + delete $.HandleItem.required; + $.HandleItem.properties["OpenTime"]["x-ms-client-name"] = "OpenedOn"; + $.HandleItem.properties["LastReconnectTime"]["x-ms-client-name"] = "LastReconnectedOn"; +``` + +### ForceCloseFileHandles + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=forceclosehandles"].put.responses["200"].headers + transform: > + $["x-ms-marker"]["x-ms-client-name"] = "ContinuationToken"; + $["x-ms-marker"]["x-nullable"] = true; +``` + +### ForceCloseDirectoryHandles + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}?comp=forceclosehandles"].put.responses["200"].headers + transform: > + $["x-ms-marker"]["x-ms-client-name"] = "ContinuationToken"; + $["x-ms-marker"]["x-nullable"] = true; +``` + +### CreateDirecotry + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}?restype=directory"].put.responses["201"] + transform: > + $.headers["x-ms-file-permission-key"]["x-ms-client-path"] = "SmbProperties.PermissionKey"; + $.headers["x-ms-file-attributes"]["x-ms-client-path"] = "SmbProperties.Attributes"; + $.headers["x-ms-file-creation-time"]["x-ms-client-path"] = "SmbProperties.CreatedOn"; + $.headers["x-ms-file-last-write-time"]["x-ms-client-path"] = "SmbProperties.LastWrittenOn"; + $.headers["x-ms-file-change-time"]["x-ms-client-path"] = "SmbProperties.ChangedOn"; + $.headers["x-ms-file-id"]["x-ms-client-path"] = "SmbProperties.FileId"; + $.headers["x-ms-file-parent-id"]["x-ms-client-path"] = "SmbProperties.ParentFileId"; + $.schema = { + "type": "object", + "x-ms-client-name": "CreateDirectoryResult", + "x-ms-sealed": false, + "properties": { + "Created": {"type": "boolean", "x-ms-client-default": true, "x-ms-xml": {"name": ""}, "description": "Indicates if the directory was successfully created by this operation."}, + "SmbProperties": {"$ref": "#/definitions/FileSmbProperties", "x-ms-xml": {"name": ""}} + } + }; +``` + +### DeleteDirectory + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}?restype=directory"].delete.responses["202"] + transform: > + $.schema = { + "type": "object", + "x-ms-client-name": "DeleteDirectoryResult", + "x-ms-sealed": false, + "properties": { + "Deleted": {"type": "boolean", "x-ms-client-default": true, "x-ms-xml": {"name": ""}, "description": "Indicates if the directory was successfully deleted by this operation."} + } + }; +``` + +### GetDirectoryProperties + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}?restype=directory"].get.responses["200"] + transform: > + $.headers["x-ms-file-permission-key"]["x-ms-client-path"] = "SmbProperties.PermissionKey"; + $.headers["x-ms-file-attributes"]["x-ms-client-path"] = "SmbProperties.Attributes"; + $.headers["x-ms-file-creation-time"]["x-ms-client-path"] = "SmbProperties.CreatedOn"; + $.headers["x-ms-file-last-write-time"]["x-ms-client-path"] = "SmbProperties.LastWrittenOn"; + $.headers["x-ms-file-change-time"]["x-ms-client-path"] = "SmbProperties.ChangedOn"; + $.headers["x-ms-file-id"]["x-ms-client-path"] = "SmbProperties.FileId"; + $.headers["x-ms-file-parent-id"]["x-ms-client-path"] = "SmbProperties.ParentFileId"; + $.schema = { + "type": "object", + "x-ms-client-name": "DirectoryProperties", + "x-ms-sealed": false, + "properties": { + "SmbProperties": {"$ref": "#/definitions/FileSmbProperties", "x-ms-xml": {"name": ""}} + } + }; +``` + +### SetDirectoryProperties + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}?restype=directory&comp=properties"].put.responses["200"] + transform: > + $.headers["x-ms-file-permission-key"]["x-ms-client-path"] = "SmbProperties.PermissionKey"; + $.headers["x-ms-file-attributes"]["x-ms-client-path"] = "SmbProperties.Attributes"; + $.headers["x-ms-file-creation-time"]["x-ms-client-path"] = "SmbProperties.CreatedOn"; + $.headers["x-ms-file-last-write-time"]["x-ms-client-path"] = "SmbProperties.LastWrittenOn"; + $.headers["x-ms-file-change-time"]["x-ms-client-path"] = "SmbProperties.ChangedOn"; + $.headers["x-ms-file-id"]["x-ms-client-path"] = "SmbProperties.FileId"; + $.headers["x-ms-file-parent-id"]["x-ms-client-path"] = "SmbProperties.ParentFileId"; + $.schema = { + "type": "object", + "x-ms-client-name": "SetDirectoryPropertiesResult", + "x-ms-sealed": false, + "properties": { + "SmbProperties": {"$ref": "#/definitions/FileSmbProperties", "x-ms-xml": {"name": ""}} + } + }; +``` + +### CreateFile + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}"].put.responses["201"] + transform: > + $.headers["x-ms-file-permission-key"]["x-ms-client-path"] = "SmbProperties.PermissionKey"; + $.headers["x-ms-file-attributes"]["x-ms-client-path"] = "SmbProperties.Attributes"; + $.headers["x-ms-file-creation-time"]["x-ms-client-path"] = "SmbProperties.CreatedOn"; + $.headers["x-ms-file-last-write-time"]["x-ms-client-path"] = "SmbProperties.LastWrittenOn"; + $.headers["x-ms-file-change-time"]["x-ms-client-path"] = "SmbProperties.ChangedOn"; + $.headers["x-ms-file-id"]["x-ms-client-path"] = "SmbProperties.FileId"; + $.headers["x-ms-file-parent-id"]["x-ms-client-path"] = "SmbProperties.ParentFileId"; + $.schema = { + "type": "object", + "x-ms-client-name": "CreateFileResult", + "x-ms-sealed": false, + "properties": { + "Created": {"type": "boolean", "x-ms-client-default": true, "x-ms-xml": {"name": ""}, "description": "Indicates if the file was successfully created by this operation."}, + "SmbProperties": {"$ref": "#/definitions/FileSmbProperties", "x-ms-xml": {"name": ""}} + } + }; +``` + +### GetFileProperties + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}"].head.responses["200"] + transform: > + $.headers["x-ms-file-permission-key"]["x-ms-client-path"] = "SmbProperties.PermissionKey"; + $.headers["x-ms-file-attributes"]["x-ms-client-path"] = "SmbProperties.Attributes"; + $.headers["x-ms-file-creation-time"]["x-ms-client-path"] = "SmbProperties.CreatedOn"; + $.headers["x-ms-file-last-write-time"]["x-ms-client-path"] = "SmbProperties.LastWrittenOn"; + $.headers["x-ms-file-change-time"]["x-ms-client-path"] = "SmbProperties.ChangedOn"; + $.headers["x-ms-file-id"]["x-ms-client-path"] = "SmbProperties.FileId"; + $.headers["x-ms-file-parent-id"]["x-ms-client-path"] = "SmbProperties.ParentFileId"; + $.headers["Content-Length"]["x-ms-client-name"] = "FileSize"; + $.headers["Content-Type"]["x-ms-client-path"] = "HttpHeaders.ContentType"; + $.headers["Content-Type"]["x-nullable"] = true; + $.headers["Content-Encoding"]["x-ms-client-path"] = "HttpHeaders.ContentEncoding"; + $.headers["Content-Encoding"]["x-nullable"] = true; + $.headers["Cache-Control"]["x-ms-client-path"] = "HttpHeaders.CacheControl"; + $.headers["Cache-Control"]["x-nullable"] = true; + $.headers["Content-Disposition"]["x-ms-client-path"] = "HttpHeaders.ContentDisposition"; + $.headers["Content-Disposition"]["x-nullable"] = true; + $.headers["Content-Language"]["x-ms-client-path"] = "HttpHeaders.ContentLanguage"; + $.headers["Content-Language"]["x-nullable"] = true; + $.headers["Content-MD5"]["x-ms-client-path"] = "HttpHeaders.ContentHash"; + $.headers["Content-MD5"]["x-nullable"] = true; + $.headers["x-ms-copy-completion-time"]["x-ms-client-name"] = "CopyCompletedOn"; + $.headers["x-ms-copy-completion-time"]["x-nullable"] = true; + $.headers["x-ms-copy-status-description"]["x-nullable"] = true; + $.headers["x-ms-copy-id"]["x-nullable"] = true; + $.headers["x-ms-copy-progress"]["x-nullable"] = true; + $.headers["x-ms-copy-source"]["x-nullable"] = true; + $.headers["x-ms-copy-status"]["x-nullable"] = true; + $.headers["x-ms-lease-duration"]["x-nullable"] = true; + $.headers["x-ms-lease-state"]["x-nullable"] = true; + $.headers["x-ms-lease-status"]["x-nullable"] = true; + delete $.headers["x-ms-type"]; + $.schema = { + "type": "object", + "x-ms-client-name": "FileProperties", + "x-ms-sealed": false, + "properties": { + "SmbProperties": {"$ref": "#/definitions/FileSmbProperties", "x-ms-xml": {"name": ""}}, + "HttpHeaders": {"$ref": "#/definitions/FileHttpHeaders", "x-ms-xml": {"name": ""}} + } + }; +``` + +### SetFileProperties + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=properties"].put.responses["200"] + transform: > + $.headers["x-ms-file-permission-key"]["x-ms-client-path"] = "SmbProperties.PermissionKey"; + $.headers["x-ms-file-attributes"]["x-ms-client-path"] = "SmbProperties.Attributes"; + $.headers["x-ms-file-creation-time"]["x-ms-client-path"] = "SmbProperties.CreatedOn"; + $.headers["x-ms-file-last-write-time"]["x-ms-client-path"] = "SmbProperties.LastWrittenOn"; + $.headers["x-ms-file-change-time"]["x-ms-client-path"] = "SmbProperties.ChangedOn"; + $.headers["x-ms-file-id"]["x-ms-client-path"] = "SmbProperties.FileId"; + $.headers["x-ms-file-parent-id"]["x-ms-client-path"] = "SmbProperties.ParentFileId"; + $.schema = { + "type": "object", + "x-ms-client-name": "SetFilePropertiesResult", + "x-ms-sealed": false, + "properties": { + "SmbProperties": {"$ref": "#/definitions/FileSmbProperties", "x-ms-xml": {"name": ""}} + } + }; +``` + +### DownloadFile + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + $.DownloadFileDetails = { + "type": "object", + "required": ["ETag", "LastModified", "IsServerEncrypted", "SmbProperties"], + "properties": { + "ETag": {"type": "string", "format": "etag", "description": "The ETag contains a value that you can use to perform operations conditionally. If the request version is 2011-08-18 or newer, the ETag value will be in quotes."}, + "LastModified": {"type": "string", "format": "date-time-rfc1123", "description": "Returns the date and time the file was last modified. Any operation that modifies the file, including an update of the file's metadata or properties, changes the last-modified time of the file."}, + "Metadata": {"$ref": "#/definitions/Metadata"}, + "CopyId": {"type": "string", "description": " String identifier for this copy operation. Use with Get File Properties to check the status of this copy operation, or pass to Abort Copy File to abort a pending copy."}, + "CopySource": {"type": "string", "description": "URL up to 2 KB in length that specifies the source file or file used in the last attempted Copy File operation where this file was the destination file. This header does not appear if this file has never been the destination in a Copy File operation, or if this file has been modified after a concluded Copy File operation using Set File Properties, Put File, or Put Block List."}, + "CopyStatus": {"$ref": "#/definitions/CopyStatus"}, + "CopyStatusDescription": {"type": "string", "description": "Only appears when x-ms-copy-status is failed or pending. Describes the cause of the last fatal or non-fatal copy operation failure. This header does not appear if this file has never been the destination in a Copy File operation, or if this file has been modified after a concluded Copy File operation using Set File Properties, Put File, or Put Block List"}, + "CopyProgress": {"type": "string", "description": "Contains the number of bytes copied and the total bytes in the source in the last attempted Copy File operation where this file was the destination file. Can show between 0 and Content-Length bytes copied. This header does not appear if this file has never been the destination in a Copy File operation, or if this file has been modified after a concluded Copy File operation using Set File Properties, Put File, or Put Block List"}, + "CopyCompletedOn": {"type": "string", "format": "date-time-rfc1123", "description": "Conclusion time of the last attempted Copy File operation where this file was the destination file. This value can specify the time of a completed, aborted, or failed copy attempt. This header does not appear if a copy is pending, if this file has never been the destination in a Copy File operation, or if this file has been modified after a concluded Copy File operation using Set File Properties, Put File, or Put Block List."}, + "IsServerEncrypted": {"type": "boolean", "description": "True if the file data and metadata are completely encrypted using the specified algorithm. Otherwise, the value is set to false (when the file is unencrypted, or if only parts of the file/application metadata are encrypted)."}, + "SmbProperties": {"$ref": "#/definitions/FileSmbProperties", "x-ms-xml": {"name": ""}}, + "LeaseDuration": {"$ref": "#/definitions/LeaseDuration"}, + "LeaseState": {"$ref": "#/definitions/LeaseState"}, + "LeaseStatus": {"$ref": "#/definitions/LeaseStatus"} + } + }; + $.DownloadFileResult = { + "type": "object", + "x-ms-sealed": false, + "properties": { + "BodyStream": {"type": "object", "format": "file", "description": "Content of the file or file range."}, + "ContentRange": {"$ref": "#/definitions/ContentRange", "x-ms-xml": {"name": ""}, "description": "Indicates the range of bytes returned."}, + "FileSize": {"type": "integer", "format": "int64", "x-ms-xml": {"name": ""}}, + "TransactionalContentHash": {"$ref": "#/definitions/ContentHash", "x-nullable": true, "x-ms-xml": {"name": ""}, "description": "MD5 hash for the downloaded range of data."}, + "HttpHeaders": {"$ref": "#/definitions/FileHttpHeaders", "x-ms-xml": {"name": ""}}, + "Details": {"$ref": "#/definitions/DownloadFileDetails", "x-ms-xml": {"name": ""}} + } + }; + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}"].get.responses + transform: > + for (const status_code of ["200", "206"]) { + $[status_code].headers["ETag"]["x-ms-client-path"] = "Details.ETag"; + $[status_code].headers["Last-Modified"]["x-ms-client-path"] = "Details.LastModified"; + $[status_code].headers["x-ms-meta"]["x-ms-client-path"] = "Details.Metadata"; + $[status_code].headers["Content-Type"]["x-ms-client-path"] = "HttpHeaders.ContentType"; + $[status_code].headers["Content-Type"]["x-nullable"] = true; + $[status_code].headers["Content-Encoding"]["x-ms-client-path"] = "HttpHeaders.ContentEncoding"; + $[status_code].headers["Content-Encoding"]["x-nullable"] = true; + $[status_code].headers["Cache-Control"]["x-ms-client-path"] = "HttpHeaders.CacheControl"; + $[status_code].headers["Cache-Control"]["x-nullable"] = true; + $[status_code].headers["Content-Disposition"]["x-ms-client-path"] = "HttpHeaders.ContentDisposition"; + $[status_code].headers["Content-Disposition"]["x-nullable"] = true; + $[status_code].headers["Content-Language"]["x-ms-client-path"] = "HttpHeaders.ContentLanguage"; + $[status_code].headers["Content-Language"]["x-nullable"] = true; + $[status_code].headers["x-ms-copy-completion-time"]["x-ms-client-path"] = "Details.CopyCompletedOn"; + $[status_code].headers["x-ms-copy-status-description"]["x-ms-client-path"] = "Details.CopyStatusDescription"; + $[status_code].headers["x-ms-copy-id"]["x-ms-client-path"] = "Details.CopyId"; + $[status_code].headers["x-ms-copy-progress"]["x-ms-client-path"] = "Details.CopyProgress"; + $[status_code].headers["x-ms-copy-source"]["x-ms-client-path"] = "Details.CopySource"; + $[status_code].headers["x-ms-copy-status"]["x-ms-client-path"] = "Details.CopyStatus"; + $[status_code].headers["x-ms-lease-duration"]["x-ms-client-path"] = "Details.LeaseDuration"; + $[status_code].headers["x-ms-lease-state"]["x-ms-client-path"] = "Details.LeaseState"; + $[status_code].headers["x-ms-lease-status"]["x-ms-client-path"] = "Details.LeaseStatus"; + $[status_code].headers["x-ms-server-encrypted"]["x-ms-client-path"] = "Details.IsServerEncrypted"; + $[status_code].headers["x-ms-file-permission-key"]["x-ms-client-path"] = "Details.SmbProperties.PermissionKey"; + $[status_code].headers["x-ms-file-attributes"]["x-ms-client-path"] = "Details.SmbProperties.Attributes"; + $[status_code].headers["x-ms-file-creation-time"]["x-ms-client-path"] = "Details.SmbProperties.CreatedOn"; + $[status_code].headers["x-ms-file-last-write-time"]["x-ms-client-path"] = "Details.SmbProperties.LastWrittenOn"; + $[status_code].headers["x-ms-file-change-time"]["x-ms-client-path"] = "Details.SmbProperties.ChangedOn"; + $[status_code].headers["x-ms-file-id"]["x-ms-client-path"] = "Details.SmbProperties.FileId"; + $[status_code].headers["x-ms-file-parent-id"]["x-ms-client-path"] = "Details.SmbProperties.ParentFileId"; + delete $[status_code].headers["Accept-Ranges"]; + delete $[status_code].headers["Content-Length"]; + delete $[status_code].headers["Content-Range"]; + $[status_code].schema = {"$ref": "#/definitions/DownloadFileResult"}; + } + $["200"].headers["Content-MD5"] = {"type": "string", "format": "byte", "x-ms-client-name": "TransactionalContentHash", "x-ms-client-path": "HttpHeaders.ContentHash", "x-nullable": true}; + $["206"].headers["Content-MD5"] = {"type": "string", "format": "byte", "x-ms-client-name": "TransactionalContentHash", "x-nullable": true}; + $["200"].headers["x-ms-content-md5"] = {"type": "string", "format": "byte", "x-ms-client-path": "HttpHeaders.ContentHash", "x-nullable": true}; + $["206"].headers["x-ms-content-md5"] = $["200"].headers["x-ms-content-md5"]; +``` + +### DeleteFile + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}"].delete.responses["202"] + transform: > + $.schema = { + "type": "object", + "x-ms-client-name": "DeleteFileResult", + "x-ms-sealed": false, + "properties": { + "Deleted": {"type": "boolean", "x-ms-client-default": true, "x-ms-xml": {"name": ""}, "description": "Indicates if the file was successfully deleted by this operation."} + } + }; +``` + +### UploadFileRange + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=range"].put.parameters + transform: > + for (const p of $) { + if (p["x-ms-client-name"] && p["x-ms-client-name"] === "FileRangeWrite") { + delete p["x-ms-enum"]; + delete p["enum"]; + delete p["default"]; + } + } + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=range"].put.responses["201"].headers + transform: > + $["Content-MD5"]["x-ms-client-name"] = "TransactionalContentHash"; + $["Content-MD5"]["x-ms-client-default"] = ""; + $["Content-MD5"]["x-nullable"] = true; + $["x-ms-request-server-encrypted"]["x-ms-client-default"] = false; + $["x-ms-request-server-encrypted"]["x-nullable"] = true; +``` + +### UploadFileRangeFromUri + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=range&fromURL"].put.responses["201"].headers + transform: > + $["x-ms-content-crc64"]["x-ms-client-name"] = "TransactionalContentHash"; + $["x-ms-content-crc64"]["x-ms-client-default"] = ""; + $["x-ms-content-crc64"]["x-nullable"] = true; + $["x-ms-request-server-encrypted"]["x-ms-client-default"] = false; + $["x-ms-request-server-encrypted"]["x-nullable"] = true; +``` + +### GetFileRangeList + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=rangelist"].get.responses["200"] + transform: > + $.headers["x-ms-content-length"]["x-ms-client-name"] = "FileSize"; + $.schema = { + "x-ms-client-name": "GetFileRangeListResult", + "x-ms-sealed": false, + "xml": {"name": "Ranges"}, + "type": "object", + "properties": { + "Range": { + "type": "array", + "x-ms-client-name": "Ranges", + "x-ms-xml": {"name": "."}, + "items": {"$ref": "#/definitions/Range"} + }, + "ClearRange": { + "type": "array", + "x-ms-client-name": "ClearRanges", + "x-ms-xml": {"name": "."}, + "items": {"$ref": "#/definitions/ClearRange"} + } + } + }; +``` + +### BreakFileLease + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=lease&break"].put.responses["202"].headers + transform: > + delete $["x-ms-lease-id"]; +``` \ No newline at end of file diff --git a/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.PremiumShare.json b/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.PremiumShare.json index 8890bb9ce..42244c13e 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.PremiumShare.json +++ b/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.PremiumShare.json @@ -2,8 +2,8 @@ "networkCallRecords": [ { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "0711a2aa-ae9e-42ca-754f-3301bb67cdc5", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "7578973b-1466-4073-7dd0-4d0805c4bf24", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -12,20 +12,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:44 GMT", - "etag": "\"0x8D9CF33032861AF\"", - "last-modified": "Tue, 04 Jan 2022 03:33:45 GMT", + "date": "Fri, 25 Feb 2022 09:37:12 GMT", + "etag": "\"0x8D9F84266BCB14B\"", + "last-modified": "Fri, 25 Feb 2022 09:37:12 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "0711a2aa-ae9e-42ca-754f-3301bb67cdc5", - "x-ms-request-id": "c5e663a6-d01a-003f-031b-0177a4000000", + "x-ms-client-request-id": "7578973b-1466-4073-7dd0-4d0805c4bf24", + "x-ms-request-id": "185c5f07-e01a-003c-622b-2af305000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestpremiumshare?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "44427081-fc2b-4a60-7281-4515b8c3e0fa", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "d05b4197-b142-4d5c-44d4-27c1fd4a532a", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -34,20 +34,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:44 GMT", - "etag": "\"0x8D9CF330334F600\"", - "last-modified": "Tue, 04 Jan 2022 03:33:45 GMT", + "date": "Fri, 25 Feb 2022 09:37:13 GMT", + "etag": "\"0x8D9F842677996FF\"", + "last-modified": "Fri, 25 Feb 2022 09:37:13 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "44427081-fc2b-4a60-7281-4515b8c3e0fa", - "x-ms-request-id": "987a41c4-c01a-001a-521b-013839000000", + "x-ms-client-request-id": "d05b4197-b142-4d5c-44d4-27c1fd4a532a", + "x-ms-request-id": "61aed4d1-401a-0059-052b-2ade65000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/premiumshare?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "0ff6e30d-2d61-4bd4-76f7-69f08bc4544f", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "baf0fbc5-e307-4e85-4515-9dfc00d32773", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -56,19 +56,19 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:44 GMT", - "etag": "\"0x8D9CF330334F600\"", - "last-modified": "Tue, 04 Jan 2022 03:33:45 GMT", + "date": "Fri, 25 Feb 2022 09:37:14 GMT", + "etag": "\"0x8D9F842677996FF\"", + "last-modified": "Fri, 25 Feb 2022 09:37:13 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", "x-ms-access-tier": "Premium", - "x-ms-client-request-id": "0ff6e30d-2d61-4bd4-76f7-69f08bc4544f", + "x-ms-client-request-id": "baf0fbc5-e307-4e85-4515-9dfc00d32773", "x-ms-enabled-protocols": "SMB", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", "x-ms-lease-status": "unlocked", - "x-ms-request-id": "987a41ca-c01a-001a-531b-013839000000", - "x-ms-share-next-allowed-quota-downgrade-time": "Tue, 04 Jan 2022 03:33:45 GMT", + "x-ms-request-id": "da56bb13-f01a-005c-422b-2a0cbe000000", + "x-ms-share-next-allowed-quota-downgrade-time": "Fri, 25 Feb 2022 09:37:13 GMT", "x-ms-share-provisioned-egress-mbps": "110", "x-ms-share-provisioned-ingress-mbps": "110", "x-ms-share-provisioned-iops": "3100", @@ -79,95 +79,95 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "aab72950-72cc-4a4c-439b-191246d97093", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "6b7e87b5-05e9-48dc-40dd-bfb66f501495", "x-ms-version": "2020-02-10" }, "Method": "GET", "Response": { - "BODY": "premiumsharepremiumshareTue, 04 Jan 2022 03:33:45 GMT\"0x8D9CF330334F600\"unlockedavailable100SMBPremium3100110110Tue, 04 Jan 2022 03:33:45 GMT$account-encryption-keyfalse", + "BODY": "premiumsharepremiumshareFri, 25 Feb 2022 09:37:13 GMT\"0x8D9F842677996FF\"unlockedavailable100SMBPremium3100110110Fri, 25 Feb 2022 09:37:13 GMT$account-encryption-keyfalse", "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-type": "application/xml", - "date": "Tue, 04 Jan 2022 03:33:44 GMT", + "date": "Fri, 25 Feb 2022 09:37:15 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", "transfer-encoding": "chunked", - "x-ms-client-request-id": "aab72950-72cc-4a4c-439b-191246d97093", - "x-ms-request-id": "987a41cc-c01a-001a-541b-013839000000", + "x-ms-client-request-id": "6b7e87b5-05e9-48dc-40dd-bfb66f501495", + "x-ms-request-id": "9b7e8b0e-c01a-009c-322b-2af480000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net?comp=list&prefix=premiumshare" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "5bf701a8-3a47-4e1a-4f62-e1eb4988e673", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "f76fa7c6-636f-48ff-42ec-e5e9bb4c94d4", "x-ms-version": "2020-02-10" }, "Method": "PUT", "Response": { - "BODY": "InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format.\nRequestId:987a41ce-c01a-001a-551b-013839000000\nTime:2022-01-04T03:33:45.4069855Zx-ms-access-tierHot", + "BODY": "InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format.\nRequestId:ff9ff323-301a-00c5-462b-2a7303000000\nTime:2022-02-25T09:37:17.0122004Zx-ms-access-tierHot", "REASON_PHRASE": "The value for one of the HTTP headers is not in the correct format.", "STATUS_CODE": "400", "content-length": "325", "content-type": "application/xml", - "date": "Tue, 04 Jan 2022 03:33:44 GMT", + "date": "Fri, 25 Feb 2022 09:37:16 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "5bf701a8-3a47-4e1a-4f62-e1eb4988e673", + "x-ms-client-request-id": "f76fa7c6-636f-48ff-42ec-e5e9bb4c94d4", "x-ms-error-code": "InvalidHeaderValue", - "x-ms-request-id": "987a41ce-c01a-001a-551b-013839000000", + "x-ms-request-id": "ff9ff323-301a-00c5-462b-2a7303000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/premiumshare?comp=properties&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "3b8efb2d-3334-4184-49e2-e196cba57d0f", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "c4bb8d41-6d36-448a-799f-244fc932bcad", "x-ms-version": "2020-02-10" }, "Method": "PUT", "Response": { - "BODY": "InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format.\nRequestId:c7d64aae-901a-00e3-3f1b-013b1b000000\nTime:2022-01-04T03:33:45.4437987Zx-ms-access-tierCool", + "BODY": "InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format.\nRequestId:01dca1be-b01a-0062-4b2b-2a9bc1000000\nTime:2022-02-25T09:37:18.1177573Zx-ms-access-tierCool", "REASON_PHRASE": "The value for one of the HTTP headers is not in the correct format.", "STATUS_CODE": "400", "content-length": "326", "content-type": "application/xml", - "date": "Tue, 04 Jan 2022 03:33:44 GMT", + "date": "Fri, 25 Feb 2022 09:37:17 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "3b8efb2d-3334-4184-49e2-e196cba57d0f", + "x-ms-client-request-id": "c4bb8d41-6d36-448a-799f-244fc932bcad", "x-ms-error-code": "InvalidHeaderValue", - "x-ms-request-id": "c7d64aae-901a-00e3-3f1b-013b1b000000", + "x-ms-request-id": "01dca1be-b01a-0062-4b2b-2a9bc1000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/premiumshare?comp=properties&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "22834a79-f9da-4abe-5c41-02afc060b019", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "d23cf134-4906-445e-625d-c34b21131650", "x-ms-version": "2020-02-10" }, "Method": "PUT", "Response": { - "BODY": "InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format.\nRequestId:692a80d6-201a-00e6-7c1b-01e9c0000000\nTime:2022-01-04T03:33:45.4851608Zx-ms-access-tierTransactionOptimized", + "BODY": "InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format.\nRequestId:f3cdb96f-e01a-008b-5f2b-2a5d8b000000\nTime:2022-02-25T09:37:19.1856618Zx-ms-access-tierTransactionOptimized", "REASON_PHRASE": "The value for one of the HTTP headers is not in the correct format.", "STATUS_CODE": "400", "content-length": "342", "content-type": "application/xml", - "date": "Tue, 04 Jan 2022 03:33:45 GMT", + "date": "Fri, 25 Feb 2022 09:37:18 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "22834a79-f9da-4abe-5c41-02afc060b019", + "x-ms-client-request-id": "d23cf134-4906-445e-625d-c34b21131650", "x-ms-error-code": "InvalidHeaderValue", - "x-ms-request-id": "692a80d6-201a-00e6-7c1b-01e9c0000000", + "x-ms-request-id": "f3cdb96f-e01a-008b-5f2b-2a5d8b000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/premiumshare?comp=properties&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "41342f02-4d86-488b-5cb4-5501ff50332c", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "ed077086-1073-4051-7c3c-5ae3dca33ba4", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -176,20 +176,20 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:45 GMT", - "etag": "\"0x8D9CF33034CAF5F\"", - "last-modified": "Tue, 04 Jan 2022 03:33:45 GMT", + "date": "Fri, 25 Feb 2022 09:37:20 GMT", + "etag": "\"0x8D9F8426B5895E9\"", + "last-modified": "Fri, 25 Feb 2022 09:37:20 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "41342f02-4d86-488b-5cb4-5501ff50332c", - "x-ms-request-id": "12dc2c61-001a-010a-5e1b-01035c000000", + "x-ms-client-request-id": "ed077086-1073-4051-7c3c-5ae3dca33ba4", + "x-ms-request-id": "04df7bb3-701a-001f-3a2b-2aeae2000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/premiumshare?comp=properties&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "628ebb8e-96f6-4bea-73e9-a15fbe2d6bca", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "13de348f-7f41-4526-4668-cf9b1c273d81", "x-ms-version": "2020-02-10" }, "Method": "DELETE", @@ -198,10 +198,30 @@ "REASON_PHRASE": "Accepted", "STATUS_CODE": "202", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:45 GMT", + "date": "Fri, 25 Feb 2022 09:37:20 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "628ebb8e-96f6-4bea-73e9-a15fbe2d6bca", - "x-ms-request-id": "c5e663a9-d01a-003f-041b-0177a4000000", + "x-ms-client-request-id": "13de348f-7f41-4526-4668-cf9b1c273d81", + "x-ms-request-id": "7d4642bc-401a-0076-402b-2ad3ae000000", + "x-ms-version": "2020-02-10" + }, + "Url": "https://REDACTED.file.core.windows.net/premiumshare?restype=share" + }, + { + "Headers": { + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "d29d41fb-cad2-4af8-7b44-7ddc461da6d6", + "x-ms-version": "2020-02-10" + }, + "Method": "DELETE", + "Response": { + "BODY": "", + "REASON_PHRASE": "Accepted", + "STATUS_CODE": "202", + "content-length": "0", + "date": "Fri, 25 Feb 2022 09:37:22 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "d29d41fb-cad2-4af8-7b44-7ddc461da6d6", + "x-ms-request-id": "eaddb71a-d01a-007a-092b-2ac782000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestpremiumshare?restype=share" diff --git a/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareMetadata.json b/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareMetadata.json index dd7acbdf0..12bb4a63d 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareMetadata.json +++ b/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareMetadata.json @@ -2,8 +2,8 @@ "networkCallRecords": [ { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "295b7880-3ca9-41a1-4da3-6ea8cda3e358", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "e62c1e61-e4a1-4c42-6ed6-5af5baf5fb70", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -12,20 +12,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F2951BBC\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:15 GMT", + "etag": "\"0x8D9F84221100989\"", + "last-modified": "Fri, 25 Feb 2022 09:35:15 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "295b7880-3ca9-41a1-4da3-6ea8cda3e358", - "x-ms-request-id": "8ff3dfce-c01a-006e-451b-01ea28000000", + "x-ms-client-request-id": "e62c1e61-e4a1-4c42-6ed6-5af5baf5fb70", + "x-ms-request-id": "ccee356c-f01a-0042-722a-2a6342000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestsharemetadata?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "616c01bb-66e1-431e-4ebd-f289f522ee70", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "773648d7-9b14-4abd-5733-0c336fcff0bd", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -34,20 +34,20 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F29A56E9\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:16 GMT", + "etag": "\"0x8D9F84221B7AA64\"", + "last-modified": "Fri, 25 Feb 2022 09:35:16 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "616c01bb-66e1-431e-4ebd-f289f522ee70", - "x-ms-request-id": "8ff3dfd1-c01a-006e-461b-01ea28000000", + "x-ms-client-request-id": "773648d7-9b14-4abd-5733-0c336fcff0bd", + "x-ms-request-id": "547a731e-701a-002e-542a-2a88d5000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestsharemetadata?comp=metadata&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "95c27344-12d3-4a11-57da-8eeef53662de", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "5fb67b30-0e48-45d1-5988-c688ee42c820", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -56,13 +56,14 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F29A56E9\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:16 GMT", + "etag": "\"0x8D9F84221B7AA64\"", + "last-modified": "Fri, 25 Feb 2022 09:35:16 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:17 GMT", - "x-ms-client-request-id": "95c27344-12d3-4a11-57da-8eeef53662de", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:35:15 GMT", + "x-ms-client-request-id": "5fb67b30-0e48-45d1-5988-c688ee42c820", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", @@ -72,7 +73,7 @@ "x-ms-meta-meta2": "value", "x-ms-meta-meta3": "value", "x-ms-meta-meta4": "value", - "x-ms-request-id": "8ff3dfd2-c01a-006e-471b-01ea28000000", + "x-ms-request-id": "c18ef70f-901a-006b-2c2a-2a5d36000000", "x-ms-share-quota": "5120", "x-ms-version": "2020-02-10" }, @@ -80,8 +81,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "055f1adc-961d-484c-7b3f-8f17b8ed0efa", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "9441c599-a70f-428d-50dd-6f18c3f42051", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -90,20 +91,20 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F29D3CAC\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:20 GMT", + "etag": "\"0x8D9F84223D273A3\"", + "last-modified": "Fri, 25 Feb 2022 09:35:20 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "055f1adc-961d-484c-7b3f-8f17b8ed0efa", - "x-ms-request-id": "8ff3dfd3-c01a-006e-481b-01ea28000000", + "x-ms-client-request-id": "9441c599-a70f-428d-50dd-6f18c3f42051", + "x-ms-request-id": "11f8c10d-201a-000c-382b-2a4dca000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestsharemetadata?comp=metadata&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "e38fd482-e2ea-4f74-49b4-ac7e2e3ea013", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "7217bee2-42f7-4761-47ce-fa8f4f303b33", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -112,13 +113,14 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F29D3CAC\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:20 GMT", + "etag": "\"0x8D9F84223D273A3\"", + "last-modified": "Fri, 25 Feb 2022 09:35:20 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:17 GMT", - "x-ms-client-request-id": "e38fd482-e2ea-4f74-49b4-ac7e2e3ea013", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:35:15 GMT", + "x-ms-client-request-id": "7217bee2-42f7-4761-47ce-fa8f4f303b33", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", @@ -128,7 +130,7 @@ "x-ms-meta-meta2": "value", "x-ms-meta-meta3": "value", "x-ms-meta-meta4": "value", - "x-ms-request-id": "8ff3dfd4-c01a-006e-491b-01ea28000000", + "x-ms-request-id": "8653f46c-201a-007e-4c2b-2a4a85000000", "x-ms-share-quota": "5120", "x-ms-version": "2020-02-10" }, @@ -136,8 +138,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "ba18f280-6072-482c-4dfb-4903c82f85d3", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "57552b53-ddca-4168-73df-c15e142cbda5", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -146,20 +148,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F2A03DAE\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:21 GMT", + "etag": "\"0x8D9F84224FCE54D\"", + "last-modified": "Fri, 25 Feb 2022 09:35:22 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "ba18f280-6072-482c-4dfb-4903c82f85d3", - "x-ms-request-id": "8ff3dfd5-c01a-006e-4a1b-01ea28000000", + "x-ms-client-request-id": "57552b53-ddca-4168-73df-c15e142cbda5", + "x-ms-request-id": "17a9267c-901a-0019-4b2b-2a5a79000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/sharemetadata1?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "eece654a-eb70-4fdb-520b-94bb1c4682c7", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "8c460df5-62ae-4642-53f8-94eddd8f378d", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -168,20 +170,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F2A28744\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:22 GMT", + "etag": "\"0x8D9F84225A149A0\"", + "last-modified": "Fri, 25 Feb 2022 09:35:23 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "eece654a-eb70-4fdb-520b-94bb1c4682c7", - "x-ms-request-id": "8ff3dfd7-c01a-006e-4b1b-01ea28000000", + "x-ms-client-request-id": "8c460df5-62ae-4642-53f8-94eddd8f378d", + "x-ms-request-id": "3cd7720d-101a-0028-642b-2abb6a000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/sharemetadata2?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "02c390ba-2309-446b-4c17-814d3daf8cc0", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "204dd409-c086-4b6f-5ec9-45f0f9358158", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -190,13 +192,14 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F2A03DAE\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:23 GMT", + "etag": "\"0x8D9F84224FCE54D\"", + "last-modified": "Fri, 25 Feb 2022 09:35:22 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:17 GMT", - "x-ms-client-request-id": "02c390ba-2309-446b-4c17-814d3daf8cc0", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:35:22 GMT", + "x-ms-client-request-id": "204dd409-c086-4b6f-5ec9-45f0f9358158", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", @@ -206,7 +209,7 @@ "x-ms-meta-meta2": "value", "x-ms-meta-meta3": "value", "x-ms-meta-meta4": "value", - "x-ms-request-id": "8ff3dfd9-c01a-006e-4c1b-01ea28000000", + "x-ms-request-id": "11299ac6-401a-0068-212b-2abc52000000", "x-ms-share-quota": "5120", "x-ms-version": "2020-02-10" }, @@ -214,8 +217,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "4da3a5a0-7cc6-4cb0-4278-cb53e97c6c20", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "8d329a02-798a-4a88-6ddb-96d92e4f9e4c", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -224,13 +227,14 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", - "etag": "\"0x8D9CF32F2A28744\"", - "last-modified": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:25 GMT", + "etag": "\"0x8D9F84225A149A0\"", + "last-modified": "Fri, 25 Feb 2022 09:35:23 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:17 GMT", - "x-ms-client-request-id": "4da3a5a0-7cc6-4cb0-4278-cb53e97c6c20", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:35:23 GMT", + "x-ms-client-request-id": "8d329a02-798a-4a88-6ddb-96d92e4f9e4c", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", @@ -240,7 +244,7 @@ "x-ms-meta-meta2": "value", "x-ms-meta-meta3": "value", "x-ms-meta-meta4": "value", - "x-ms-request-id": "8ff3dfda-c01a-006e-4d1b-01ea28000000", + "x-ms-request-id": "88876d84-101a-0065-1e2b-2a7486000000", "x-ms-share-quota": "5120", "x-ms-version": "2020-02-10" }, @@ -248,8 +252,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "73a21a9e-ab11-40b0-6075-fb4fc7a334fa", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "479064df-fa3b-4e2b-44fd-227862f6a28a", "x-ms-version": "2020-02-10" }, "Method": "DELETE", @@ -258,10 +262,50 @@ "REASON_PHRASE": "Accepted", "STATUS_CODE": "202", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:17 GMT", + "date": "Fri, 25 Feb 2022 09:35:26 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "73a21a9e-ab11-40b0-6075-fb4fc7a334fa", - "x-ms-request-id": "8ff3dfdb-c01a-006e-4e1b-01ea28000000", + "x-ms-client-request-id": "479064df-fa3b-4e2b-44fd-227862f6a28a", + "x-ms-request-id": "79f68ac6-c01a-0082-2a2b-2a9b7c000000", + "x-ms-version": "2020-02-10" + }, + "Url": "https://REDACTED.file.core.windows.net/sharemetadata1?restype=share" + }, + { + "Headers": { + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "4f5a6223-b131-4cd3-4486-185503719859", + "x-ms-version": "2020-02-10" + }, + "Method": "DELETE", + "Response": { + "BODY": "", + "REASON_PHRASE": "Accepted", + "STATUS_CODE": "202", + "content-length": "0", + "date": "Fri, 25 Feb 2022 09:35:26 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4f5a6223-b131-4cd3-4486-185503719859", + "x-ms-request-id": "185c5db5-e01a-003c-232b-2af305000000", + "x-ms-version": "2020-02-10" + }, + "Url": "https://REDACTED.file.core.windows.net/sharemetadata2?restype=share" + }, + { + "Headers": { + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "cf15dbbb-5b67-439d-7ee7-ebd4933ff0d7", + "x-ms-version": "2020-02-10" + }, + "Method": "DELETE", + "Response": { + "BODY": "", + "REASON_PHRASE": "Accepted", + "STATUS_CODE": "202", + "content-length": "0", + "date": "Fri, 25 Feb 2022 09:35:27 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "cf15dbbb-5b67-439d-7ee7-ebd4933ff0d7", + "x-ms-request-id": "a4e7bf1a-a01a-003d-702b-2aacd9000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestsharemetadata?restype=share" diff --git a/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareProperties.json b/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareProperties.json index c30bad653..a92a76b4a 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareProperties.json +++ b/sdk/storage/azure-storage-files-shares/test/ut/recordings/FileShareClientTest.ShareProperties.json @@ -2,8 +2,8 @@ "networkCallRecords": [ { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "82ff9877-8813-4253-7f94-adb4f02edd89", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "9b5d8c1a-5290-40e8-4151-9fd91b4d4034", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -12,20 +12,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F6EB1335\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:35:56 GMT", + "etag": "\"0x8D9F84239465905\"", + "last-modified": "Fri, 25 Feb 2022 09:35:56 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "82ff9877-8813-4253-7f94-adb4f02edd89", - "x-ms-request-id": "d4bc312e-601a-0048-271b-01a230000000", + "x-ms-client-request-id": "9b5d8c1a-5290-40e8-4151-9fd91b4d4034", + "x-ms-request-id": "7be8b293-a01a-004f-492b-2aab96000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "d4b3c6b4-f6fa-42a7-77dc-03c328a5b5ed", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "2707df9c-d561-4cae-48c7-a4134a1a356e", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -34,20 +34,20 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F6F71A92\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:35:56 GMT", + "etag": "\"0x8D9F84239D8B835\"", + "last-modified": "Fri, 25 Feb 2022 09:35:57 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "d4b3c6b4-f6fa-42a7-77dc-03c328a5b5ed", - "x-ms-request-id": "d4bc3131-601a-0048-281b-01a230000000", + "x-ms-client-request-id": "2707df9c-d561-4cae-48c7-a4134a1a356e", + "x-ms-request-id": "36716902-c01a-0049-312b-2a9829000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?comp=properties&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "08da48e3-5588-488e-4927-c97b0ea7162f", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "a1507114-1631-4391-6dd8-e5a4afd57339", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -56,18 +56,19 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F6F71A92\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:35:57 GMT", + "etag": "\"0x8D9F84239D8B835\"", + "last-modified": "Fri, 25 Feb 2022 09:35:57 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:24 GMT", - "x-ms-client-request-id": "08da48e3-5588-488e-4927-c97b0ea7162f", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:35:56 GMT", + "x-ms-client-request-id": "a1507114-1631-4391-6dd8-e5a4afd57339", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", "x-ms-lease-status": "unlocked", - "x-ms-request-id": "d4bc3132-601a-0048-291b-01a230000000", + "x-ms-request-id": "beef454d-901a-007b-712b-2a985e000000", "x-ms-share-quota": "32", "x-ms-version": "2020-02-10" }, @@ -75,8 +76,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "454932da-b709-4aeb-64ae-1b8a687fd82d", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "f995689a-e346-442b-6928-9f0d7a39982e", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -85,20 +86,20 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F6FB86B9\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:35:58 GMT", + "etag": "\"0x8D9F8423AF91956\"", + "last-modified": "Fri, 25 Feb 2022 09:35:59 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "454932da-b709-4aeb-64ae-1b8a687fd82d", - "x-ms-request-id": "d4bc3133-601a-0048-2a1b-01a230000000", + "x-ms-client-request-id": "f995689a-e346-442b-6928-9f0d7a39982e", + "x-ms-request-id": "44b0bd05-501a-005b-7f2b-2ae3f9000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?comp=properties&restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "f34fd70a-30e3-4ca9-651b-79490be32ee4", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "efdd8b6b-7d74-4c30-4569-653513ea3b6d", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -107,18 +108,19 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F6FB86B9\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:35:59 GMT", + "etag": "\"0x8D9F8423AF91956\"", + "last-modified": "Fri, 25 Feb 2022 09:35:59 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:24 GMT", - "x-ms-client-request-id": "f34fd70a-30e3-4ca9-651b-79490be32ee4", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:35:56 GMT", + "x-ms-client-request-id": "efdd8b6b-7d74-4c30-4569-653513ea3b6d", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", "x-ms-lease-status": "unlocked", - "x-ms-request-id": "d4bc3134-601a-0048-2b1b-01a230000000", + "x-ms-request-id": "37c319b5-e01a-0085-242b-2af71f000000", "x-ms-share-quota": "64", "x-ms-version": "2020-02-10" }, @@ -126,8 +128,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "adb5dc84-043a-4313-547d-647a72ef8841", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "5f47a121-4c32-45ac-492b-a8be97e7a5ce", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -136,20 +138,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F6FE4A4A\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:36:00 GMT", + "etag": "\"0x8D9F8423C25CE3B\"", + "last-modified": "Fri, 25 Feb 2022 09:36:01 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "adb5dc84-043a-4313-547d-647a72ef8841", - "x-ms-request-id": "d4bc3135-601a-0048-2c1b-01a230000000", + "x-ms-client-request-id": "5f47a121-4c32-45ac-492b-a8be97e7a5ce", + "x-ms-request-id": "3af7be6f-b01a-0053-7f2b-2af9f6000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/shareproperties1?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "28081b0b-db2f-4c9e-6ac3-8ce8a73f7c00", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "54346be5-5724-4092-504e-3f921a6277b6", "x-ms-version": "2020-02-10" }, "Method": "PUT", @@ -158,20 +160,20 @@ "REASON_PHRASE": "Created", "STATUS_CODE": "201", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F7006CDA\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:36:01 GMT", + "etag": "\"0x8D9F8423CC45560\"", + "last-modified": "Fri, 25 Feb 2022 09:36:02 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "28081b0b-db2f-4c9e-6ac3-8ce8a73f7c00", - "x-ms-request-id": "d4bc3137-601a-0048-2d1b-01a230000000", + "x-ms-client-request-id": "54346be5-5724-4092-504e-3f921a6277b6", + "x-ms-request-id": "700c3ba8-401a-0047-5e2b-2ab199000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/shareproperties2?restype=share" }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "7eb40cff-8be6-4980-5425-db1a6ade2d95", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "0fbebd58-6fac-438e-55e6-1aec77d0325b", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -180,18 +182,19 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F6FE4A4A\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:36:02 GMT", + "etag": "\"0x8D9F8423C25CE3B\"", + "last-modified": "Fri, 25 Feb 2022 09:36:01 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:24 GMT", - "x-ms-client-request-id": "7eb40cff-8be6-4980-5425-db1a6ade2d95", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:36:01 GMT", + "x-ms-client-request-id": "0fbebd58-6fac-438e-55e6-1aec77d0325b", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", "x-ms-lease-status": "unlocked", - "x-ms-request-id": "d4bc3139-601a-0048-2e1b-01a230000000", + "x-ms-request-id": "9d5cea07-a01a-0070-1f2b-2a6335000000", "x-ms-share-quota": "32", "x-ms-version": "2020-02-10" }, @@ -199,8 +202,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "ae9ec301-2b21-42aa-672f-4d27c31913c7", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "b9003bd5-e880-4d0d-6c0c-a20c82a7fec2", "x-ms-version": "2020-02-10" }, "Method": "GET", @@ -209,18 +212,19 @@ "REASON_PHRASE": "OK", "STATUS_CODE": "200", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F7006CDA\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:36:04 GMT", + "etag": "\"0x8D9F8423CC45560\"", + "last-modified": "Fri, 25 Feb 2022 09:36:02 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:24 GMT", - "x-ms-client-request-id": "ae9ec301-2b21-42aa-672f-4d27c31913c7", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:36:02 GMT", + "x-ms-client-request-id": "b9003bd5-e880-4d0d-6c0c-a20c82a7fec2", "x-ms-has-immutability-policy": "false", "x-ms-has-legal-hold": "false", "x-ms-lease-state": "available", "x-ms-lease-status": "unlocked", - "x-ms-request-id": "d4bc313a-601a-0048-2f1b-01a230000000", + "x-ms-request-id": "f3f5dc89-f01a-0030-4d2b-2a640d000000", "x-ms-share-quota": "64", "x-ms-version": "2020-02-10" }, @@ -228,59 +232,8 @@ }, { "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "463c2a7c-e835-4a16-47c3-843306c3a234", - "x-ms-version": "2020-02-10" - }, - "Method": "PUT", - "Response": { - "BODY": "", - "REASON_PHRASE": "OK", - "STATUS_CODE": "200", - "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F7052244\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", - "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "463c2a7c-e835-4a16-47c3-843306c3a234", - "x-ms-request-id": "d4bc313b-601a-0048-301b-01a230000000", - "x-ms-version": "2020-02-10" - }, - "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?comp=properties&restype=share" - }, - { - "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "315c3e92-739b-456c-4402-941965e33139", - "x-ms-version": "2020-02-10" - }, - "Method": "GET", - "Response": { - "BODY": "", - "REASON_PHRASE": "OK", - "STATUS_CODE": "200", - "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", - "etag": "\"0x8D9CF32F7052244\"", - "last-modified": "Tue, 04 Jan 2022 03:33:24 GMT", - "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-access-tier": "TransactionOptimized", - "x-ms-access-tier-change-time": "Tue, 04 Jan 2022 03:33:24 GMT", - "x-ms-client-request-id": "315c3e92-739b-456c-4402-941965e33139", - "x-ms-has-immutability-policy": "false", - "x-ms-has-legal-hold": "false", - "x-ms-lease-state": "available", - "x-ms-lease-status": "unlocked", - "x-ms-request-id": "d4bc313c-601a-0048-311b-01a230000000", - "x-ms-share-quota": "5120", - "x-ms-version": "2020-02-10" - }, - "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?restype=share" - }, - { - "Headers": { - "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Linux 5.4.0-1063-azure x86_64 #66~18.04.1-Ubuntu SMP Thu Oct 21 09:59:28 UTC 2021)", - "x-ms-client-request-id": "d36affcc-0d5f-49c6-6e8d-e85fa0e98ced", + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "ea53e474-37e3-47f2-4fdb-372b6147835e", "x-ms-version": "2020-02-10" }, "Method": "DELETE", @@ -289,10 +242,102 @@ "REASON_PHRASE": "Accepted", "STATUS_CODE": "202", "content-length": "0", - "date": "Tue, 04 Jan 2022 03:33:24 GMT", + "date": "Fri, 25 Feb 2022 09:36:04 GMT", "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", - "x-ms-client-request-id": "d36affcc-0d5f-49c6-6e8d-e85fa0e98ced", - "x-ms-request-id": "d4bc313d-601a-0048-321b-01a230000000", + "x-ms-client-request-id": "ea53e474-37e3-47f2-4fdb-372b6147835e", + "x-ms-request-id": "a2aaf8bf-301a-0096-3d2b-2ad313000000", + "x-ms-version": "2020-02-10" + }, + "Url": "https://REDACTED.file.core.windows.net/shareproperties1?restype=share" + }, + { + "Headers": { + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "5602210b-28a7-4baf-6a8c-2a5420e3054b", + "x-ms-version": "2020-02-10" + }, + "Method": "DELETE", + "Response": { + "BODY": "", + "REASON_PHRASE": "Accepted", + "STATUS_CODE": "202", + "content-length": "0", + "date": "Fri, 25 Feb 2022 09:36:05 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "5602210b-28a7-4baf-6a8c-2a5420e3054b", + "x-ms-request-id": "d28347b7-d01a-0027-562b-2acd06000000", + "x-ms-version": "2020-02-10" + }, + "Url": "https://REDACTED.file.core.windows.net/shareproperties2?restype=share" + }, + { + "Headers": { + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "c91f2b17-4c67-4087-4c44-5c22633eaa97", + "x-ms-version": "2020-02-10" + }, + "Method": "PUT", + "Response": { + "BODY": "", + "REASON_PHRASE": "OK", + "STATUS_CODE": "200", + "content-length": "0", + "date": "Fri, 25 Feb 2022 09:36:06 GMT", + "etag": "\"0x8D9F8423FDA3C1D\"", + "last-modified": "Fri, 25 Feb 2022 09:36:07 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "c91f2b17-4c67-4087-4c44-5c22633eaa97", + "x-ms-request-id": "f827a746-801a-0058-242b-2a029d000000", + "x-ms-version": "2020-02-10" + }, + "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?comp=properties&restype=share" + }, + { + "Headers": { + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "7c75d26d-78cc-4f75-4648-afff8c5e37af", + "x-ms-version": "2020-02-10" + }, + "Method": "GET", + "Response": { + "BODY": "", + "REASON_PHRASE": "OK", + "STATUS_CODE": "200", + "content-length": "0", + "date": "Fri, 25 Feb 2022 09:36:07 GMT", + "etag": "\"0x8D9F8423FDA3C1D\"", + "last-modified": "Fri, 25 Feb 2022 09:36:07 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "vary": "Origin", + "x-ms-access-tier": "TransactionOptimized", + "x-ms-access-tier-change-time": "Fri, 25 Feb 2022 09:35:56 GMT", + "x-ms-client-request-id": "7c75d26d-78cc-4f75-4648-afff8c5e37af", + "x-ms-has-immutability-policy": "false", + "x-ms-has-legal-hold": "false", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-request-id": "32baddbd-901a-0009-452b-2a9f11000000", + "x-ms-share-quota": "5120", + "x-ms-version": "2020-02-10" + }, + "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?restype=share" + }, + { + "Headers": { + "user-agent": "azsdk-cpp-storage-files-shares/12.3.0-beta.1 (Windows 10 Pro 6.3 19041 19041.1.amd64fre.vb_release.191206-1406)", + "x-ms-client-request-id": "4dbd7392-40c7-4c54-6e11-8e3419d00f93", + "x-ms-version": "2020-02-10" + }, + "Method": "DELETE", + "Response": { + "BODY": "", + "REASON_PHRASE": "Accepted", + "STATUS_CODE": "202", + "content-length": "0", + "date": "Fri, 25 Feb 2022 09:36:08 GMT", + "server": "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0", + "x-ms-client-request-id": "4dbd7392-40c7-4c54-6e11-8e3419d00f93", + "x-ms-request-id": "a4fcf515-701a-0011-162b-2a4076000000", "x-ms-version": "2020-02-10" }, "Url": "https://REDACTED.file.core.windows.net/fileshareclienttestshareproperties?restype=share" diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp index 5e04f754c..d1dbeeb9b 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -39,7 +40,7 @@ namespace Azure { namespace Storage { namespace Test { m_shareClient = std::make_shared( Files::Shares::ShareClient::CreateFromConnectionString( StandardStorageConnectionString(), m_shareName, m_options)); - m_shareClient->Create(); + m_shareClient->CreateIfNotExists(); } void FileShareClientTest::TearDown() @@ -155,6 +156,8 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(metadata1, result); result = client2.GetProperties().Value.Metadata; EXPECT_EQ(metadata2, result); + client1.DeleteIfExists(); + client2.DeleteIfExists(); } } @@ -195,6 +198,8 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(quota32GB, result); result = client2.GetProperties().Value.Quota; EXPECT_EQ(quota64GB, result); + client1.DeleteIfExists(); + client2.DeleteIfExists(); } { @@ -501,18 +506,15 @@ namespace Azure { namespace Storage { namespace Test { { EXPECT_NE(shareClients.find(shareItem.Name), shareClients.end()); properties = shareClients.at(shareItem.Name).GetProperties().Value; - EXPECT_EQ(true, shareItem.Details.AccessTier.HasValue() && properties.AccessTier.HasValue()); + ASSERT_TRUE(shareItem.Details.AccessTier.HasValue()); + ASSERT_TRUE(properties.AccessTier.HasValue()); EXPECT_EQ(shareItem.Details.AccessTier.Value(), properties.AccessTier.Value()); - EXPECT_EQ( - true, - shareItem.Details.AccessTierChangedOn.HasValue() - && properties.AccessTierChangedOn.HasValue()); + ASSERT_TRUE(shareItem.Details.AccessTierChangedOn.HasValue()); + ASSERT_TRUE(properties.AccessTierChangedOn.HasValue()); EXPECT_EQ( shareItem.Details.AccessTierChangedOn.Value(), properties.AccessTierChangedOn.Value()); - EXPECT_EQ( - false, - shareItem.Details.AccessTierTransitionState.HasValue() - || properties.AccessTierTransitionState.HasValue()); + EXPECT_FALSE(shareItem.Details.AccessTierTransitionState.HasValue()); + EXPECT_FALSE(properties.AccessTierTransitionState.HasValue()); } } @@ -556,5 +558,6 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(Files::Shares::Models::AccessTier::Premium, properties.AccessTier.Value()); EXPECT_FALSE(properties.AccessTierTransitionState.HasValue()); EXPECT_FALSE(properties.AccessTierChangedOn.HasValue()); + shareClient.DeleteIfExists(); } }}} // namespace Azure::Storage::Test diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp index 176e84377..69f2c4eac 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_file_attributes_test.cpp @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include - #include "test/ut/test_base.hpp" +#include "azure/storage/files/shares/rest_client.hpp" + namespace Azure { namespace Storage { namespace Test { TEST(ShareFileAttributes, EqualOperator)