| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.ComponentModel; |
| | 7 | | using System.IO; |
| | 8 | |
|
| | 9 | | namespace Azure.Storage.Files.DataLake.Models |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// DataLakeModelFactory provides utilities for mocking. |
| | 13 | | /// </summary> |
| | 14 | | public static partial class DataLakeModelFactory |
| | 15 | | { |
| | 16 | | #region FileDownloadDetails |
| | 17 | | /// <summary> |
| | 18 | | /// Creates a new <see cref="FileDownloadDetails"/> instance for mocking. |
| | 19 | | /// </summary> |
| | 20 | | public static FileDownloadDetails FileDownloadDetails( |
| | 21 | | DateTimeOffset lastModified, |
| | 22 | | IDictionary<string, string> metadata, |
| | 23 | | string contentRange, |
| | 24 | | ETag eTag, |
| | 25 | | string contentEncoding, |
| | 26 | | string cacheControl, |
| | 27 | | string contentDisposition, |
| | 28 | | string contentLanguage, |
| | 29 | | DateTimeOffset copyCompletionTime, |
| | 30 | | string copyStatusDescription, |
| | 31 | | string copyId, |
| | 32 | | string copyProgress, |
| | 33 | | Uri copySource, |
| | 34 | | CopyStatus copyStatus, |
| | 35 | | DataLakeLeaseDuration leaseDuration, |
| | 36 | | DataLakeLeaseState leaseState, |
| | 37 | | DataLakeLeaseStatus leaseStatus, |
| | 38 | | string acceptRanges, |
| | 39 | | bool isServerEncrypted, |
| | 40 | | string encryptionKeySha256, |
| | 41 | | byte[] contentHash) |
| 0 | 42 | | => new FileDownloadDetails() |
| 0 | 43 | | { |
| 0 | 44 | | LastModified = lastModified, |
| 0 | 45 | | Metadata = metadata, |
| 0 | 46 | | ContentRange = contentRange, |
| 0 | 47 | | ETag = eTag, |
| 0 | 48 | | ContentEncoding = contentEncoding, |
| 0 | 49 | | CacheControl = cacheControl, |
| 0 | 50 | | ContentDisposition = contentDisposition, |
| 0 | 51 | | ContentLanguage = contentLanguage, |
| 0 | 52 | | CopyCompletedOn = copyCompletionTime, |
| 0 | 53 | | CopyStatusDescription = copyStatusDescription, |
| 0 | 54 | | CopyId = copyId, |
| 0 | 55 | | CopyProgress = copyProgress, |
| 0 | 56 | | CopySource = copySource, |
| 0 | 57 | | CopyStatus = copyStatus, |
| 0 | 58 | | LeaseDuration = leaseDuration, |
| 0 | 59 | | LeaseState = leaseState, |
| 0 | 60 | | LeaseStatus = leaseStatus, |
| 0 | 61 | | AcceptRanges = acceptRanges, |
| 0 | 62 | | IsServerEncrypted = isServerEncrypted, |
| 0 | 63 | | EncryptionKeySha256 = encryptionKeySha256, |
| 0 | 64 | | ContentHash = contentHash |
| 0 | 65 | | }; |
| | 66 | | #endregion FileDownloadDetails |
| | 67 | |
|
| | 68 | | #region FileDownloadInfo |
| | 69 | | /// <summary> |
| | 70 | | /// Creates a new <see cref="FileDownloadInfo"/> instance for mocking. |
| | 71 | | /// </summary> |
| | 72 | | public static FileDownloadInfo FileDownloadInfo( |
| | 73 | | long contentLength, |
| | 74 | | Stream content, |
| | 75 | | byte[] contentHash, |
| | 76 | | FileDownloadDetails properties) |
| 0 | 77 | | => new FileDownloadInfo() |
| 0 | 78 | | { |
| 0 | 79 | | ContentLength = contentLength, |
| 0 | 80 | | Content = content, |
| 0 | 81 | | ContentHash = contentHash, |
| 0 | 82 | | Properties = properties |
| 0 | 83 | | }; |
| | 84 | | #endregion FileDownloadInfo |
| | 85 | |
|
| | 86 | | #region FileSystemInfo |
| | 87 | | /// <summary> |
| | 88 | | /// Creates a new <see cref="FileSystemInfo"/> instance for mocking. |
| | 89 | | /// </summary> |
| | 90 | | public static FileSystemInfo FileSystemInfo( |
| | 91 | | ETag etag, |
| | 92 | | DateTimeOffset lastModified) |
| 0 | 93 | | => new FileSystemInfo() |
| 0 | 94 | | { |
| 0 | 95 | | ETag = etag, |
| 0 | 96 | | LastModified = lastModified |
| 0 | 97 | | }; |
| | 98 | | #endregion FileSystemInfo |
| | 99 | |
|
| | 100 | | #region FileSystemItem |
| | 101 | | /// <summary> |
| | 102 | | /// Creates a new <see cref="FileSystemItem"/> instance for mocking. |
| | 103 | | /// </summary> |
| | 104 | | public static FileSystemItem FileSystemItem( |
| | 105 | | string name, |
| | 106 | | FileSystemProperties properties) |
| 0 | 107 | | => new FileSystemItem() |
| 0 | 108 | | { |
| 0 | 109 | | Name = name, |
| 0 | 110 | | Properties = properties |
| 0 | 111 | | }; |
| | 112 | | #endregion FileSystemItem |
| | 113 | |
|
| | 114 | | #region FileSystemProperties |
| | 115 | | /// <summary> |
| | 116 | | /// Creates a new <see cref="FileSystemProperties"/> instance for mocking. |
| | 117 | | /// </summary> |
| | 118 | | public static FileSystemProperties FileSystemProperties( |
| | 119 | | DateTimeOffset lastModified, |
| | 120 | | DataLakeLeaseStatus? leaseStatus, |
| | 121 | | DataLakeLeaseState? leaseState, |
| | 122 | | DataLakeLeaseDuration? leaseDuration, |
| | 123 | | PublicAccessType? publicAccess, |
| | 124 | | bool? hasImmutabilityPolicy, |
| | 125 | | bool? hasLegalHold, |
| | 126 | | ETag eTag) |
| 0 | 127 | | => new FileSystemProperties() |
| 0 | 128 | | { |
| 0 | 129 | | LastModified = lastModified, |
| 0 | 130 | | LeaseStatus = leaseStatus, |
| 0 | 131 | | LeaseState = leaseState, |
| 0 | 132 | | LeaseDuration = leaseDuration, |
| 0 | 133 | | PublicAccess = publicAccess, |
| 0 | 134 | | HasImmutabilityPolicy = hasImmutabilityPolicy, |
| 0 | 135 | | HasLegalHold = hasLegalHold, |
| 0 | 136 | | ETag = eTag |
| 0 | 137 | | }; |
| | 138 | | #endregion FileSystemProperties |
| | 139 | |
|
| | 140 | | #region Lease |
| | 141 | | /// <summary> |
| | 142 | | /// Creates a new <see cref="DataLakeLease"/> instance for mocking. |
| | 143 | | /// </summary> |
| | 144 | | public static DataLakeLease Lease( |
| | 145 | | ETag eTag, |
| | 146 | | DateTimeOffset lastModified, |
| | 147 | | string leaseId, |
| | 148 | | int? leaseTime) |
| 0 | 149 | | => new DataLakeLease() |
| 0 | 150 | | { |
| 0 | 151 | | ETag = eTag, |
| 0 | 152 | | LastModified = lastModified, |
| 0 | 153 | | LeaseId = leaseId, |
| 0 | 154 | | LeaseTime = leaseTime |
| 0 | 155 | | }; |
| | 156 | | #endregion Lease |
| | 157 | |
|
| | 158 | | #region PathAccessControl |
| | 159 | | /// <summary> |
| | 160 | | /// Creates a new <see cref="PathAccessControl"/> instance for mocking. |
| | 161 | | /// </summary> |
| | 162 | | public static PathAccessControl PathAccessControl( |
| | 163 | | string owner, |
| | 164 | | string group, |
| | 165 | | PathPermissions permissions, |
| | 166 | | IList<PathAccessControlItem> acl) |
| 0 | 167 | | => new PathAccessControl() |
| 0 | 168 | | { |
| 0 | 169 | | Owner = owner, |
| 0 | 170 | | Group = group, |
| 0 | 171 | | Permissions = permissions, |
| 0 | 172 | | AccessControlList = acl |
| 0 | 173 | | }; |
| | 174 | | #endregion PathAccessControl |
| | 175 | |
|
| | 176 | | #region PathContentInfo |
| | 177 | | /// <summary> |
| | 178 | | /// Creates a new <see cref="PathContentInfo"/> instance for mocking. |
| | 179 | | /// </summary> |
| | 180 | | public static PathContentInfo PathContentInfo( |
| | 181 | | string contentHash, |
| | 182 | | ETag eTag, |
| | 183 | | DateTimeOffset lastModified, |
| | 184 | | string acceptRanges, |
| | 185 | | string cacheControl, |
| | 186 | | string contentDisposition, |
| | 187 | | string contentEncoding, |
| | 188 | | string contentLanguage, |
| | 189 | | long contentLength, |
| | 190 | | string contentRange, |
| | 191 | | string contentType, |
| | 192 | | IDictionary<string, string> metadata) |
| 0 | 193 | | => new PathContentInfo() |
| 0 | 194 | | { |
| 0 | 195 | | ContentHash = contentHash, |
| 0 | 196 | | ETag = eTag, |
| 0 | 197 | | LastModified = lastModified, |
| 0 | 198 | | AcceptRanges = acceptRanges, |
| 0 | 199 | | CacheControl = cacheControl, |
| 0 | 200 | | ContentDisposition = contentDisposition, |
| 0 | 201 | | ContentEncoding = contentEncoding, |
| 0 | 202 | | ContentLanguage = contentLanguage, |
| 0 | 203 | | ContentLength = contentLength, |
| 0 | 204 | | ContentRange = contentRange, |
| 0 | 205 | | ContentType = contentType, |
| 0 | 206 | | Metadata = metadata |
| 0 | 207 | | }; |
| | 208 | | #endregion PathContentInfo |
| | 209 | |
|
| | 210 | | #region PathCreateInfo |
| | 211 | | /// <summary> |
| | 212 | | /// Creates a new <see cref="PathCreateInfo"/> instance for mocking. |
| | 213 | | /// </summary> |
| | 214 | | public static PathCreateInfo PathCreateInfo( |
| | 215 | | PathInfo pathInfo, |
| | 216 | | string continuation) |
| 0 | 217 | | => new PathCreateInfo() |
| 0 | 218 | | { |
| 0 | 219 | | PathInfo = pathInfo, |
| 0 | 220 | | Continuation = continuation |
| 0 | 221 | | }; |
| | 222 | | #endregion PathCreateInfo |
| | 223 | |
|
| | 224 | | #region PathInfo |
| | 225 | | /// <summary> |
| | 226 | | /// Creates a new <see cref="PathInfo"/> instance for mocking. |
| | 227 | | /// </summary> |
| | 228 | | public static PathInfo PathInfo( |
| | 229 | | ETag eTag, |
| | 230 | | DateTimeOffset lastModified) |
| 0 | 231 | | => new PathInfo() |
| 0 | 232 | | { |
| 0 | 233 | | ETag = eTag, |
| 0 | 234 | | LastModified = lastModified |
| 0 | 235 | | }; |
| | 236 | | #endregion PathInfo |
| | 237 | |
|
| | 238 | | #region PathItem |
| | 239 | | /// <summary> |
| | 240 | | /// Creates a new <see cref="PathItem"/> instance for mocking. |
| | 241 | | /// </summary> |
| | 242 | | public static PathItem PathItem( |
| | 243 | | string name, |
| | 244 | | bool? isDirectory, |
| | 245 | | DateTimeOffset lastModified, |
| | 246 | | ETag eTag, |
| | 247 | | long? contentLength, |
| | 248 | | string owner, |
| | 249 | | string group, |
| | 250 | | string permissions) |
| 0 | 251 | | => new PathItem() |
| 0 | 252 | | { |
| 0 | 253 | | Name = name, |
| 0 | 254 | | IsDirectory = isDirectory, |
| 0 | 255 | | LastModified = lastModified, |
| 0 | 256 | | ETag = eTag, |
| 0 | 257 | | ContentLength = contentLength, |
| 0 | 258 | | Owner = owner, |
| 0 | 259 | | Group = group, |
| 0 | 260 | | Permissions = permissions |
| 0 | 261 | | }; |
| | 262 | | #endregion PathItem |
| | 263 | |
|
| | 264 | | #region PathProperties |
| | 265 | | /// <summary> |
| | 266 | | /// Creates a new PathProperties instance for mocking. |
| | 267 | | /// </summary> |
| | 268 | | public static PathProperties PathProperties( |
| | 269 | | DateTimeOffset lastModified, |
| | 270 | | DateTimeOffset creationTime, |
| | 271 | | IDictionary<string, string> metadata, |
| | 272 | | DateTimeOffset copyCompletionTime, |
| | 273 | | string copyStatusDescription, |
| | 274 | | string copyId, |
| | 275 | | string copyProgress, |
| | 276 | | Uri copySource, |
| | 277 | | CopyStatus copyStatus, |
| | 278 | | bool isIncrementalCopy, |
| | 279 | | DataLakeLeaseDuration leaseDuration, |
| | 280 | | DataLakeLeaseState leaseState, |
| | 281 | | DataLakeLeaseStatus leaseStatus, |
| | 282 | | long contentLength, |
| | 283 | | string contentType, |
| | 284 | | ETag eTag, |
| | 285 | | byte[] contentHash, |
| | 286 | | string contentEncoding, |
| | 287 | | string contentDisposition, |
| | 288 | | string contentLanguage, |
| | 289 | | string cacheControl, |
| | 290 | | string acceptRanges, |
| | 291 | | bool isServerEncrypted, |
| | 292 | | string encryptionKeySha256, |
| | 293 | | string accessTier, |
| | 294 | | string archiveStatus, |
| | 295 | | DateTimeOffset accessTierChangeTime, |
| | 296 | | bool isDirectory) |
| 0 | 297 | | => new PathProperties() |
| 0 | 298 | | { |
| 0 | 299 | | LastModified = lastModified, |
| 0 | 300 | | CreatedOn = creationTime, |
| 0 | 301 | | Metadata = metadata, |
| 0 | 302 | | CopyCompletedOn = copyCompletionTime, |
| 0 | 303 | | CopyStatusDescription = copyStatusDescription, |
| 0 | 304 | | CopyId = copyId, |
| 0 | 305 | | CopyProgress = copyProgress, |
| 0 | 306 | | CopySource = copySource, |
| 0 | 307 | | CopyStatus = copyStatus, |
| 0 | 308 | | IsIncrementalCopy = isIncrementalCopy, |
| 0 | 309 | | LeaseDuration = leaseDuration, |
| 0 | 310 | | LeaseState = leaseState, |
| 0 | 311 | | LeaseStatus = leaseStatus, |
| 0 | 312 | | ContentLength = contentLength, |
| 0 | 313 | | ContentType = contentType, |
| 0 | 314 | | ETag = eTag, |
| 0 | 315 | | ContentHash = contentHash, |
| 0 | 316 | | ContentEncoding = contentEncoding, |
| 0 | 317 | | ContentDisposition = contentDisposition, |
| 0 | 318 | | ContentLanguage = contentLanguage, |
| 0 | 319 | | CacheControl = cacheControl, |
| 0 | 320 | | AcceptRanges = acceptRanges, |
| 0 | 321 | | IsServerEncrypted = isServerEncrypted, |
| 0 | 322 | | EncryptionKeySha256 = encryptionKeySha256, |
| 0 | 323 | | AccessTier = accessTier, |
| 0 | 324 | | ArchiveStatus = archiveStatus, |
| 0 | 325 | | AccessTierChangedOn = accessTierChangeTime, |
| 0 | 326 | | IsDirectory = isDirectory |
| 0 | 327 | | }; |
| | 328 | |
|
| | 329 | | /// <summary> |
| | 330 | | /// Creates a new PathProperties instance for mocking. |
| | 331 | | /// </summary> |
| | 332 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 333 | | public static PathProperties PathProperties( |
| | 334 | | DateTimeOffset lastModified, |
| | 335 | | DateTimeOffset creationTime, |
| | 336 | | IDictionary<string, string> metadata, |
| | 337 | | DateTimeOffset copyCompletionTime, |
| | 338 | | string copyStatusDescription, |
| | 339 | | string copyId, |
| | 340 | | string copyProgress, |
| | 341 | | Uri copySource, |
| | 342 | | CopyStatus copyStatus, |
| | 343 | | bool isIncrementalCopy, |
| | 344 | | DataLakeLeaseDuration leaseDuration, |
| | 345 | | DataLakeLeaseState leaseState, |
| | 346 | | DataLakeLeaseStatus leaseStatus, |
| | 347 | | long contentLength, |
| | 348 | | string contentType, |
| | 349 | | ETag eTag, |
| | 350 | | byte[] contentHash, |
| | 351 | | string contentEncoding, |
| | 352 | | string contentDisposition, |
| | 353 | | string contentLanguage, |
| | 354 | | string cacheControl, |
| | 355 | | string acceptRanges, |
| | 356 | | bool isServerEncrypted, |
| | 357 | | string encryptionKeySha256, |
| | 358 | | string accessTier, |
| | 359 | | string archiveStatus, |
| | 360 | | DateTimeOffset accessTierChangeTime) |
| 0 | 361 | | => new PathProperties() |
| 0 | 362 | | { |
| 0 | 363 | | LastModified = lastModified, |
| 0 | 364 | | CreatedOn = creationTime, |
| 0 | 365 | | Metadata = metadata, |
| 0 | 366 | | CopyCompletedOn = copyCompletionTime, |
| 0 | 367 | | CopyStatusDescription = copyStatusDescription, |
| 0 | 368 | | CopyId = copyId, |
| 0 | 369 | | CopyProgress = copyProgress, |
| 0 | 370 | | CopySource = copySource, |
| 0 | 371 | | CopyStatus = copyStatus, |
| 0 | 372 | | IsIncrementalCopy = isIncrementalCopy, |
| 0 | 373 | | LeaseDuration = leaseDuration, |
| 0 | 374 | | LeaseState = leaseState, |
| 0 | 375 | | LeaseStatus = leaseStatus, |
| 0 | 376 | | ContentLength = contentLength, |
| 0 | 377 | | ContentType = contentType, |
| 0 | 378 | | ETag = eTag, |
| 0 | 379 | | ContentHash = contentHash, |
| 0 | 380 | | ContentEncoding = contentEncoding, |
| 0 | 381 | | ContentDisposition = contentDisposition, |
| 0 | 382 | | ContentLanguage = contentLanguage, |
| 0 | 383 | | CacheControl = cacheControl, |
| 0 | 384 | | AcceptRanges = acceptRanges, |
| 0 | 385 | | IsServerEncrypted = isServerEncrypted, |
| 0 | 386 | | EncryptionKeySha256 = encryptionKeySha256, |
| 0 | 387 | | AccessTier = accessTier, |
| 0 | 388 | | ArchiveStatus = archiveStatus, |
| 0 | 389 | | AccessTierChangedOn = accessTierChangeTime |
| 0 | 390 | | }; |
| | 391 | | #endregion PathProperties |
| | 392 | |
|
| | 393 | | #region UserDelegationKey |
| | 394 | | /// <summary> |
| | 395 | | /// Creates a new <see cref="UserDelegationKey"/> instance for mocking. |
| | 396 | | /// </summary> |
| | 397 | | public static UserDelegationKey UserDelegationKey( |
| | 398 | | string signedObjectId, |
| | 399 | | string signedTenantId, |
| | 400 | | DateTimeOffset signedStart, |
| | 401 | | DateTimeOffset signedExpiry, |
| | 402 | | string signedService, |
| | 403 | | string signedVersion, |
| | 404 | | string value) |
| 0 | 405 | | => new UserDelegationKey() |
| 0 | 406 | | { |
| 0 | 407 | | SignedObjectId = signedObjectId, |
| 0 | 408 | | SignedTenantId = signedTenantId, |
| 0 | 409 | | SignedStartsOn = signedStart, |
| 0 | 410 | | SignedExpiresOn = signedExpiry, |
| 0 | 411 | | SignedService = signedService, |
| 0 | 412 | | SignedVersion = signedVersion, |
| 0 | 413 | | Value = value |
| 0 | 414 | | }; |
| | 415 | | #endregion UserDelegationKey |
| | 416 | |
|
| | 417 | | #region DataLakeQueryError |
| | 418 | | /// <summary> |
| | 419 | | /// Creates a new BlobQueryError instance for mocking. |
| | 420 | | /// </summary> |
| | 421 | | public static DataLakeQueryError DataLakeQueryError( |
| | 422 | | string name = default, |
| | 423 | | string description = default, |
| | 424 | | bool isFatal = default, |
| | 425 | | long position = default) |
| 0 | 426 | | => new DataLakeQueryError |
| 0 | 427 | | { |
| 0 | 428 | | Name = name, |
| 0 | 429 | | Description = description, |
| 0 | 430 | | IsFatal = isFatal, |
| 0 | 431 | | Position = position |
| 0 | 432 | | }; |
| | 433 | | #endregion DataLakeQueryError |
| | 434 | | } |
| | 435 | | } |