| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | |
|
| | 7 | | #pragma warning disable SA1402 // File may only contain a single type |
| | 8 | |
|
| | 9 | | namespace Azure.Storage.Files.Shares.Models |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Details returned when downloading a File |
| | 13 | | /// </summary> |
| | 14 | | public partial class ShareFileDownloadDetails |
| | 15 | | { |
| | 16 | | /// <summary> |
| | 17 | | /// Internal flattened property representation |
| | 18 | | /// </summary> |
| | 19 | | internal FlattenedStorageFileProperties _flattened; |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Returns the date and time the file was last modified. Any operation that modifies the file or its properties |
| | 23 | | /// </summary> |
| 2 | 24 | | public DateTimeOffset LastModified => _flattened.LastModified; |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// A set of name-value pairs associated with this file as user-defined metadata. |
| | 28 | | /// </summary> |
| 2 | 29 | | public IDictionary<string, string> Metadata => _flattened.Metadata; |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Indicates the range of bytes returned if the client requested a subset of the file by setting the Range requ |
| | 33 | | /// </summary> |
| 0 | 34 | | public string ContentRange => _flattened.ContentRange; |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// The ETag contains a value that you can use to perform operations conditionally, in quotes. |
| | 38 | | /// </summary> |
| 4 | 39 | | public ETag ETag => _flattened.ETag; |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Returns the value that was specified for the Content-Encoding request header. |
| | 43 | | /// </summary> |
| 2 | 44 | | public IEnumerable<string> ContentEncoding => _flattened.ContentEncoding; |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Returned if it was previously specified for the file. |
| | 48 | | /// </summary> |
| 2 | 49 | | public string CacheControl => _flattened.CacheControl; |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Returns the value that was specified for the 'x-ms-content-disposition' header and specifies how to process |
| | 53 | | /// </summary> |
| 2 | 54 | | public string ContentDisposition => _flattened.ContentDisposition; |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Returns the value that was specified for the Content-Language request header. |
| | 58 | | /// </summary> |
| 2 | 59 | | public IEnumerable<string> ContentLanguage => _flattened.ContentLanguage; |
| | 60 | |
|
| | 61 | | /// <summary> |
| | 62 | | /// Indicates that the service supports requests for partial file content. |
| | 63 | | /// </summary> |
| 0 | 64 | | public string AcceptRanges => _flattened.AcceptRanges; |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Conclusion time of the last attempted Copy File operation where this file was the destination file. This val |
| | 68 | | /// </summary> |
| 2 | 69 | | public DateTimeOffset CopyCompletedOn => _flattened.CopyCompletionTime; |
| | 70 | |
|
| | 71 | | /// <summary> |
| | 72 | | /// Only appears when x-ms-copy-status is failed or pending. Describes cause of fatal or non-fatal copy operatio |
| | 73 | | /// </summary> |
| 2 | 74 | | public string CopyStatusDescription => _flattened.CopyStatusDescription; |
| | 75 | |
|
| | 76 | | /// <summary> |
| | 77 | | /// String identifier for the last attempted Copy File operation where this file was the destination file. |
| | 78 | | /// </summary> |
| 2 | 79 | | public string CopyId => _flattened.CopyId; |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// Contains the number of bytes copied and the total bytes in the source in the last attempted Copy File operat |
| | 83 | | /// </summary> |
| 2 | 84 | | public string CopyProgress => _flattened.CopyProgress; |
| | 85 | |
|
| | 86 | | /// <summary> |
| | 87 | | /// URL up to 2KB in length that specifies the source file used in the last attempted Copy File operation where |
| | 88 | | /// </summary> |
| 2 | 89 | | public Uri CopySource => _flattened.CopySource; |
| | 90 | |
|
| | 91 | | /// <summary> |
| | 92 | | /// State of the copy operation identified by 'x-ms-copy-id'. |
| | 93 | | /// </summary> |
| 2 | 94 | | public CopyStatus CopyStatus => _flattened.CopyStatus; |
| | 95 | |
|
| | 96 | | /// <summary> |
| | 97 | | /// If the file has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header |
| | 98 | | /// </summary> |
| | 99 | | #pragma warning disable CA1819 // Properties should not return arrays |
| 0 | 100 | | public byte[] FileContentHash => _flattened.FileContentHash; |
| | 101 | | #pragma warning restore CA1819 // Properties should not return arrays |
| | 102 | |
|
| | 103 | | /// <summary> |
| | 104 | | /// The value of this header is set to true if the file data and application metadata are completely encrypted u |
| | 105 | | /// </summary> |
| 2 | 106 | | public bool IsServerEncrypted => _flattened.IsServerEncrypted; |
| | 107 | |
|
| | 108 | |
|
| | 109 | | /// <summary> |
| | 110 | | /// When a file is leased, specifies whether the lease is of infinite or fixed duration. |
| | 111 | | /// </summary> |
| 2 | 112 | | public ShareLeaseDuration LeaseDuration => _flattened.LeaseDuration; |
| | 113 | |
|
| | 114 | | /// <summary> |
| | 115 | | /// Lease state of the file. |
| | 116 | | /// </summary> |
| 2 | 117 | | public ShareLeaseState LeaseState => _flattened.LeaseState; |
| | 118 | |
|
| | 119 | | /// <summary> |
| | 120 | | /// The current lease status of the file. |
| | 121 | | /// </summary> |
| 2 | 122 | | public ShareLeaseStatus LeaseStatus => _flattened.LeaseStatus; |
| | 123 | |
|
| | 124 | | /// <summary> |
| | 125 | | /// The SMB properties for the file |
| | 126 | | /// </summary> |
| 63 | 127 | | public FileSmbProperties SmbProperties { get; set; } |
| | 128 | |
|
| 61 | 129 | | internal ShareFileDownloadDetails(FlattenedStorageFileProperties flattened) |
| | 130 | | { |
| 61 | 131 | | _flattened = flattened; |
| 61 | 132 | | SmbProperties = new FileSmbProperties(flattened); |
| 61 | 133 | | } |
| | 134 | | } |
| | 135 | |
|
| | 136 | | /// <summary> |
| | 137 | | /// FilesModelFactory provides utilities for mocking. |
| | 138 | | /// </summary> |
| | 139 | | public static partial class FilesModelFactory |
| | 140 | | { |
| | 141 | | /// <summary> |
| | 142 | | /// Creates a new StorageFileDownloadProperties instance for mocking. |
| | 143 | | /// </summary> |
| | 144 | | public static ShareFileDownloadDetails StorageFileDownloadProperties( |
| | 145 | | DateTimeOffset lastModified, |
| | 146 | | IDictionary<string, string> metadata, |
| | 147 | | string contentType, |
| | 148 | | string contentRange, |
| | 149 | | ETag eTag, |
| | 150 | | IEnumerable<string> contentEncoding, |
| | 151 | | string cacheControl, |
| | 152 | | string contentDisposition, |
| | 153 | | IEnumerable<string> contentLanguage, |
| | 154 | | string acceptRanges, |
| | 155 | | DateTimeOffset copyCompletedOn, |
| | 156 | | string copyStatusDescription, |
| | 157 | | string copyId, |
| | 158 | | string copyProgress, |
| | 159 | | Uri copySource, |
| | 160 | | CopyStatus copyStatus, |
| | 161 | | byte[] fileContentHash, |
| | 162 | | bool isServiceEncrypted) |
| | 163 | | { |
| | 164 | | var flattened = new FlattenedStorageFileProperties() |
| | 165 | | { |
| | 166 | | LastModified = lastModified, |
| | 167 | | Metadata = metadata, |
| | 168 | | ContentType = contentType, |
| | 169 | | ContentRange = contentRange, |
| | 170 | | ETag = eTag, |
| | 171 | | ContentEncoding = contentEncoding, |
| | 172 | | CacheControl = cacheControl, |
| | 173 | | ContentDisposition = contentDisposition, |
| | 174 | | ContentLanguage = contentLanguage, |
| | 175 | | AcceptRanges = acceptRanges, |
| | 176 | | CopyCompletionTime = copyCompletedOn, |
| | 177 | | CopyStatusDescription = copyStatusDescription, |
| | 178 | | CopyId = copyId, |
| | 179 | | CopyProgress = copyProgress, |
| | 180 | | CopySource = copySource, |
| | 181 | | CopyStatus = copyStatus, |
| | 182 | | FileContentHash = fileContentHash, |
| | 183 | | IsServerEncrypted = isServiceEncrypted |
| | 184 | | }; |
| | 185 | | return new ShareFileDownloadDetails(flattened); |
| | 186 | | } |
| | 187 | | } |
| | 188 | | } |