| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Text; |
| | 5 | |
|
| | 6 | | namespace Azure.Storage.Files.DataLake.Models |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Specifies lease access conditions for a file system or path. |
| | 10 | | /// </summary> |
| | 11 | | public class DataLakeRequestConditions : RequestConditions |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Optionally limit requests to resources with an active lease |
| | 15 | | /// matching this Id. |
| | 16 | | /// </summary> |
| 3542 | 17 | | public string LeaseId { get; set; } |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Converts the value of the current RequestConditions object to |
| | 21 | | /// its equivalent string representation. |
| | 22 | | /// </summary> |
| | 23 | | /// <returns> |
| | 24 | | /// A string representation of the RequestConditions. |
| | 25 | | /// </returns> |
| | 26 | | public override string ToString() |
| | 27 | | { |
| 0 | 28 | | StringBuilder conditions = new StringBuilder(); |
| 0 | 29 | | conditions.Append('[').Append(GetType().Name); |
| 0 | 30 | | AddConditions(conditions); |
| 0 | 31 | | if (conditions[conditions.Length - 1] == ';') |
| | 32 | | { |
| 0 | 33 | | conditions[conditions.Length - 1] = ']'; |
| | 34 | | } |
| | 35 | | else |
| | 36 | | { |
| 0 | 37 | | conditions.Append(']'); |
| | 38 | | } |
| 0 | 39 | | return conditions.ToString(); |
| | 40 | | } |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// Collect any request conditions. Conditions should be separated by |
| | 44 | | /// a semicolon. |
| | 45 | | /// </summary> |
| | 46 | | /// <param name="conditions">The collected conditions.</param> |
| | 47 | | internal virtual void AddConditions(StringBuilder conditions) |
| | 48 | | { |
| 0 | 49 | | if (IfMatch != null) |
| | 50 | | { |
| 0 | 51 | | conditions.Append(nameof(IfMatch)).Append('=').Append(IfMatch).Append(';'); |
| | 52 | | } |
| | 53 | |
|
| 0 | 54 | | if (IfNoneMatch != null) |
| | 55 | | { |
| 0 | 56 | | conditions.Append(nameof(IfNoneMatch)).Append('=').Append(IfNoneMatch).Append(';'); |
| | 57 | | } |
| | 58 | |
|
| 0 | 59 | | if (IfModifiedSince != null) |
| | 60 | | { |
| 0 | 61 | | conditions.Append(nameof(IfModifiedSince)).Append('=').Append(IfModifiedSince).Append(';'); |
| | 62 | | } |
| | 63 | |
|
| 0 | 64 | | if (IfUnmodifiedSince != null) |
| | 65 | | { |
| 0 | 66 | | conditions.Append(nameof(IfUnmodifiedSince)).Append('=').Append(IfUnmodifiedSince).Append(';'); |
| | 67 | | } |
| | 68 | |
|
| 0 | 69 | | if (LeaseId != null) |
| | 70 | | { |
| 0 | 71 | | conditions.Append(nameof(LeaseId)).Append('=').Append(LeaseId).Append(';'); |
| | 72 | | } |
| 0 | 73 | | } |
| | 74 | | } |
| | 75 | | } |