| | | 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.Threading; |
| | | 8 | | using System.Threading.Tasks; |
| | | 9 | | using Azure.Core; |
| | | 10 | | using Azure.Core.Pipeline; |
| | | 11 | | using Azure.Storage.Files.Shares.Models; |
| | | 12 | | using Azure.Storage.Shared; |
| | | 13 | | using Metadata = System.Collections.Generic.IDictionary<string, string>; |
| | | 14 | | |
| | | 15 | | namespace Azure.Storage.Files.Shares |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// A DirectoryClient represents a URI to the Azure Storage File service allowing you to manipulate a directory. |
| | | 19 | | /// </summary> |
| | | 20 | | public class ShareDirectoryClient |
| | | 21 | | { |
| | | 22 | | /// <summary> |
| | | 23 | | /// The directory's primary <see cref="Uri"/> endpoint. |
| | | 24 | | /// </summary> |
| | | 25 | | private readonly Uri _uri; |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets the directory's primary <see cref="Uri"/> endpoint. |
| | | 29 | | /// </summary> |
| | 992 | 30 | | public virtual Uri Uri => _uri; |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// The <see cref="HttpPipeline"/> transport pipeline used to send |
| | | 34 | | /// every request. |
| | | 35 | | /// </summary> |
| | | 36 | | private readonly HttpPipeline _pipeline; |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Gets the <see cref="HttpPipeline"/> transport pipeline used to send |
| | | 40 | | /// every request. |
| | | 41 | | /// </summary> |
| | 1348 | 42 | | internal virtual HttpPipeline Pipeline => _pipeline; |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// The version of the service to use when sending requests. |
| | | 46 | | /// </summary> |
| | | 47 | | private readonly ShareClientOptions.ServiceVersion _version; |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// The version of the service to use when sending requests. |
| | | 51 | | /// </summary> |
| | 838 | 52 | | internal virtual ShareClientOptions.ServiceVersion Version => _version; |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// The <see cref="ClientDiagnostics"/> instance used to create diagnostic scopes |
| | | 56 | | /// every request. |
| | | 57 | | /// </summary> |
| | | 58 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// The <see cref="ClientDiagnostics"/> instance used to create diagnostic scopes |
| | | 62 | | /// every request. |
| | | 63 | | /// </summary> |
| | 838 | 64 | | internal virtual ClientDiagnostics ClientDiagnostics => _clientDiagnostics; |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// The Storage account name corresponding to the directory client. |
| | | 68 | | /// </summary> |
| | | 69 | | private string _accountName; |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Gets the Storage account name corresponding to the directory client. |
| | | 73 | | /// </summary> |
| | | 74 | | public virtual string AccountName |
| | | 75 | | { |
| | | 76 | | get |
| | | 77 | | { |
| | 4 | 78 | | SetNameFieldsIfNull(); |
| | 4 | 79 | | return _accountName; |
| | | 80 | | } |
| | | 81 | | } |
| | | 82 | | |
| | | 83 | | /// <summary> |
| | | 84 | | /// The share name corresponding to the directory client. |
| | | 85 | | /// </summary> |
| | | 86 | | private string _shareName; |
| | | 87 | | |
| | | 88 | | /// <summary> |
| | | 89 | | /// Gets the share name corresponding to the directory client. |
| | | 90 | | /// </summary> |
| | | 91 | | public virtual string ShareName |
| | | 92 | | { |
| | | 93 | | get |
| | | 94 | | { |
| | 4 | 95 | | SetNameFieldsIfNull(); |
| | 4 | 96 | | return _shareName; |
| | | 97 | | } |
| | | 98 | | } |
| | | 99 | | |
| | | 100 | | /// <summary> |
| | | 101 | | /// The name of the directory. |
| | | 102 | | /// </summary> |
| | | 103 | | private string _name; |
| | | 104 | | |
| | | 105 | | /// <summary> |
| | | 106 | | /// Gets the name of the directory. |
| | | 107 | | /// </summary> |
| | | 108 | | public virtual string Name |
| | | 109 | | { |
| | | 110 | | get |
| | | 111 | | { |
| | 80 | 112 | | SetNameFieldsIfNull(); |
| | 80 | 113 | | return _name; |
| | | 114 | | } |
| | | 115 | | } |
| | | 116 | | |
| | | 117 | | /// <summary> |
| | | 118 | | /// The path of the directory. |
| | | 119 | | /// </summary> |
| | | 120 | | private string _path; |
| | | 121 | | |
| | | 122 | | /// <summary> |
| | | 123 | | /// Gets the path of the directory. |
| | | 124 | | /// </summary> |
| | | 125 | | public virtual string Path |
| | | 126 | | { |
| | | 127 | | get |
| | | 128 | | { |
| | 64 | 129 | | SetNameFieldsIfNull(); |
| | 64 | 130 | | return _path; |
| | | 131 | | } |
| | | 132 | | } |
| | | 133 | | |
| | | 134 | | #region ctors |
| | | 135 | | /// <summary> |
| | | 136 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> |
| | | 137 | | /// class for mocking. |
| | | 138 | | /// </summary> |
| | 459 | 139 | | protected ShareDirectoryClient() |
| | | 140 | | { |
| | 459 | 141 | | } |
| | | 142 | | |
| | | 143 | | /// <summary> |
| | | 144 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> class. |
| | | 145 | | /// </summary> |
| | | 146 | | /// <param name="connectionString"> |
| | | 147 | | /// A connection string includes the authentication information |
| | | 148 | | /// required for your application to access data in an Azure Storage |
| | | 149 | | /// account at runtime. |
| | | 150 | | /// |
| | | 151 | | /// For more information, |
| | | 152 | | /// <see href="https://docs.microsoft.com/azure/storage/common/storage-configure-connection-string"> |
| | | 153 | | /// Configure Azure Storage connection strings</see> |
| | | 154 | | /// </param> |
| | | 155 | | /// <param name="shareName"> |
| | | 156 | | /// The name of the share in the storage account to reference. |
| | | 157 | | /// </param> |
| | | 158 | | /// <param name="directoryPath"> |
| | | 159 | | /// The path of the directory in the storage account to reference. |
| | | 160 | | /// </param> |
| | | 161 | | public ShareDirectoryClient(string connectionString, string shareName, string directoryPath) |
| | 0 | 162 | | : this(connectionString, shareName, directoryPath, null) |
| | | 163 | | { |
| | 0 | 164 | | } |
| | | 165 | | |
| | | 166 | | /// <summary> |
| | | 167 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> class. |
| | | 168 | | /// </summary> |
| | | 169 | | /// <param name="connectionString"> |
| | | 170 | | /// A connection string includes the authentication information |
| | | 171 | | /// required for your application to access data in an Azure Storage |
| | | 172 | | /// account at runtime. |
| | | 173 | | /// |
| | | 174 | | /// For more information, |
| | | 175 | | /// <see href="https://docs.microsoft.com/azure/storage/common/storage-configure-connection-string"> |
| | | 176 | | /// Configure Azure Storage connection strings</see> |
| | | 177 | | /// </param> |
| | | 178 | | /// <param name="shareName"> |
| | | 179 | | /// The name of the share in the storage account to reference. |
| | | 180 | | /// </param> |
| | | 181 | | /// <param name="directoryPath"> |
| | | 182 | | /// The path of the directory in the storage account to reference. |
| | | 183 | | /// </param> |
| | | 184 | | /// <param name="options"> |
| | | 185 | | /// Optional <see cref="ShareClientOptions"/> that define the transport |
| | | 186 | | /// pipeline policies for authentication, retries, etc., that are |
| | | 187 | | /// applied to every request. |
| | | 188 | | /// </param> |
| | 26 | 189 | | public ShareDirectoryClient(string connectionString, string shareName, string directoryPath, ShareClientOptions |
| | | 190 | | { |
| | 26 | 191 | | options ??= new ShareClientOptions(); |
| | 26 | 192 | | var conn = StorageConnectionString.Parse(connectionString); |
| | 26 | 193 | | var builder = |
| | 26 | 194 | | new ShareUriBuilder(conn.FileEndpoint) |
| | 26 | 195 | | { |
| | 26 | 196 | | ShareName = shareName, |
| | 26 | 197 | | DirectoryOrFilePath = directoryPath |
| | 26 | 198 | | }; |
| | 26 | 199 | | _uri = builder.ToUri(); |
| | 26 | 200 | | _pipeline = options.Build(conn.Credentials); |
| | 26 | 201 | | _version = options.Version; |
| | 26 | 202 | | _clientDiagnostics = new ClientDiagnostics(options); |
| | 26 | 203 | | } |
| | | 204 | | |
| | | 205 | | /// <summary> |
| | | 206 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> |
| | | 207 | | /// class. |
| | | 208 | | /// </summary> |
| | | 209 | | /// <param name="directoryUri"> |
| | | 210 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | | 211 | | /// name of the account, the name of the share, and the path of the |
| | | 212 | | /// directory. |
| | | 213 | | /// </param> |
| | | 214 | | /// <param name="options"> |
| | | 215 | | /// Optional <see cref="ShareClientOptions"/> that define the transport |
| | | 216 | | /// pipeline policies for authentication, retries, etc., that are |
| | | 217 | | /// applied to every request. |
| | | 218 | | /// </param> |
| | | 219 | | public ShareDirectoryClient(Uri directoryUri, ShareClientOptions options = default) |
| | 10 | 220 | | : this(directoryUri, (HttpPipelinePolicy)null, options) |
| | | 221 | | { |
| | 10 | 222 | | } |
| | | 223 | | |
| | | 224 | | /// <summary> |
| | | 225 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> |
| | | 226 | | /// class. |
| | | 227 | | /// </summary> |
| | | 228 | | /// <param name="directoryUri"> |
| | | 229 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | | 230 | | /// name of the account, the name of the share, and the path of the |
| | | 231 | | /// directory. |
| | | 232 | | /// </param> |
| | | 233 | | /// <param name="credential"> |
| | | 234 | | /// The shared key credential used to sign requests. |
| | | 235 | | /// </param> |
| | | 236 | | /// <param name="options"> |
| | | 237 | | /// Optional client options that define the transport pipeline |
| | | 238 | | /// policies for authentication, retries, etc., that are applied to |
| | | 239 | | /// every request. |
| | | 240 | | /// </param> |
| | | 241 | | public ShareDirectoryClient(Uri directoryUri, StorageSharedKeyCredential credential, ShareClientOptions options |
| | 4 | 242 | | : this(directoryUri, credential.AsPolicy(), options) |
| | | 243 | | { |
| | 4 | 244 | | } |
| | | 245 | | |
| | | 246 | | /// <summary> |
| | | 247 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> |
| | | 248 | | /// class. |
| | | 249 | | /// </summary> |
| | | 250 | | /// <param name="directoryUri"> |
| | | 251 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | | 252 | | /// name of the account, the name of the share, and the path of the |
| | | 253 | | /// directory. |
| | | 254 | | /// </param> |
| | | 255 | | /// <param name="authentication"> |
| | | 256 | | /// An optional authentication policy used to sign requests. |
| | | 257 | | /// </param> |
| | | 258 | | /// <param name="options"> |
| | | 259 | | /// Optional client options that define the transport pipeline |
| | | 260 | | /// policies for authentication, retries, etc., that are applied to |
| | | 261 | | /// every request. |
| | | 262 | | /// </param> |
| | 14 | 263 | | internal ShareDirectoryClient(Uri directoryUri, HttpPipelinePolicy authentication, ShareClientOptions options) |
| | | 264 | | { |
| | 14 | 265 | | options ??= new ShareClientOptions(); |
| | 14 | 266 | | _uri = directoryUri; |
| | 14 | 267 | | _pipeline = options.Build(authentication); |
| | 14 | 268 | | _version = options.Version; |
| | 14 | 269 | | _clientDiagnostics = new ClientDiagnostics(options); |
| | 14 | 270 | | } |
| | | 271 | | |
| | | 272 | | /// <summary> |
| | | 273 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> |
| | | 274 | | /// class. |
| | | 275 | | /// </summary> |
| | | 276 | | /// <param name="directoryUri"> |
| | | 277 | | /// A <see cref="Uri"/> referencing the directory that includes the |
| | | 278 | | /// name of the account, the name of the share, and the path of the |
| | | 279 | | /// directory. |
| | | 280 | | /// </param> |
| | | 281 | | /// <param name="pipeline"> |
| | | 282 | | /// The transport pipeline used to send every request. |
| | | 283 | | /// </param> |
| | | 284 | | /// <param name="version"> |
| | | 285 | | /// The version of the service to use when sending requests. |
| | | 286 | | /// </param> |
| | | 287 | | /// <param name="clientDiagnostics"> |
| | | 288 | | /// The <see cref="ClientDiagnostics"/> instance used to create |
| | | 289 | | /// diagnostic scopes every request. |
| | | 290 | | /// </param> |
| | 469 | 291 | | internal ShareDirectoryClient(Uri directoryUri, HttpPipeline pipeline, ShareClientOptions.ServiceVersion version |
| | | 292 | | { |
| | 469 | 293 | | _uri = directoryUri; |
| | 469 | 294 | | _pipeline = pipeline; |
| | 469 | 295 | | _version = version; |
| | 469 | 296 | | _clientDiagnostics = clientDiagnostics; |
| | 469 | 297 | | } |
| | | 298 | | #endregion ctors |
| | | 299 | | |
| | | 300 | | /// <summary> |
| | | 301 | | /// Initializes a new instance of the <see cref="ShareDirectoryClient"/> |
| | | 302 | | /// class with an identical <see cref="Uri"/> source but the specified |
| | | 303 | | /// <paramref name="snapshot"/> timestamp. |
| | | 304 | | /// |
| | | 305 | | /// For more information, see |
| | | 306 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/snapshot-share"> |
| | | 307 | | /// Snapshot Share</see>. |
| | | 308 | | /// </summary> |
| | | 309 | | /// <remarks> |
| | | 310 | | /// Pass null or empty string to remove the snapshot returning a URL to the base directory. |
| | | 311 | | /// </remarks> |
| | | 312 | | /// <param name="snapshot"> |
| | | 313 | | /// The snapshot identifier. |
| | | 314 | | /// </param> |
| | | 315 | | /// <returns> |
| | | 316 | | /// A new <see cref="ShareDirectoryClient"/> instance. |
| | | 317 | | /// </returns> |
| | | 318 | | public virtual ShareDirectoryClient WithSnapshot(string snapshot) |
| | | 319 | | { |
| | 0 | 320 | | var p = new ShareUriBuilder(Uri) { Snapshot = snapshot }; |
| | 0 | 321 | | return new ShareDirectoryClient(p.ToUri(), Pipeline, Version, ClientDiagnostics); |
| | | 322 | | } |
| | | 323 | | |
| | | 324 | | /// <summary> |
| | | 325 | | /// Creates a new <see cref="ShareFileClient"/> object by appending |
| | | 326 | | /// <paramref name="fileName"/> to the end of <see cref="Uri"/>. The |
| | | 327 | | /// new <see cref="ShareFileClient"/> uses the same request policy |
| | | 328 | | /// pipeline as the <see cref="ShareDirectoryClient"/>. |
| | | 329 | | /// </summary> |
| | | 330 | | /// <param name="fileName">The name of the file.</param> |
| | | 331 | | /// <returns>A new <see cref="ShareFileClient"/> instance.</returns> |
| | | 332 | | public virtual ShareFileClient GetFileClient(string fileName) |
| | | 333 | | { |
| | 322 | 334 | | ShareUriBuilder shareUriBuilder = new ShareUriBuilder(Uri); |
| | 322 | 335 | | shareUriBuilder.DirectoryOrFilePath += $"/{fileName}"; |
| | 322 | 336 | | return new ShareFileClient( |
| | 322 | 337 | | shareUriBuilder.ToUri(), |
| | 322 | 338 | | Pipeline, |
| | 322 | 339 | | Version, |
| | 322 | 340 | | ClientDiagnostics); |
| | | 341 | | } |
| | | 342 | | |
| | | 343 | | /// <summary> |
| | | 344 | | /// Creates a new <see cref="ShareDirectoryClient"/> object by appending |
| | | 345 | | /// <paramref name="subdirectoryName"/> to the end of <see cref="Uri"/>. |
| | | 346 | | /// The new <see cref="ShareDirectoryClient"/> uses the same request policy |
| | | 347 | | /// pipeline as the <see cref="ShareDirectoryClient"/>. |
| | | 348 | | /// </summary> |
| | | 349 | | /// <param name="subdirectoryName">The name of the subdirectory.</param> |
| | | 350 | | /// <returns>A new <see cref="ShareDirectoryClient"/> instance.</returns> |
| | | 351 | | public virtual ShareDirectoryClient GetSubdirectoryClient(string subdirectoryName) |
| | | 352 | | { |
| | 36 | 353 | | ShareUriBuilder shareUriBuilder = new ShareUriBuilder(Uri); |
| | 36 | 354 | | shareUriBuilder.DirectoryOrFilePath += $"/{subdirectoryName}"; |
| | 36 | 355 | | return new ShareDirectoryClient( |
| | 36 | 356 | | shareUriBuilder.ToUri(), |
| | 36 | 357 | | Pipeline, |
| | 36 | 358 | | Version, |
| | 36 | 359 | | ClientDiagnostics); |
| | | 360 | | } |
| | | 361 | | |
| | | 362 | | /// <summary> |
| | | 363 | | /// Sets the various name fields if they are currently null. |
| | | 364 | | /// </summary> |
| | | 365 | | private void SetNameFieldsIfNull() |
| | | 366 | | { |
| | 152 | 367 | | if (_name == null || _shareName == null || _accountName == null || _path == null) |
| | | 368 | | { |
| | 70 | 369 | | var builder = new ShareUriBuilder(Uri); |
| | 70 | 370 | | _name = builder.LastDirectoryOrFileName; |
| | 70 | 371 | | _shareName = builder.ShareName; |
| | 70 | 372 | | _accountName = builder.AccountName; |
| | 70 | 373 | | _path = builder.DirectoryOrFilePath; |
| | | 374 | | } |
| | 152 | 375 | | } |
| | | 376 | | |
| | | 377 | | #region Create |
| | | 378 | | /// <summary> |
| | | 379 | | /// The <see cref="Create"/> operation creates a new directory |
| | | 380 | | /// at the specified <see cref="Uri"/>. |
| | | 381 | | /// |
| | | 382 | | /// For more information, see |
| | | 383 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 384 | | /// Create Directory</see>. |
| | | 385 | | /// </summary> |
| | | 386 | | /// <param name="metadata"> |
| | | 387 | | /// Optional custom metadata to set for this directory. |
| | | 388 | | /// </param> |
| | | 389 | | /// <param name="smbProperties"> |
| | | 390 | | /// Optional SMB properties to set for the directory. |
| | | 391 | | /// </param> |
| | | 392 | | /// <param name="filePermission"> |
| | | 393 | | /// Optional file permission to set on the directory. |
| | | 394 | | /// </param> |
| | | 395 | | /// <param name="cancellationToken"> |
| | | 396 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 397 | | /// notifications that the operation should be cancelled. |
| | | 398 | | /// </param> |
| | | 399 | | /// <returns> |
| | | 400 | | /// A <see cref="Response{StorageDirectoryInfo}"/> describing the newly |
| | | 401 | | /// created directory. |
| | | 402 | | /// </returns> |
| | | 403 | | /// <remarks> |
| | | 404 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 405 | | /// a failure occurs. |
| | | 406 | | /// </remarks> |
| | | 407 | | public virtual Response<ShareDirectoryInfo> Create( |
| | | 408 | | Metadata metadata = default, |
| | | 409 | | FileSmbProperties smbProperties = default, |
| | | 410 | | string filePermission = default, |
| | | 411 | | CancellationToken cancellationToken = default) => |
| | 165 | 412 | | CreateInternal( |
| | 165 | 413 | | metadata, |
| | 165 | 414 | | smbProperties, |
| | 165 | 415 | | filePermission, |
| | 165 | 416 | | false, // async |
| | 165 | 417 | | cancellationToken) |
| | 165 | 418 | | .EnsureCompleted(); |
| | | 419 | | |
| | | 420 | | /// <summary> |
| | | 421 | | /// The <see cref="CreateAsync"/> operation creates a new directory |
| | | 422 | | /// at the specified <see cref="Uri"/>. |
| | | 423 | | /// |
| | | 424 | | /// For more information, see |
| | | 425 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 426 | | /// Create Directory</see>. |
| | | 427 | | /// </summary> |
| | | 428 | | /// <param name="metadata"> |
| | | 429 | | /// Optional custom metadata to set for this directory. |
| | | 430 | | /// </param> |
| | | 431 | | /// <param name="smbProperties"> |
| | | 432 | | /// Optional SMB properties to set for the directory. |
| | | 433 | | /// </param> |
| | | 434 | | /// <param name="filePermission"> |
| | | 435 | | /// Optional file permission to set on the directory. |
| | | 436 | | /// </param> |
| | | 437 | | /// <param name="cancellationToken"> |
| | | 438 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 439 | | /// notifications that the operation should be cancelled. |
| | | 440 | | /// </param> |
| | | 441 | | /// <returns> |
| | | 442 | | /// A <see cref="Response{StorageDirectoryInfo}"/> describing the newly |
| | | 443 | | /// created directory. |
| | | 444 | | /// </returns> |
| | | 445 | | /// <remarks> |
| | | 446 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 447 | | /// a failure occurs. |
| | | 448 | | /// </remarks> |
| | | 449 | | public virtual async Task<Response<ShareDirectoryInfo>> CreateAsync( |
| | | 450 | | Metadata metadata = default, |
| | | 451 | | FileSmbProperties smbProperties = default, |
| | | 452 | | string filePermission = default, |
| | | 453 | | CancellationToken cancellationToken = default) => |
| | 166 | 454 | | await CreateInternal( |
| | 166 | 455 | | metadata, |
| | 166 | 456 | | smbProperties, |
| | 166 | 457 | | filePermission, |
| | 166 | 458 | | true, // async |
| | 166 | 459 | | cancellationToken) |
| | 166 | 460 | | .ConfigureAwait(false); |
| | | 461 | | |
| | | 462 | | /// <summary> |
| | | 463 | | /// The <see cref="CreateInternal"/> operation creates a new directory |
| | | 464 | | /// at the specified <see cref="Uri"/>. |
| | | 465 | | /// |
| | | 466 | | /// For more information, see |
| | | 467 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 468 | | /// Create Directory</see>. |
| | | 469 | | /// </summary> |
| | | 470 | | /// <param name="metadata"> |
| | | 471 | | /// Optional custom metadata to set for this directory. |
| | | 472 | | /// </param> |
| | | 473 | | /// <param name="smbProperties"> |
| | | 474 | | /// Optional SMB properties to set for the directory. |
| | | 475 | | /// </param> |
| | | 476 | | /// <param name="filePermission"> |
| | | 477 | | /// Optional file permission to set on the directory. |
| | | 478 | | /// </param> |
| | | 479 | | /// <param name="async"> |
| | | 480 | | /// Whether to invoke the operation asynchronously. |
| | | 481 | | /// </param> |
| | | 482 | | /// <param name="cancellationToken"> |
| | | 483 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 484 | | /// notifications that the operation should be cancelled. |
| | | 485 | | /// </param> |
| | | 486 | | /// <param name="operationName"> |
| | | 487 | | /// Optional. To indicate if the name of the operation. |
| | | 488 | | /// </param> |
| | | 489 | | /// <returns> |
| | | 490 | | /// A <see cref="Response{StorageDirectoryInfo}"/> describing the newly |
| | | 491 | | /// created directory. |
| | | 492 | | /// </returns> |
| | | 493 | | /// <remarks> |
| | | 494 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 495 | | /// a failure occurs. |
| | | 496 | | /// </remarks> |
| | | 497 | | internal async Task<Response<ShareDirectoryInfo>> CreateInternal( |
| | | 498 | | Metadata metadata, |
| | | 499 | | FileSmbProperties smbProperties, |
| | | 500 | | string filePermission, |
| | | 501 | | bool async, |
| | | 502 | | CancellationToken cancellationToken, |
| | | 503 | | string operationName = default) |
| | | 504 | | { |
| | 343 | 505 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 506 | | { |
| | | 507 | | Pipeline.LogMethodEnter( |
| | | 508 | | nameof(ShareDirectoryClient), |
| | | 509 | | message: $"{nameof(Uri)}: {Uri}"); |
| | | 510 | | try |
| | | 511 | | { |
| | 343 | 512 | | FileSmbProperties smbProps = smbProperties ?? new FileSmbProperties(); |
| | | 513 | | |
| | 343 | 514 | | ShareExtensions.AssertValidFilePermissionAndKey(filePermission, smbProps.FilePermissionKey); |
| | 339 | 515 | | if (filePermission == null && smbProps.FilePermissionKey == null) |
| | | 516 | | { |
| | 335 | 517 | | filePermission = Constants.File.FilePermissionInherit; |
| | | 518 | | } |
| | | 519 | | |
| | 339 | 520 | | Response<RawStorageDirectoryInfo> response = await FileRestClient.Directory.CreateAsync( |
| | 339 | 521 | | ClientDiagnostics, |
| | 339 | 522 | | Pipeline, |
| | 339 | 523 | | Uri, |
| | 339 | 524 | | version: Version.ToVersionString(), |
| | 339 | 525 | | metadata: metadata, |
| | 339 | 526 | | fileAttributes: smbProps.FileAttributes?.ToAttributesString() ?? Constants.File.FileAttributesNo |
| | 339 | 527 | | filePermission: filePermission, |
| | 339 | 528 | | fileCreationTime: smbProps.FileCreatedOn.ToFileDateTimeString() ?? Constants.File.FileTimeNow, |
| | 339 | 529 | | fileLastWriteTime: smbProps.FileLastWrittenOn.ToFileDateTimeString() ?? Constants.File.FileTimeN |
| | 339 | 530 | | filePermissionKey: smbProps.FilePermissionKey, |
| | 339 | 531 | | async: async, |
| | 339 | 532 | | operationName: operationName ?? $"{nameof(ShareDirectoryClient)}.{nameof(Create)}", |
| | 339 | 533 | | cancellationToken: cancellationToken) |
| | 339 | 534 | | .ConfigureAwait(false); |
| | | 535 | | |
| | 333 | 536 | | return Response.FromValue(new ShareDirectoryInfo(response.Value), response.GetRawResponse()); |
| | | 537 | | } |
| | 10 | 538 | | catch (Exception ex) |
| | | 539 | | { |
| | | 540 | | Pipeline.LogException(ex); |
| | 10 | 541 | | throw; |
| | | 542 | | } |
| | | 543 | | finally |
| | | 544 | | { |
| | | 545 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 546 | | } |
| | | 547 | | } |
| | 333 | 548 | | } |
| | | 549 | | #endregion Create |
| | | 550 | | |
| | | 551 | | #region CreateIfNotExists |
| | | 552 | | /// <summary> |
| | | 553 | | /// The <see cref="CreateIfNotExists"/> operation creates a new directory, |
| | | 554 | | /// if it does not already exists. If the directory already exists, it is not |
| | | 555 | | /// modified. |
| | | 556 | | /// |
| | | 557 | | /// For more information, see |
| | | 558 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 559 | | /// Create Directory</see>. |
| | | 560 | | /// </summary> |
| | | 561 | | /// <param name="metadata"> |
| | | 562 | | /// Optional custom metadata to set for this directory. |
| | | 563 | | /// </param> |
| | | 564 | | /// <param name="smbProperties"> |
| | | 565 | | /// Optional SMB properties to set for the directory. |
| | | 566 | | /// </param> |
| | | 567 | | /// <param name="filePermission"> |
| | | 568 | | /// Optional file permission to set on the directory. |
| | | 569 | | /// </param> |
| | | 570 | | /// <param name="cancellationToken"> |
| | | 571 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 572 | | /// notifications that the operation should be cancelled. |
| | | 573 | | /// </param> |
| | | 574 | | /// <returns> |
| | | 575 | | /// A <see cref="Response{StorageDirectoryInfo}"/> describing the newly |
| | | 576 | | /// created directory. |
| | | 577 | | /// </returns> |
| | | 578 | | /// <remarks> |
| | | 579 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 580 | | /// a failure occurs. |
| | | 581 | | /// </remarks> |
| | | 582 | | public virtual Response<ShareDirectoryInfo> CreateIfNotExists( |
| | | 583 | | Metadata metadata = default, |
| | | 584 | | FileSmbProperties smbProperties = default, |
| | | 585 | | string filePermission = default, |
| | | 586 | | CancellationToken cancellationToken = default) => |
| | 3 | 587 | | CreateIfNotExistsInternal( |
| | 3 | 588 | | metadata, |
| | 3 | 589 | | smbProperties, |
| | 3 | 590 | | filePermission, |
| | 3 | 591 | | async: false, |
| | 3 | 592 | | cancellationToken).EnsureCompleted(); |
| | | 593 | | |
| | | 594 | | /// <summary> |
| | | 595 | | /// The <see cref="CreateIfNotExistsAsync"/> operation creates a new directory, |
| | | 596 | | /// if it does not already exists. If the directory already exists, it is not |
| | | 597 | | /// modified. |
| | | 598 | | /// |
| | | 599 | | /// For more information, see |
| | | 600 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 601 | | /// Create Directory</see>. |
| | | 602 | | /// </summary> |
| | | 603 | | /// <param name="metadata"> |
| | | 604 | | /// Optional custom metadata to set for this directory. |
| | | 605 | | /// </param> |
| | | 606 | | /// <param name="smbProperties"> |
| | | 607 | | /// Optional SMB properties to set for the directory. |
| | | 608 | | /// </param> |
| | | 609 | | /// <param name="filePermission"> |
| | | 610 | | /// Optional file permission to set on the directory. |
| | | 611 | | /// </param> |
| | | 612 | | /// <param name="cancellationToken"> |
| | | 613 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 614 | | /// notifications that the operation should be cancelled. |
| | | 615 | | /// </param> |
| | | 616 | | /// <returns> |
| | | 617 | | /// A <see cref="Response{StorageDirectoryInfo}"/> describing the newly |
| | | 618 | | /// created directory. |
| | | 619 | | /// </returns> |
| | | 620 | | /// <remarks> |
| | | 621 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 622 | | /// a failure occurs. |
| | | 623 | | /// </remarks> |
| | | 624 | | public virtual async Task<Response<ShareDirectoryInfo>> CreateIfNotExistsAsync( |
| | | 625 | | Metadata metadata = default, |
| | | 626 | | FileSmbProperties smbProperties = default, |
| | | 627 | | string filePermission = default, |
| | | 628 | | CancellationToken cancellationToken = default) => |
| | 3 | 629 | | await CreateIfNotExistsInternal( |
| | 3 | 630 | | metadata, |
| | 3 | 631 | | smbProperties, |
| | 3 | 632 | | filePermission, |
| | 3 | 633 | | async: true, |
| | 3 | 634 | | cancellationToken).ConfigureAwait(false); |
| | | 635 | | |
| | | 636 | | /// <summary> |
| | | 637 | | /// The <see cref="CreateIfNotExistsInternal"/> operation creates a new directory, |
| | | 638 | | /// if it does not already exists. If the directory already exists, it is not |
| | | 639 | | /// modified. |
| | | 640 | | /// |
| | | 641 | | /// For more information, see |
| | | 642 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 643 | | /// Create Directory</see>. |
| | | 644 | | /// </summary> |
| | | 645 | | /// <param name="metadata"> |
| | | 646 | | /// Optional custom metadata to set for this directory. |
| | | 647 | | /// </param> |
| | | 648 | | /// <param name="smbProperties"> |
| | | 649 | | /// Optional SMB properties to set for the directory. |
| | | 650 | | /// </param> |
| | | 651 | | /// <param name="filePermission"> |
| | | 652 | | /// Optional file permission to set on the directory. |
| | | 653 | | /// </param> |
| | | 654 | | /// <param name="async"> |
| | | 655 | | /// Whether to invoke the operation asynchronously. |
| | | 656 | | /// </param> |
| | | 657 | | /// <param name="cancellationToken"> |
| | | 658 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 659 | | /// notifications that the operation should be cancelled. |
| | | 660 | | /// </param> |
| | | 661 | | /// <param name="operationName"> |
| | | 662 | | /// Optional. To indicate if the name of the operation. |
| | | 663 | | /// </param> |
| | | 664 | | /// <returns> |
| | | 665 | | /// A <see cref="Response{StorageDirectoryInfo}"/> describing the newly |
| | | 666 | | /// created directory. |
| | | 667 | | /// </returns> |
| | | 668 | | /// <remarks> |
| | | 669 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 670 | | /// a failure occurs. |
| | | 671 | | /// </remarks> |
| | | 672 | | internal async Task<Response<ShareDirectoryInfo>> CreateIfNotExistsInternal( |
| | | 673 | | Metadata metadata, |
| | | 674 | | FileSmbProperties smbProperties, |
| | | 675 | | string filePermission, |
| | | 676 | | bool async, |
| | | 677 | | CancellationToken cancellationToken, |
| | | 678 | | string operationName = default) |
| | | 679 | | { |
| | 6 | 680 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 681 | | { |
| | | 682 | | Pipeline.LogMethodEnter( |
| | | 683 | | nameof(ShareDirectoryClient), |
| | | 684 | | message: $"{nameof(Uri)}: {Uri}"); |
| | | 685 | | try |
| | | 686 | | { |
| | 6 | 687 | | Response<ShareDirectoryInfo> response = await CreateInternal( |
| | 6 | 688 | | metadata, |
| | 6 | 689 | | smbProperties, |
| | 6 | 690 | | filePermission, |
| | 6 | 691 | | async, |
| | 6 | 692 | | cancellationToken, |
| | 6 | 693 | | operationName: operationName ?? $"{nameof(ShareDirectoryClient)}.{nameof(CreateIfNotExists)}") |
| | 6 | 694 | | .ConfigureAwait(false); |
| | | 695 | | |
| | 2 | 696 | | return response; |
| | | 697 | | } |
| | | 698 | | catch (RequestFailedException storageRequestFailedException) |
| | 4 | 699 | | when (storageRequestFailedException.ErrorCode == ShareErrorCode.ResourceAlreadyExists) |
| | | 700 | | { |
| | 2 | 701 | | return default; |
| | | 702 | | } |
| | 2 | 703 | | catch (Exception ex) |
| | | 704 | | { |
| | | 705 | | Pipeline.LogException(ex); |
| | 2 | 706 | | throw; |
| | | 707 | | } |
| | | 708 | | finally |
| | | 709 | | { |
| | | 710 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 711 | | } |
| | | 712 | | } |
| | 4 | 713 | | } |
| | | 714 | | #endregion CreateIfNotExists |
| | | 715 | | |
| | | 716 | | #region Exists |
| | | 717 | | /// <summary> |
| | | 718 | | /// The <see cref="Exists"/> operation can be called on a |
| | | 719 | | /// <see cref="ShareDirectoryClient"/> to see if the associated directory |
| | | 720 | | /// exists in the share on the storage account in the storage service. |
| | | 721 | | /// </summary> |
| | | 722 | | /// <param name="cancellationToken"> |
| | | 723 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 724 | | /// notifications that the operation should be cancelled. |
| | | 725 | | /// </param> |
| | | 726 | | /// <returns> |
| | | 727 | | /// Returns true if the directory exists. |
| | | 728 | | /// </returns> |
| | | 729 | | /// <remarks> |
| | | 730 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 731 | | /// a failure occurs. |
| | | 732 | | /// </remarks> |
| | | 733 | | public virtual Response<bool> Exists( |
| | | 734 | | CancellationToken cancellationToken = default) => |
| | 4 | 735 | | ExistsInternal( |
| | 4 | 736 | | async: false, |
| | 4 | 737 | | cancellationToken).EnsureCompleted(); |
| | | 738 | | |
| | | 739 | | /// <summary> |
| | | 740 | | /// The <see cref="Exists"/> operation can be called on a |
| | | 741 | | /// <see cref="ShareDirectoryClient"/> to see if the associated directory |
| | | 742 | | /// exists in the share on the storage account in the storage service. |
| | | 743 | | /// </summary> |
| | | 744 | | /// <param name="cancellationToken"> |
| | | 745 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 746 | | /// notifications that the operation should be cancelled. |
| | | 747 | | /// </param> |
| | | 748 | | /// <returns> |
| | | 749 | | /// Returns true if the directory exists. |
| | | 750 | | /// </returns> |
| | | 751 | | /// <remarks> |
| | | 752 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 753 | | /// a failure occurs. |
| | | 754 | | /// </remarks> |
| | | 755 | | public virtual async Task<Response<bool>> ExistsAsync( |
| | | 756 | | CancellationToken cancellationToken = default) => |
| | 4 | 757 | | await ExistsInternal( |
| | 4 | 758 | | async: true, |
| | 4 | 759 | | cancellationToken).ConfigureAwait(false); |
| | | 760 | | |
| | | 761 | | /// <summary> |
| | | 762 | | /// The <see cref="ExistsInternal"/> operation can be called on a |
| | | 763 | | /// <see cref="ShareDirectoryClient"/> to see if the associated directory |
| | | 764 | | /// exists in the share on the storage account in the storage service. |
| | | 765 | | /// </summary> |
| | | 766 | | /// <param name="async"> |
| | | 767 | | /// Whether to invoke the operation asynchronously. |
| | | 768 | | /// </param> |
| | | 769 | | /// <param name="cancellationToken"> |
| | | 770 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 771 | | /// notifications that the operation should be cancelled. |
| | | 772 | | /// </param> |
| | | 773 | | /// <returns> |
| | | 774 | | /// Returns true if the directory exists. |
| | | 775 | | /// </returns> |
| | | 776 | | /// <remarks> |
| | | 777 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 778 | | /// a failure occurs. |
| | | 779 | | /// </remarks> |
| | | 780 | | private async Task<Response<bool>> ExistsInternal( |
| | | 781 | | bool async, |
| | | 782 | | CancellationToken cancellationToken) |
| | | 783 | | { |
| | 8 | 784 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 785 | | { |
| | | 786 | | Pipeline.LogMethodEnter( |
| | | 787 | | nameof(ShareDirectoryClient), |
| | | 788 | | message: |
| | | 789 | | $"{nameof(Uri)}: {Uri}"); |
| | | 790 | | |
| | | 791 | | try |
| | | 792 | | { |
| | 8 | 793 | | Response<ShareDirectoryProperties> response = await GetPropertiesInternal( |
| | 8 | 794 | | async, |
| | 8 | 795 | | cancellationToken, |
| | 8 | 796 | | operationName: $"{nameof(ShareDirectoryClient)}.{nameof(Exists)}") |
| | 8 | 797 | | .ConfigureAwait(false); |
| | | 798 | | |
| | 2 | 799 | | return Response.FromValue(true, response.GetRawResponse()); |
| | | 800 | | } |
| | | 801 | | catch (RequestFailedException storageRequestFailedException) |
| | 6 | 802 | | when (storageRequestFailedException.ErrorCode == ShareErrorCode.ResourceNotFound |
| | 6 | 803 | | || storageRequestFailedException.ErrorCode == ShareErrorCode.ShareNotFound) |
| | | 804 | | { |
| | 4 | 805 | | return Response.FromValue(false, default); |
| | | 806 | | } |
| | 2 | 807 | | catch (Exception ex) |
| | | 808 | | { |
| | | 809 | | Pipeline.LogException(ex); |
| | 2 | 810 | | throw; |
| | | 811 | | } |
| | | 812 | | finally |
| | | 813 | | { |
| | | 814 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 815 | | } |
| | | 816 | | } |
| | 6 | 817 | | } |
| | | 818 | | #endregion Exists |
| | | 819 | | |
| | | 820 | | #region DeleteIfExists |
| | | 821 | | /// <summary> |
| | | 822 | | /// The <see cref="DeleteIfExists"/> operation removes the specified |
| | | 823 | | /// empty directory, if it exists. |
| | | 824 | | /// |
| | | 825 | | /// For more information, see |
| | | 826 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 827 | | /// Delete Directory</see>. |
| | | 828 | | /// </summary> |
| | | 829 | | /// <param name="cancellationToken"> |
| | | 830 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 831 | | /// notifications that the operation should be cancelled. |
| | | 832 | | /// </param> |
| | | 833 | | /// <returns> |
| | | 834 | | /// True if the directory existed. |
| | | 835 | | /// </returns> |
| | | 836 | | /// <remarks> |
| | | 837 | | /// Note that the directory must be empty before it can be deleted. |
| | | 838 | | /// </remarks> |
| | | 839 | | public virtual Response<bool> DeleteIfExists( |
| | | 840 | | CancellationToken cancellationToken = default) => |
| | 4 | 841 | | DeleteIfExistsInternal( |
| | 4 | 842 | | async: false, |
| | 4 | 843 | | cancellationToken).EnsureCompleted(); |
| | | 844 | | |
| | | 845 | | /// <summary> |
| | | 846 | | /// The <see cref="DeleteIfExistsAsync"/> operation removes the specified |
| | | 847 | | /// empty directory, if it exists. |
| | | 848 | | /// |
| | | 849 | | /// For more information, see |
| | | 850 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 851 | | /// Delete Directory</see>. |
| | | 852 | | /// </summary> |
| | | 853 | | /// <param name="cancellationToken"> |
| | | 854 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 855 | | /// notifications that the operation should be cancelled. |
| | | 856 | | /// </param> |
| | | 857 | | /// <returns> |
| | | 858 | | /// True if the directory existed. |
| | | 859 | | /// </returns> |
| | | 860 | | /// <remarks> |
| | | 861 | | /// Note that the directory must be empty before it can be deleted. |
| | | 862 | | /// </remarks> |
| | | 863 | | public virtual async Task<Response<bool>> DeleteIfExistsAsync( |
| | | 864 | | CancellationToken cancellationToken = default) => |
| | 4 | 865 | | await DeleteIfExistsInternal( |
| | 4 | 866 | | async: true, |
| | 4 | 867 | | cancellationToken).ConfigureAwait(false); |
| | | 868 | | |
| | | 869 | | /// <summary> |
| | | 870 | | /// The <see cref="DeleteIfExistsInternal"/> operation removes the specified |
| | | 871 | | /// empty directory, if it exists. |
| | | 872 | | /// |
| | | 873 | | /// For more information, see |
| | | 874 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 875 | | /// Delete Directory</see>. |
| | | 876 | | /// </summary> |
| | | 877 | | /// <param name="async"> |
| | | 878 | | /// Whether to invoke the operation asynchronously. |
| | | 879 | | /// </param> |
| | | 880 | | /// <param name="cancellationToken"> |
| | | 881 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 882 | | /// notifications that the operation should be cancelled. |
| | | 883 | | /// </param> |
| | | 884 | | /// <param name="operationName"> |
| | | 885 | | /// Optional. To indicate if the name of the operation. |
| | | 886 | | /// </param> |
| | | 887 | | /// <returns> |
| | | 888 | | /// True if the directory existed. |
| | | 889 | | /// </returns> |
| | | 890 | | /// <remarks> |
| | | 891 | | /// Note that the directory must be empty before it can be deleted. |
| | | 892 | | /// </remarks> |
| | | 893 | | internal async Task<Response<bool>> DeleteIfExistsInternal( |
| | | 894 | | bool async, |
| | | 895 | | CancellationToken cancellationToken, |
| | | 896 | | string operationName = default) |
| | | 897 | | { |
| | 8 | 898 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 899 | | { |
| | | 900 | | Pipeline.LogMethodEnter( |
| | | 901 | | nameof(ShareDirectoryClient), |
| | | 902 | | message: $"{nameof(Uri)}: {Uri}"); |
| | | 903 | | try |
| | | 904 | | { |
| | 8 | 905 | | Response response = await DeleteInternal( |
| | 8 | 906 | | async, |
| | 8 | 907 | | cancellationToken, |
| | 8 | 908 | | operationName: operationName ?? $"{nameof(ShareDirectoryClient)}.{nameof(DeleteIfExists)}") |
| | 8 | 909 | | .ConfigureAwait(false); |
| | 2 | 910 | | return Response.FromValue(true, response); |
| | | 911 | | } |
| | | 912 | | catch (RequestFailedException storageRequestFailedException) |
| | 6 | 913 | | when (storageRequestFailedException.ErrorCode == ShareErrorCode.ResourceNotFound |
| | 6 | 914 | | || storageRequestFailedException.ErrorCode == ShareErrorCode.ShareNotFound) |
| | | 915 | | { |
| | 4 | 916 | | return Response.FromValue(false, default); |
| | | 917 | | } |
| | 2 | 918 | | catch (Exception ex) |
| | | 919 | | { |
| | | 920 | | Pipeline.LogException(ex); |
| | 2 | 921 | | throw; |
| | | 922 | | } |
| | | 923 | | finally |
| | | 924 | | { |
| | | 925 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 926 | | } |
| | | 927 | | } |
| | 6 | 928 | | } |
| | | 929 | | #endregion DeleteIfExists |
| | | 930 | | |
| | | 931 | | #region Delete |
| | | 932 | | /// <summary> |
| | | 933 | | /// The <see cref="Delete"/> operation removes the specified empty directory. |
| | | 934 | | /// |
| | | 935 | | /// For more information, see |
| | | 936 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 937 | | /// Delete Directory</see>. |
| | | 938 | | /// </summary> |
| | | 939 | | /// <param name="cancellationToken"> |
| | | 940 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 941 | | /// notifications that the operation should be cancelled. |
| | | 942 | | /// </param> |
| | | 943 | | /// <returns> |
| | | 944 | | /// A <see cref="Response"/> if successful. |
| | | 945 | | /// </returns> |
| | | 946 | | /// <remarks> |
| | | 947 | | /// Note that the directory must be empty before it can be deleted. |
| | | 948 | | /// </remarks> |
| | | 949 | | public virtual Response Delete( |
| | | 950 | | CancellationToken cancellationToken = default) => |
| | 3 | 951 | | DeleteInternal( |
| | 3 | 952 | | false, // async |
| | 3 | 953 | | cancellationToken) |
| | 3 | 954 | | .EnsureCompleted(); |
| | | 955 | | |
| | | 956 | | /// <summary> |
| | | 957 | | /// The <see cref="DeleteAsync"/> operation removes the specified empty directory. |
| | | 958 | | /// |
| | | 959 | | /// For more information, see |
| | | 960 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 961 | | /// Delete Directory</see>. |
| | | 962 | | /// </summary> |
| | | 963 | | /// <param name="cancellationToken"> |
| | | 964 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 965 | | /// notifications that the operation should be cancelled. |
| | | 966 | | /// </param> |
| | | 967 | | /// <returns> |
| | | 968 | | /// A <see cref="Response"/> if successful. |
| | | 969 | | /// </returns> |
| | | 970 | | /// <remarks> |
| | | 971 | | /// Note that the directory must be empty before it can be deleted. |
| | | 972 | | /// </remarks> |
| | | 973 | | public virtual async Task<Response> DeleteAsync( |
| | | 974 | | CancellationToken cancellationToken = default) => |
| | 3 | 975 | | await DeleteInternal( |
| | 3 | 976 | | true, // async |
| | 3 | 977 | | cancellationToken) |
| | 3 | 978 | | .ConfigureAwait(false); |
| | | 979 | | |
| | | 980 | | /// <summary> |
| | | 981 | | /// The <see cref="DeleteInternal"/> operation removes the specified |
| | | 982 | | /// empty directory. |
| | | 983 | | /// |
| | | 984 | | /// For more information, see |
| | | 985 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 986 | | /// Delete Directory</see>. |
| | | 987 | | /// </summary> |
| | | 988 | | /// <param name="async"> |
| | | 989 | | /// Whether to invoke the operation asynchronously. |
| | | 990 | | /// </param> |
| | | 991 | | /// <param name="cancellationToken"> |
| | | 992 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 993 | | /// notifications that the operation should be cancelled. |
| | | 994 | | /// </param> |
| | | 995 | | /// <param name="operationName"> |
| | | 996 | | /// Optional. To indicate if the name of the operation. |
| | | 997 | | /// </param> |
| | | 998 | | /// <returns> |
| | | 999 | | /// A <see cref="Response"/> if successful. |
| | | 1000 | | /// </returns> |
| | | 1001 | | /// <remarks> |
| | | 1002 | | /// Note that the directory must be empty before it can be deleted. |
| | | 1003 | | /// </remarks> |
| | | 1004 | | internal async Task<Response> DeleteInternal( |
| | | 1005 | | bool async, |
| | | 1006 | | CancellationToken cancellationToken, |
| | | 1007 | | string operationName = default) |
| | | 1008 | | { |
| | 16 | 1009 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 1010 | | { |
| | | 1011 | | Pipeline.LogMethodEnter( |
| | | 1012 | | nameof(ShareDirectoryClient), |
| | | 1013 | | message: $"{nameof(Uri)}: {Uri}"); |
| | | 1014 | | try |
| | | 1015 | | { |
| | 16 | 1016 | | return await FileRestClient.Directory.DeleteAsync( |
| | 16 | 1017 | | ClientDiagnostics, |
| | 16 | 1018 | | Pipeline, |
| | 16 | 1019 | | Uri, |
| | 16 | 1020 | | version: Version.ToVersionString(), |
| | 16 | 1021 | | async: async, |
| | 16 | 1022 | | operationName: operationName ?? $"{nameof(ShareDirectoryClient)}.{nameof(Delete)}", |
| | 16 | 1023 | | cancellationToken: cancellationToken) |
| | 16 | 1024 | | .ConfigureAwait(false); |
| | | 1025 | | } |
| | 8 | 1026 | | catch (Exception ex) |
| | | 1027 | | { |
| | | 1028 | | Pipeline.LogException(ex); |
| | 8 | 1029 | | throw; |
| | | 1030 | | } |
| | | 1031 | | finally |
| | | 1032 | | { |
| | | 1033 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 1034 | | } |
| | | 1035 | | } |
| | 8 | 1036 | | } |
| | | 1037 | | #endregion Delete |
| | | 1038 | | |
| | | 1039 | | #region GetProperties |
| | | 1040 | | /// <summary> |
| | | 1041 | | /// The <see cref="GetProperties"/> operation returns all |
| | | 1042 | | /// user-defined metadata and system properties for the specified |
| | | 1043 | | /// directory. The data returned does not include the directory's |
| | | 1044 | | /// list of subdirectories or files. |
| | | 1045 | | /// |
| | | 1046 | | /// For more information, see |
| | | 1047 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-directory-properties"> |
| | | 1048 | | /// Get Directory Properties</see>. |
| | | 1049 | | /// </summary> |
| | | 1050 | | /// <param name="cancellationToken"> |
| | | 1051 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1052 | | /// notifications that the operation should be cancelled. |
| | | 1053 | | /// </param> |
| | | 1054 | | /// <returns> |
| | | 1055 | | /// A <see cref="Response{StorageDirectoryProperties}"/> describing the |
| | | 1056 | | /// directory and its properties. |
| | | 1057 | | /// </returns> |
| | | 1058 | | /// <remarks> |
| | | 1059 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1060 | | /// a failure occurs. |
| | | 1061 | | /// </remarks> |
| | | 1062 | | public virtual Response<ShareDirectoryProperties> GetProperties( |
| | | 1063 | | CancellationToken cancellationToken = default) => |
| | 5 | 1064 | | GetPropertiesInternal( |
| | 5 | 1065 | | false, // async |
| | 5 | 1066 | | cancellationToken) |
| | 5 | 1067 | | .EnsureCompleted(); |
| | | 1068 | | |
| | | 1069 | | /// <summary> |
| | | 1070 | | /// The <see cref="GetPropertiesAsync"/> operation returns all |
| | | 1071 | | /// user-defined metadata and system properties for the specified |
| | | 1072 | | /// directory. The data returned does not include the directory's |
| | | 1073 | | /// list of subdirectories or files. |
| | | 1074 | | /// |
| | | 1075 | | /// For more information, see |
| | | 1076 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-directory-properties"> |
| | | 1077 | | /// Get Directory Properties</see>. |
| | | 1078 | | /// </summary> |
| | | 1079 | | /// <param name="cancellationToken"> |
| | | 1080 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1081 | | /// notifications that the operation should be cancelled. |
| | | 1082 | | /// </param> |
| | | 1083 | | /// <returns> |
| | | 1084 | | /// A <see cref="Response{StorageDirectoryProperties}"/> describing the |
| | | 1085 | | /// directory and its properties. |
| | | 1086 | | /// </returns> |
| | | 1087 | | /// <remarks> |
| | | 1088 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1089 | | /// a failure occurs. |
| | | 1090 | | /// </remarks> |
| | | 1091 | | public virtual async Task<Response<ShareDirectoryProperties>> GetPropertiesAsync( |
| | | 1092 | | CancellationToken cancellationToken = default) => |
| | 37 | 1093 | | await GetPropertiesInternal( |
| | 37 | 1094 | | true, // async |
| | 37 | 1095 | | cancellationToken) |
| | 37 | 1096 | | .ConfigureAwait(false); |
| | | 1097 | | |
| | | 1098 | | /// <summary> |
| | | 1099 | | /// The <see cref="GetPropertiesInternal"/> operation returns all |
| | | 1100 | | /// user-defined metadata and system properties for the specified |
| | | 1101 | | /// directory. The data returned does not include the directory's |
| | | 1102 | | /// list of subdirectories or files. |
| | | 1103 | | /// |
| | | 1104 | | /// For more information, see |
| | | 1105 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/get-directory-properties"> |
| | | 1106 | | /// Get Directory Properties</see>. |
| | | 1107 | | /// </summary> |
| | | 1108 | | /// <param name="async"> |
| | | 1109 | | /// Whether to invoke the operation asynchronously. |
| | | 1110 | | /// </param> |
| | | 1111 | | /// <param name="cancellationToken"> |
| | | 1112 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1113 | | /// notifications that the operation should be cancelled. |
| | | 1114 | | /// </param> |
| | | 1115 | | /// <param name="operationName"> |
| | | 1116 | | /// Optional. To indicate if the name of the operation. |
| | | 1117 | | /// </param> |
| | | 1118 | | /// <returns> |
| | | 1119 | | /// A <see cref="Response{StorageDirectoryProperties}"/> describing the |
| | | 1120 | | /// directory and its properties. |
| | | 1121 | | /// </returns> |
| | | 1122 | | /// <remarks> |
| | | 1123 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1124 | | /// a failure occurs. |
| | | 1125 | | /// </remarks> |
| | | 1126 | | private async Task<Response<ShareDirectoryProperties>> GetPropertiesInternal( |
| | | 1127 | | bool async, |
| | | 1128 | | CancellationToken cancellationToken, |
| | | 1129 | | string operationName = default) |
| | | 1130 | | { |
| | 50 | 1131 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 1132 | | { |
| | | 1133 | | Pipeline.LogMethodEnter( |
| | | 1134 | | nameof(ShareDirectoryClient), |
| | | 1135 | | message: |
| | | 1136 | | $"{nameof(Uri)}: {Uri}"); |
| | | 1137 | | try |
| | | 1138 | | { |
| | 50 | 1139 | | Response<RawStorageDirectoryProperties> response = await FileRestClient.Directory.GetPropertiesAsync |
| | 50 | 1140 | | ClientDiagnostics, |
| | 50 | 1141 | | Pipeline, |
| | 50 | 1142 | | Uri, |
| | 50 | 1143 | | version: Version.ToVersionString(), |
| | 50 | 1144 | | async: async, |
| | 50 | 1145 | | operationName: operationName ?? $"{nameof(ShareDirectoryClient)}.{nameof(GetProperties)}", |
| | 50 | 1146 | | cancellationToken: cancellationToken) |
| | 50 | 1147 | | .ConfigureAwait(false); |
| | | 1148 | | |
| | | 1149 | | // Return an exploding Response on 304 |
| | 40 | 1150 | | return response.IsUnavailable() ? |
| | 40 | 1151 | | response.GetRawResponse().AsNoBodyResponse<ShareDirectoryProperties>() : |
| | 40 | 1152 | | Response.FromValue(new ShareDirectoryProperties(response.Value), response.GetRawResponse()); |
| | | 1153 | | } |
| | 10 | 1154 | | catch (Exception ex) |
| | | 1155 | | { |
| | | 1156 | | Pipeline.LogException(ex); |
| | 10 | 1157 | | throw; |
| | | 1158 | | } |
| | | 1159 | | finally |
| | | 1160 | | { |
| | | 1161 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 1162 | | } |
| | | 1163 | | } |
| | 40 | 1164 | | } |
| | | 1165 | | #endregion GetProperties |
| | | 1166 | | |
| | | 1167 | | #region SetHttpHeaders |
| | | 1168 | | /// <summary> |
| | | 1169 | | /// The <see cref="SetHttpHeaders"/> operation sets system |
| | | 1170 | | /// properties on the directory. |
| | | 1171 | | /// |
| | | 1172 | | /// For more information, see |
| | | 1173 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-directory-properties"> |
| | | 1174 | | /// Set Directory Properties</see>. |
| | | 1175 | | /// </summary> |
| | | 1176 | | /// <param name="smbProperties"> |
| | | 1177 | | /// Optional SMB properties to set for the directory. |
| | | 1178 | | /// </param> |
| | | 1179 | | /// <param name="filePermission"> |
| | | 1180 | | /// Optional file permission to set for the directory. |
| | | 1181 | | /// </param> |
| | | 1182 | | /// <param name="cancellationToken"> |
| | | 1183 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1184 | | /// notifications that the operation should be cancelled. |
| | | 1185 | | /// </param> |
| | | 1186 | | /// <returns> |
| | | 1187 | | /// A <see cref="Response{StorageFileInfo}"/> describing the |
| | | 1188 | | /// state of the file. |
| | | 1189 | | /// </returns> |
| | | 1190 | | /// <remarks> |
| | | 1191 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1192 | | /// a failure occurs. |
| | | 1193 | | /// </remarks> |
| | | 1194 | | public virtual Response<ShareDirectoryInfo> SetHttpHeaders( |
| | | 1195 | | FileSmbProperties smbProperties = default, |
| | | 1196 | | string filePermission = default, |
| | | 1197 | | CancellationToken cancellationToken = default) => |
| | 4 | 1198 | | SetHttpHeadersInternal( |
| | 4 | 1199 | | smbProperties, |
| | 4 | 1200 | | filePermission, |
| | 4 | 1201 | | false, // async |
| | 4 | 1202 | | cancellationToken) |
| | 4 | 1203 | | .EnsureCompleted(); |
| | | 1204 | | |
| | | 1205 | | /// <summary> |
| | | 1206 | | /// The <see cref="SetHttpHeadersAsync"/> operation sets system |
| | | 1207 | | /// properties on the directory. |
| | | 1208 | | /// |
| | | 1209 | | /// For more information, see <see href="https://docs.microsoft.com/rest/api/storageservices/set-directory-prope |
| | | 1210 | | /// </summary> |
| | | 1211 | | /// <param name="smbProperties"> |
| | | 1212 | | /// Optional SMB properties to set for the directory. |
| | | 1213 | | /// </param> |
| | | 1214 | | /// <param name="filePermission"> |
| | | 1215 | | /// Optional file permission to set for the directory. |
| | | 1216 | | /// </param> |
| | | 1217 | | /// <param name="cancellationToken"> |
| | | 1218 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1219 | | /// notifications that the operation should be cancelled. |
| | | 1220 | | /// </param> |
| | | 1221 | | /// <returns> |
| | | 1222 | | /// A <see cref="Response{StorageFileInfo}"/> describing the |
| | | 1223 | | /// state of the file. |
| | | 1224 | | /// </returns> |
| | | 1225 | | /// <remarks> |
| | | 1226 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1227 | | /// a failure occurs. |
| | | 1228 | | /// </remarks> |
| | | 1229 | | public virtual async Task<Response<ShareDirectoryInfo>> SetHttpHeadersAsync( |
| | | 1230 | | FileSmbProperties smbProperties = default, |
| | | 1231 | | string filePermission = default, |
| | | 1232 | | CancellationToken cancellationToken = default) => |
| | 4 | 1233 | | await SetHttpHeadersInternal( |
| | 4 | 1234 | | smbProperties, |
| | 4 | 1235 | | filePermission, |
| | 4 | 1236 | | true, // async |
| | 4 | 1237 | | cancellationToken) |
| | 4 | 1238 | | .ConfigureAwait(false); |
| | | 1239 | | |
| | | 1240 | | /// <summary> |
| | | 1241 | | /// The <see cref="SetHttpHeadersInternal"/> operation sets system |
| | | 1242 | | /// properties on the directory. |
| | | 1243 | | /// |
| | | 1244 | | /// For more information, see |
| | | 1245 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-directory-properties"> |
| | | 1246 | | /// Set Directory Properties</see>. |
| | | 1247 | | /// </summary> |
| | | 1248 | | /// <param name="smbProperties"> |
| | | 1249 | | /// Optional SMB properties to set for the directory. |
| | | 1250 | | /// </param> |
| | | 1251 | | /// <param name="filePermission"> |
| | | 1252 | | /// Optional file permission to set ofr the directory. |
| | | 1253 | | /// </param> |
| | | 1254 | | /// <param name="async"> |
| | | 1255 | | /// Whether to invoke the operation asynchronously. |
| | | 1256 | | /// </param> |
| | | 1257 | | /// <param name="cancellationToken"> |
| | | 1258 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1259 | | /// notifications that the operation should be cancelled. |
| | | 1260 | | /// </param> |
| | | 1261 | | /// <returns> |
| | | 1262 | | /// A <see cref="Response{StorageFileInfo}"/> describing the |
| | | 1263 | | /// state of the file. |
| | | 1264 | | /// </returns> |
| | | 1265 | | /// <remarks> |
| | | 1266 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1267 | | /// a failure occurs. |
| | | 1268 | | /// </remarks> |
| | | 1269 | | private async Task<Response<ShareDirectoryInfo>> SetHttpHeadersInternal( |
| | | 1270 | | FileSmbProperties smbProperties, |
| | | 1271 | | string filePermission, |
| | | 1272 | | bool async, |
| | | 1273 | | CancellationToken cancellationToken) |
| | | 1274 | | { |
| | 8 | 1275 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 1276 | | { |
| | | 1277 | | Pipeline.LogMethodEnter( |
| | | 1278 | | nameof(ShareDirectoryClient), |
| | | 1279 | | message: |
| | | 1280 | | $"{nameof(Uri)}: {Uri}\n"); |
| | | 1281 | | try |
| | | 1282 | | { |
| | 8 | 1283 | | FileSmbProperties smbProps = smbProperties ?? new FileSmbProperties(); |
| | | 1284 | | |
| | 8 | 1285 | | ShareExtensions.AssertValidFilePermissionAndKey(filePermission, smbProps.FilePermissionKey); |
| | 4 | 1286 | | if (filePermission == null && smbProps.FilePermissionKey == null) |
| | | 1287 | | { |
| | 0 | 1288 | | filePermission = Constants.File.Preserve; |
| | | 1289 | | } |
| | | 1290 | | |
| | 4 | 1291 | | Response<RawStorageDirectoryInfo> response = await FileRestClient.Directory.SetPropertiesAsync( |
| | 4 | 1292 | | ClientDiagnostics, |
| | 4 | 1293 | | Pipeline, |
| | 4 | 1294 | | Uri, |
| | 4 | 1295 | | version: Version.ToVersionString(), |
| | 4 | 1296 | | fileAttributes: smbProps.FileAttributes?.ToAttributesString() ?? Constants.File.Preserve, |
| | 4 | 1297 | | filePermission: filePermission, |
| | 4 | 1298 | | fileCreationTime: smbProps.FileCreatedOn.ToFileDateTimeString() ?? Constants.File.Preserve, |
| | 4 | 1299 | | fileLastWriteTime: smbProps.FileLastWrittenOn.ToFileDateTimeString() ?? Constants.File.Preserve, |
| | 4 | 1300 | | filePermissionKey: smbProps.FilePermissionKey, |
| | 4 | 1301 | | async: async, |
| | 4 | 1302 | | operationName: $"{nameof(ShareDirectoryClient)}.{nameof(SetHttpHeaders)}", |
| | 4 | 1303 | | cancellationToken: cancellationToken) |
| | 4 | 1304 | | .ConfigureAwait(false); |
| | | 1305 | | |
| | 4 | 1306 | | return Response.FromValue(new ShareDirectoryInfo(response.Value), response.GetRawResponse()); |
| | | 1307 | | } |
| | 4 | 1308 | | catch (Exception ex) |
| | | 1309 | | { |
| | | 1310 | | Pipeline.LogException(ex); |
| | 4 | 1311 | | throw; |
| | | 1312 | | } |
| | | 1313 | | finally |
| | | 1314 | | { |
| | | 1315 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 1316 | | } |
| | | 1317 | | } |
| | 4 | 1318 | | } |
| | | 1319 | | #endregion SetHttpHeaders |
| | | 1320 | | |
| | | 1321 | | #region SetMetadata |
| | | 1322 | | /// <summary> |
| | | 1323 | | /// The <see cref="SetMetadata"/> operation sets one or more |
| | | 1324 | | /// user-defined name-value pairs for the specified directory. |
| | | 1325 | | /// |
| | | 1326 | | /// For more information, see |
| | | 1327 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-directory-metadata"> |
| | | 1328 | | /// Set Directory Metadata</see>. |
| | | 1329 | | /// </summary> |
| | | 1330 | | /// <param name="metadata"> |
| | | 1331 | | /// Custom metadata to set for this directory. |
| | | 1332 | | /// </param> |
| | | 1333 | | /// <param name="cancellationToken"> |
| | | 1334 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1335 | | /// notifications that the operation should be cancelled. |
| | | 1336 | | /// </param> |
| | | 1337 | | /// <returns> |
| | | 1338 | | /// A <see cref="Response{StorageDirectoryInfo}"/> if successful. |
| | | 1339 | | /// </returns> |
| | | 1340 | | /// <remarks> |
| | | 1341 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1342 | | /// a failure occurs. |
| | | 1343 | | /// </remarks> |
| | | 1344 | | public virtual Response<ShareDirectoryInfo> SetMetadata( |
| | | 1345 | | Metadata metadata, |
| | | 1346 | | CancellationToken cancellationToken = default) => |
| | 2 | 1347 | | SetMetadataInternal( |
| | 2 | 1348 | | metadata, |
| | 2 | 1349 | | false, // async |
| | 2 | 1350 | | cancellationToken) |
| | 2 | 1351 | | .EnsureCompleted(); |
| | | 1352 | | |
| | | 1353 | | /// <summary> |
| | | 1354 | | /// The <see cref="SetMetadataAsync"/> operation sets one or more |
| | | 1355 | | /// user-defined name-value pairs for the specified directory. |
| | | 1356 | | /// |
| | | 1357 | | /// For more information, see |
| | | 1358 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-directory-metadata"> |
| | | 1359 | | /// Set Directory Metadata</see>. |
| | | 1360 | | /// </summary> |
| | | 1361 | | /// <param name="metadata"> |
| | | 1362 | | /// Custom metadata to set for this directory. |
| | | 1363 | | /// </param> |
| | | 1364 | | /// <param name="cancellationToken"> |
| | | 1365 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1366 | | /// notifications that the operation should be cancelled. |
| | | 1367 | | /// </param> |
| | | 1368 | | /// <returns> |
| | | 1369 | | /// A <see cref="Response{StorageDirectoryInfo}"/> if successful. |
| | | 1370 | | /// </returns> |
| | | 1371 | | /// <remarks> |
| | | 1372 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1373 | | /// a failure occurs. |
| | | 1374 | | /// </remarks> |
| | | 1375 | | public virtual async Task<Response<ShareDirectoryInfo>> SetMetadataAsync( |
| | | 1376 | | Metadata metadata, |
| | | 1377 | | CancellationToken cancellationToken = default) => |
| | 2 | 1378 | | await SetMetadataInternal( |
| | 2 | 1379 | | metadata, |
| | 2 | 1380 | | true, // async |
| | 2 | 1381 | | cancellationToken) |
| | 2 | 1382 | | .ConfigureAwait(false); |
| | | 1383 | | |
| | | 1384 | | /// <summary> |
| | | 1385 | | /// The <see cref="SetMetadataInternal"/> operation sets one or more |
| | | 1386 | | /// user-defined name-value pairs for the specified directory. |
| | | 1387 | | /// |
| | | 1388 | | /// For more information, see |
| | | 1389 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-directory-metadata"> |
| | | 1390 | | /// Set Directory Metadata</see>. |
| | | 1391 | | /// </summary> |
| | | 1392 | | /// <param name="metadata"> |
| | | 1393 | | /// Custom metadata to set for this directory. |
| | | 1394 | | /// </param> |
| | | 1395 | | /// <param name="async"> |
| | | 1396 | | /// Whether to invoke the operation asynchronously. |
| | | 1397 | | /// </param> |
| | | 1398 | | /// <param name="cancellationToken"> |
| | | 1399 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1400 | | /// notifications that the operation should be cancelled. |
| | | 1401 | | /// </param> |
| | | 1402 | | /// <returns> |
| | | 1403 | | /// A <see cref="Response{StorageDirectoryInfo}"/> if successful. |
| | | 1404 | | /// </returns> |
| | | 1405 | | /// <remarks> |
| | | 1406 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1407 | | /// a failure occurs. |
| | | 1408 | | /// </remarks> |
| | | 1409 | | private async Task<Response<ShareDirectoryInfo>> SetMetadataInternal( |
| | | 1410 | | Metadata metadata, |
| | | 1411 | | bool async, |
| | | 1412 | | CancellationToken cancellationToken) |
| | | 1413 | | { |
| | 4 | 1414 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 1415 | | { |
| | | 1416 | | Pipeline.LogMethodEnter( |
| | | 1417 | | nameof(ShareDirectoryClient), |
| | | 1418 | | message: $"{nameof(Uri)}: {Uri}"); |
| | | 1419 | | try |
| | | 1420 | | { |
| | 4 | 1421 | | Response<RawStorageDirectoryInfo> response = await FileRestClient.Directory.SetMetadataAsync( |
| | 4 | 1422 | | ClientDiagnostics, |
| | 4 | 1423 | | Pipeline, |
| | 4 | 1424 | | Uri, |
| | 4 | 1425 | | version: Version.ToVersionString(), |
| | 4 | 1426 | | metadata: metadata, |
| | 4 | 1427 | | async: async, |
| | 4 | 1428 | | operationName: $"{nameof(ShareDirectoryClient)}.{nameof(SetMetadata)}", |
| | 4 | 1429 | | cancellationToken: cancellationToken) |
| | 4 | 1430 | | .ConfigureAwait(false); |
| | | 1431 | | |
| | 2 | 1432 | | return Response.FromValue(new ShareDirectoryInfo(response.Value), response.GetRawResponse()); |
| | | 1433 | | } |
| | 2 | 1434 | | catch (Exception ex) |
| | | 1435 | | { |
| | | 1436 | | Pipeline.LogException(ex); |
| | 2 | 1437 | | throw; |
| | | 1438 | | } |
| | | 1439 | | finally |
| | | 1440 | | { |
| | | 1441 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 1442 | | } |
| | | 1443 | | } |
| | 2 | 1444 | | } |
| | | 1445 | | #endregion SetMetadata |
| | | 1446 | | |
| | | 1447 | | #region GetFilesAndDirectories |
| | | 1448 | | /// <summary> |
| | | 1449 | | /// The <see cref="GetFilesAndDirectories"/> operation returns an async |
| | | 1450 | | /// sequence of files and subdirectories in this directory. |
| | | 1451 | | /// Enumerating the files and directories may make multiple requests |
| | | 1452 | | /// to the service while fetching all the values. |
| | | 1453 | | /// |
| | | 1454 | | /// For more information, see |
| | | 1455 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-directories-and-files"> |
| | | 1456 | | /// List Directories and Files</see>. |
| | | 1457 | | /// </summary> |
| | | 1458 | | /// <param name="prefix"> |
| | | 1459 | | /// Optional string that filters the results to return only |
| | | 1460 | | /// files and directories whose name begins with the specified prefix. |
| | | 1461 | | /// </param> |
| | | 1462 | | /// <param name="cancellationToken"> |
| | | 1463 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1464 | | /// notifications that the operation should be cancelled. |
| | | 1465 | | /// </param> |
| | | 1466 | | /// <returns> |
| | | 1467 | | /// An <see cref="IEnumerable{T}" /> of <see cref="Response{StorageFileItem}"/> |
| | | 1468 | | /// describing the items in the directory. |
| | | 1469 | | /// </returns> |
| | | 1470 | | /// <remarks> |
| | | 1471 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1472 | | /// a failure occurs. |
| | | 1473 | | /// </remarks> |
| | | 1474 | | public virtual Pageable<ShareFileItem> GetFilesAndDirectories( |
| | | 1475 | | string prefix = default, |
| | | 1476 | | CancellationToken cancellationToken = default) => |
| | 27 | 1477 | | new GetFilesAndDirectoriesAsyncCollection(this, prefix).ToSyncCollection(cancellationToken); |
| | | 1478 | | |
| | | 1479 | | /// <summary> |
| | | 1480 | | /// The <see cref="GetFilesAndDirectoriesAsync"/> operation returns an |
| | | 1481 | | /// async collection of files and subdirectories in this directory. |
| | | 1482 | | /// Enumerating the files and directories may make multiple requests |
| | | 1483 | | /// to the service while fetching all the values. |
| | | 1484 | | /// |
| | | 1485 | | /// For more information, see |
| | | 1486 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-directories-and-files"> |
| | | 1487 | | /// List Directories and Files</see>. |
| | | 1488 | | /// </summary> |
| | | 1489 | | /// <param name="prefix"> |
| | | 1490 | | /// Optional string that filters the results to return only |
| | | 1491 | | /// files and directories whose name begins with the specified prefix. |
| | | 1492 | | /// </param> |
| | | 1493 | | /// <param name="cancellationToken"> |
| | | 1494 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1495 | | /// notifications that the operation should be cancelled. |
| | | 1496 | | /// </param> |
| | | 1497 | | /// <returns> |
| | | 1498 | | /// A <see cref="AsyncPageable{T}"/> describing the |
| | | 1499 | | /// items in the directory. |
| | | 1500 | | /// </returns> |
| | | 1501 | | /// <remarks> |
| | | 1502 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1503 | | /// a failure occurs. |
| | | 1504 | | /// </remarks> |
| | | 1505 | | public virtual AsyncPageable<ShareFileItem> GetFilesAndDirectoriesAsync( |
| | | 1506 | | string prefix = default, |
| | | 1507 | | CancellationToken cancellationToken = default) => |
| | 27 | 1508 | | new GetFilesAndDirectoriesAsyncCollection(this, prefix).ToAsyncCollection(cancellationToken); |
| | | 1509 | | |
| | | 1510 | | /// <summary> |
| | | 1511 | | /// The <see cref="GetFilesAndDirectoriesInternal"/> operation returns a |
| | | 1512 | | /// single segment of files and subdirectories in this directory, starting |
| | | 1513 | | /// from the specified <paramref name="marker"/>. |
| | | 1514 | | /// |
| | | 1515 | | /// For more information, see |
| | | 1516 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-directories-and-files"> |
| | | 1517 | | /// List Directories and Files</see>. |
| | | 1518 | | /// </summary> |
| | | 1519 | | /// <param name="marker"> |
| | | 1520 | | /// An optional string value that identifies the segment of the list |
| | | 1521 | | /// of items to be returned with the next listing operation. The |
| | | 1522 | | /// operation returns a non-empty <see cref="FilesAndDirectoriesSegment.NextMarker"/> |
| | | 1523 | | /// if the listing operation did not return all items remaining to be |
| | | 1524 | | /// listed with the current segment. The NextMarker value can |
| | | 1525 | | /// be used as the value for the <paramref name="marker"/> parameter |
| | | 1526 | | /// in a subsequent call to request the next segment of list items. |
| | | 1527 | | /// </param> |
| | | 1528 | | /// <param name="prefix"> |
| | | 1529 | | /// Optional string that filters the results to return only |
| | | 1530 | | /// files and directories whose name begins with the specified prefix. |
| | | 1531 | | /// </param> |
| | | 1532 | | /// <param name="pageSizeHint"> |
| | | 1533 | | /// Gets or sets a value indicating the size of the page that should be |
| | | 1534 | | /// requested. |
| | | 1535 | | /// </param> |
| | | 1536 | | /// <param name="async"> |
| | | 1537 | | /// Whether to invoke the operation asynchronously. |
| | | 1538 | | /// </param> |
| | | 1539 | | /// <param name="cancellationToken"> |
| | | 1540 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1541 | | /// notifications that the operation should be cancelled. |
| | | 1542 | | /// </param> |
| | | 1543 | | /// <returns> |
| | | 1544 | | /// A <see cref="Response{FilesAndDirectoriesSegment}"/> describing a |
| | | 1545 | | /// segment of the items in the directory. |
| | | 1546 | | /// </returns> |
| | | 1547 | | /// <remarks> |
| | | 1548 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1549 | | /// a failure occurs. |
| | | 1550 | | /// </remarks> |
| | | 1551 | | internal async Task<Response<FilesAndDirectoriesSegment>> GetFilesAndDirectoriesInternal( |
| | | 1552 | | string marker, |
| | | 1553 | | string prefix, |
| | | 1554 | | int? pageSizeHint, |
| | | 1555 | | bool async, |
| | | 1556 | | CancellationToken cancellationToken) |
| | | 1557 | | { |
| | 54 | 1558 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 1559 | | { |
| | | 1560 | | Pipeline.LogMethodEnter( |
| | | 1561 | | nameof(ShareDirectoryClient), |
| | | 1562 | | message: |
| | | 1563 | | $"{nameof(Uri)}: {Uri}\n" + |
| | | 1564 | | $"{nameof(marker)}: {marker}\n" + |
| | | 1565 | | $"{nameof(prefix)}: {prefix}"); |
| | | 1566 | | try |
| | | 1567 | | { |
| | 54 | 1568 | | return await FileRestClient.Directory.ListFilesAndDirectoriesSegmentAsync( |
| | 54 | 1569 | | ClientDiagnostics, |
| | 54 | 1570 | | Pipeline, |
| | 54 | 1571 | | Uri, |
| | 54 | 1572 | | version: Version.ToVersionString(), |
| | 54 | 1573 | | marker: marker, |
| | 54 | 1574 | | prefix: prefix, |
| | 54 | 1575 | | maxresults: pageSizeHint, |
| | 54 | 1576 | | async: async, |
| | 54 | 1577 | | operationName: $"{nameof(ShareDirectoryClient)}.{nameof(GetFilesAndDirectories)}", |
| | 54 | 1578 | | cancellationToken: cancellationToken) |
| | 54 | 1579 | | .ConfigureAwait(false); |
| | | 1580 | | } |
| | 2 | 1581 | | catch (Exception ex) |
| | | 1582 | | { |
| | | 1583 | | Pipeline.LogException(ex); |
| | 2 | 1584 | | throw; |
| | | 1585 | | } |
| | | 1586 | | finally |
| | | 1587 | | { |
| | | 1588 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 1589 | | } |
| | | 1590 | | } |
| | 52 | 1591 | | } |
| | | 1592 | | #endregion GetFilesAndDirectories |
| | | 1593 | | |
| | | 1594 | | #region GetHandles |
| | | 1595 | | /// <summary> |
| | | 1596 | | /// The <see cref="GetHandles"/> operation returns an async sequence |
| | | 1597 | | /// of the open handles on a directory or a file. Enumerating the |
| | | 1598 | | /// handles may make multiple requests to the service while fetching |
| | | 1599 | | /// all the values. |
| | | 1600 | | /// |
| | | 1601 | | /// For more information, see |
| | | 1602 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-handles"> |
| | | 1603 | | /// List Handles</see>. |
| | | 1604 | | /// </summary> |
| | | 1605 | | /// <param name="recursive"> |
| | | 1606 | | /// Optional. A boolean value that specifies if the operation should also apply to the files and subdirectories |
| | | 1607 | | /// </param> |
| | | 1608 | | /// <param name="cancellationToken"> |
| | | 1609 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1610 | | /// notifications that the operation should be cancelled. |
| | | 1611 | | /// </param> |
| | | 1612 | | /// <returns> |
| | | 1613 | | /// An <see cref="IEnumerable{T}"/> of <see cref="Response{StorageHandle}"/> |
| | | 1614 | | /// describing the handles in the directory. |
| | | 1615 | | /// </returns> |
| | | 1616 | | /// <remarks> |
| | | 1617 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1618 | | /// a failure occurs. |
| | | 1619 | | /// </remarks> |
| | | 1620 | | public virtual Pageable<ShareFileHandle> GetHandles( |
| | | 1621 | | bool? recursive = default, |
| | | 1622 | | CancellationToken cancellationToken = default) => |
| | 3 | 1623 | | new GetDirectoryHandlesAsyncCollection(this, recursive).ToSyncCollection(cancellationToken); |
| | | 1624 | | |
| | | 1625 | | /// <summary> |
| | | 1626 | | /// The <see cref="GetHandlesAsync"/> operation returns an async |
| | | 1627 | | /// sequence of the open handles on a directory or a file. |
| | | 1628 | | /// Enumerating the handles may make multiple requests to the service |
| | | 1629 | | /// while fetching all the values. |
| | | 1630 | | /// |
| | | 1631 | | /// For more information, see |
| | | 1632 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-handles"> |
| | | 1633 | | /// List Handles</see>. |
| | | 1634 | | /// </summary> |
| | | 1635 | | /// <param name="recursive"> |
| | | 1636 | | /// Optional. A boolean value that specifies if the operation should also apply to the files and subdirectories |
| | | 1637 | | /// </param> |
| | | 1638 | | /// <param name="cancellationToken"> |
| | | 1639 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1640 | | /// notifications that the operation should be cancelled. |
| | | 1641 | | /// </param> |
| | | 1642 | | /// <returns> |
| | | 1643 | | /// A <see cref="AsyncPageable{T}"/> describing the |
| | | 1644 | | /// handles on the directory. |
| | | 1645 | | /// </returns> |
| | | 1646 | | /// <remarks> |
| | | 1647 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1648 | | /// a failure occurs. |
| | | 1649 | | /// </remarks> |
| | | 1650 | | public virtual AsyncPageable<ShareFileHandle> GetHandlesAsync( |
| | | 1651 | | bool? recursive = default, |
| | | 1652 | | CancellationToken cancellationToken = default) => |
| | 4 | 1653 | | new GetDirectoryHandlesAsyncCollection(this, recursive).ToAsyncCollection(cancellationToken); |
| | | 1654 | | |
| | | 1655 | | /// <summary> |
| | | 1656 | | /// The <see cref="GetHandlesAsync"/> operation returns a list of open |
| | | 1657 | | /// handles on a directory or a file. |
| | | 1658 | | /// |
| | | 1659 | | /// For more information, see |
| | | 1660 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-handles"> |
| | | 1661 | | /// List Handles</see>. |
| | | 1662 | | /// </summary> |
| | | 1663 | | /// <param name="marker"> |
| | | 1664 | | /// An optional string value that identifies the segment of the list |
| | | 1665 | | /// of items to be returned with the next listing operation. The |
| | | 1666 | | /// operation returns a non-empty <see cref="StorageHandlesSegment.NextMarker"/> |
| | | 1667 | | /// if the listing operation did not return all items remaining to be |
| | | 1668 | | /// listed with the current segment. The NextMarker value can |
| | | 1669 | | /// be used as the value for the <paramref name="marker"/> parameter |
| | | 1670 | | /// in a subsequent call to request the next segment of list items. |
| | | 1671 | | /// </param> |
| | | 1672 | | /// <param name="maxResults"> |
| | | 1673 | | /// Optional. Specifies the maximum number of handles taken on files and/or directories to return. |
| | | 1674 | | /// </param> |
| | | 1675 | | /// <param name="recursive"> |
| | | 1676 | | /// Optional. A boolean value that specifies if the operation should also apply to the files and subdirectories |
| | | 1677 | | /// </param> |
| | | 1678 | | /// <param name="async"> |
| | | 1679 | | /// Whether to invoke the operation asynchronously. |
| | | 1680 | | /// </param> |
| | | 1681 | | /// <param name="cancellationToken"> |
| | | 1682 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1683 | | /// notifications that the operation should be cancelled. |
| | | 1684 | | /// </param> |
| | | 1685 | | /// <returns> |
| | | 1686 | | /// A <see cref="Response{StorageHandlesSegment}"/> describing a |
| | | 1687 | | /// segment of the handles in the directory. |
| | | 1688 | | /// </returns> |
| | | 1689 | | /// <remarks> |
| | | 1690 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1691 | | /// a failure occurs. |
| | | 1692 | | /// </remarks> |
| | | 1693 | | internal async Task<Response<StorageHandlesSegment>> GetHandlesInternal( |
| | | 1694 | | string marker, |
| | | 1695 | | int? maxResults, |
| | | 1696 | | bool? recursive, |
| | | 1697 | | bool async, |
| | | 1698 | | CancellationToken cancellationToken) |
| | | 1699 | | { |
| | 5 | 1700 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 1701 | | { |
| | | 1702 | | Pipeline.LogMethodEnter( |
| | | 1703 | | nameof(ShareDirectoryClient), |
| | | 1704 | | message: |
| | | 1705 | | $"{nameof(Uri)}: {Uri}\n" + |
| | | 1706 | | $"{nameof(marker)}: {marker}\n" + |
| | | 1707 | | $"{nameof(maxResults)}: {maxResults}\n" + |
| | | 1708 | | $"{nameof(recursive)}: {recursive}"); |
| | | 1709 | | try |
| | | 1710 | | { |
| | 5 | 1711 | | return await FileRestClient.Directory.ListHandlesAsync( |
| | 5 | 1712 | | ClientDiagnostics, |
| | 5 | 1713 | | Pipeline, |
| | 5 | 1714 | | Uri, |
| | 5 | 1715 | | version: Version.ToVersionString(), |
| | 5 | 1716 | | marker: marker, |
| | 5 | 1717 | | maxresults: maxResults, |
| | 5 | 1718 | | recursive: recursive, |
| | 5 | 1719 | | async: async, |
| | 5 | 1720 | | operationName: $"{nameof(ShareDirectoryClient)}.{nameof(GetHandles)}", |
| | 5 | 1721 | | cancellationToken: cancellationToken) |
| | 5 | 1722 | | .ConfigureAwait(false); |
| | | 1723 | | } |
| | 2 | 1724 | | catch (Exception ex) |
| | | 1725 | | { |
| | | 1726 | | Pipeline.LogException(ex); |
| | 2 | 1727 | | throw; |
| | | 1728 | | } |
| | | 1729 | | finally |
| | | 1730 | | { |
| | | 1731 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 1732 | | } |
| | | 1733 | | } |
| | 3 | 1734 | | } |
| | | 1735 | | #endregion GetHandles |
| | | 1736 | | |
| | | 1737 | | #region ForceCloseHandles |
| | | 1738 | | /// <summary> |
| | | 1739 | | /// The <see cref="ForceCloseHandle"/> operation closes a handle opened on a directory |
| | | 1740 | | /// or a file at the service. It supports closing a single handle specified by <paramref name="handleId"/>. |
| | | 1741 | | /// |
| | | 1742 | | /// This API is intended to be used alongside <see cref="GetHandles"/> to force close handles that |
| | | 1743 | | /// block operations, such as renaming a directory. These handles may have leaked or been lost track of by |
| | | 1744 | | /// SMB clients. The API has client-side impact on the handle being closed, including user visible |
| | | 1745 | | /// errors due to failed attempts to read or write files. This API is not intended for use as a replacement |
| | | 1746 | | /// or alternative for SMB close. |
| | | 1747 | | /// |
| | | 1748 | | /// For more information, see |
| | | 1749 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/force-close-handles"> |
| | | 1750 | | /// Force Close Handles</see>. |
| | | 1751 | | /// </summary> |
| | | 1752 | | /// <param name="handleId"> |
| | | 1753 | | /// Specifies the handle ID to be closed. |
| | | 1754 | | /// </param> |
| | | 1755 | | /// <param name="cancellationToken"> |
| | | 1756 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1757 | | /// notifications that the operation should be cancelled. |
| | | 1758 | | /// </param> |
| | | 1759 | | /// <returns> |
| | | 1760 | | /// A <see cref="Response{CloseHandlesResult}"/> describing the status of the |
| | | 1761 | | /// <see cref="ForceCloseHandle"/> operation. |
| | | 1762 | | /// </returns> |
| | | 1763 | | /// <remarks> |
| | | 1764 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1765 | | /// a failure occurs. |
| | | 1766 | | /// </remarks> |
| | | 1767 | | public virtual Response<CloseHandlesResult> ForceCloseHandle( |
| | | 1768 | | string handleId, |
| | | 1769 | | CancellationToken cancellationToken = default) |
| | | 1770 | | { |
| | 1 | 1771 | | Response<StorageClosedHandlesSegment> response = ForceCloseHandlesInternal( |
| | 1 | 1772 | | handleId, |
| | 1 | 1773 | | null, |
| | 1 | 1774 | | null, |
| | 1 | 1775 | | false, // async |
| | 1 | 1776 | | cancellationToken, |
| | 1 | 1777 | | $"{nameof(ShareDirectoryClient)}.{nameof(ForceCloseHandle)}") |
| | 1 | 1778 | | .EnsureCompleted(); |
| | | 1779 | | |
| | 0 | 1780 | | return Response.FromValue( |
| | 0 | 1781 | | response.ToCloseHandlesResult(), |
| | 0 | 1782 | | response.GetRawResponse()); |
| | | 1783 | | } |
| | | 1784 | | |
| | | 1785 | | /// <summary> |
| | | 1786 | | /// The <see cref="ForceCloseHandle"/> operation closes a handle opened on a directory |
| | | 1787 | | /// or a file at the service. It supports closing a single handle specified by <paramref name="handleId"/>. |
| | | 1788 | | /// |
| | | 1789 | | /// This API is intended to be used alongside <see cref="GetHandlesAsync"/> to force close handles that |
| | | 1790 | | /// block operations, such as renaming a directory. These handles may have leaked or been lost track of by |
| | | 1791 | | /// SMB clients. The API has client-side impact on the handle being closed, including user visible |
| | | 1792 | | /// errors due to failed attempts to read or write files. This API is not intended for use as a replacement |
| | | 1793 | | /// or alternative for SMB close. |
| | | 1794 | | /// |
| | | 1795 | | /// For more information, see |
| | | 1796 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/force-close-handles"> |
| | | 1797 | | /// Force Close Handles</see>. |
| | | 1798 | | /// </summary> |
| | | 1799 | | /// <param name="handleId"> |
| | | 1800 | | /// Specifies the handle ID to be closed. |
| | | 1801 | | /// </param> |
| | | 1802 | | /// <param name="cancellationToken"> |
| | | 1803 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1804 | | /// notifications that the operation should be cancelled. |
| | | 1805 | | /// </param> |
| | | 1806 | | /// <returns> |
| | | 1807 | | /// A <see cref="Response{CloseHandlesResult}"/> describing the status of the |
| | | 1808 | | /// <see cref="ForceCloseHandleAsync"/> operation. |
| | | 1809 | | /// </returns> |
| | | 1810 | | /// <remarks> |
| | | 1811 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1812 | | /// a failure occurs. |
| | | 1813 | | /// </remarks> |
| | | 1814 | | public virtual async Task<Response<CloseHandlesResult>> ForceCloseHandleAsync( |
| | | 1815 | | string handleId, |
| | | 1816 | | CancellationToken cancellationToken = default) |
| | | 1817 | | { |
| | 1 | 1818 | | Response<StorageClosedHandlesSegment> response = await ForceCloseHandlesInternal( |
| | 1 | 1819 | | handleId, |
| | 1 | 1820 | | null, |
| | 1 | 1821 | | null, |
| | 1 | 1822 | | true, // async |
| | 1 | 1823 | | cancellationToken, |
| | 1 | 1824 | | $"{nameof(ShareDirectoryClient)}.{nameof(ForceCloseHandle)}") |
| | 1 | 1825 | | .ConfigureAwait(false); |
| | | 1826 | | |
| | 0 | 1827 | | return Response.FromValue( |
| | 0 | 1828 | | response.ToCloseHandlesResult(), |
| | 0 | 1829 | | response.GetRawResponse()); |
| | 0 | 1830 | | } |
| | | 1831 | | |
| | | 1832 | | /// <summary> |
| | | 1833 | | /// The <see cref="ForceCloseAllHandles"/> operation closes all handles opened on a directory |
| | | 1834 | | /// or a file at the service. It optionally supports recursively closing handles on subresources |
| | | 1835 | | /// when the resource is a directory. |
| | | 1836 | | /// |
| | | 1837 | | /// This API is intended to be used alongside <see cref="GetHandles"/> to force close handles that |
| | | 1838 | | /// block operations, such as renaming a directory. These handles may have leaked or been lost track of by |
| | | 1839 | | /// SMB clients. The API has client-side impact on the handle being closed, including user visible |
| | | 1840 | | /// errors due to failed attempts to read or write files. This API is not intended for use as a replacement |
| | | 1841 | | /// or alternative for SMB close. |
| | | 1842 | | /// |
| | | 1843 | | /// For more information, see |
| | | 1844 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/force-close-handles"> |
| | | 1845 | | /// Force Close Handles</see>. |
| | | 1846 | | /// </summary> |
| | | 1847 | | /// <param name="recursive"> |
| | | 1848 | | /// Optional. A boolean value that specifies if the operation should also apply to the files and subdirectories |
| | | 1849 | | /// </param> |
| | | 1850 | | /// <param name="cancellationToken"> |
| | | 1851 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1852 | | /// notifications that the operation should be cancelled. |
| | | 1853 | | /// </param> |
| | | 1854 | | /// <returns> |
| | | 1855 | | /// A <see cref="CloseHandlesResult"/> describing the status of the |
| | | 1856 | | /// <see cref="ForceCloseAllHandles"/> operation. |
| | | 1857 | | /// </returns> |
| | | 1858 | | /// <remarks> |
| | | 1859 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1860 | | /// a failure occurs. |
| | | 1861 | | /// </remarks> |
| | | 1862 | | public virtual CloseHandlesResult ForceCloseAllHandles( |
| | | 1863 | | bool? recursive = default, |
| | | 1864 | | CancellationToken cancellationToken = default) => |
| | 3 | 1865 | | ForceCloseAllHandlesInternal( |
| | 3 | 1866 | | recursive, |
| | 3 | 1867 | | false, // async |
| | 3 | 1868 | | cancellationToken) |
| | 3 | 1869 | | .EnsureCompleted(); |
| | | 1870 | | |
| | | 1871 | | /// <summary> |
| | | 1872 | | /// The <see cref="ForceCloseAllHandlesAsync"/> operation closes all handles opened on a directory |
| | | 1873 | | /// or a file at the service. It optionally supports recursively closing handles on subresources |
| | | 1874 | | /// when the resource is a directory. |
| | | 1875 | | /// |
| | | 1876 | | /// This API is intended to be used alongside <see cref="GetHandlesAsync"/> to force close handles that |
| | | 1877 | | /// block operations, such as renaming a directory. These handles may have leaked or been lost track of by |
| | | 1878 | | /// SMB clients. The API has client-side impact on the handle being closed, including user visible |
| | | 1879 | | /// errors due to failed attempts to read or write files. This API is not intended for use as a replacement |
| | | 1880 | | /// or alternative for SMB close. |
| | | 1881 | | /// |
| | | 1882 | | /// FFor more information, see |
| | | 1883 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/force-close-handles"> |
| | | 1884 | | /// Force Close Handles</see>. |
| | | 1885 | | /// </summary> |
| | | 1886 | | /// <param name="recursive"> |
| | | 1887 | | /// Optional. A boolean value that specifies if the operation should also apply to the files and subdirectories |
| | | 1888 | | /// </param> |
| | | 1889 | | /// <param name="cancellationToken"> |
| | | 1890 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1891 | | /// notifications that the operation should be cancelled. |
| | | 1892 | | /// </param> |
| | | 1893 | | /// <returns> |
| | | 1894 | | /// A <see cref="CloseHandlesResult"/> describing the status of the |
| | | 1895 | | /// <see cref="ForceCloseAllHandlesAsync"/> operation. |
| | | 1896 | | /// </returns> |
| | | 1897 | | /// <remarks> |
| | | 1898 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1899 | | /// a failure occurs. |
| | | 1900 | | /// </remarks> |
| | | 1901 | | public virtual async Task<CloseHandlesResult> ForceCloseAllHandlesAsync( |
| | | 1902 | | bool? recursive = default, |
| | | 1903 | | CancellationToken cancellationToken = default) => |
| | 3 | 1904 | | await ForceCloseAllHandlesInternal( |
| | 3 | 1905 | | recursive, |
| | 3 | 1906 | | true, // async |
| | 3 | 1907 | | cancellationToken) |
| | 3 | 1908 | | .ConfigureAwait(false); |
| | | 1909 | | |
| | | 1910 | | /// <summary> |
| | | 1911 | | /// The <see cref="ForceCloseAllHandlesAsync"/> operation closes all handles opened on a directory |
| | | 1912 | | /// or a file at the service. It optionally supports recursively closing handles on subresources |
| | | 1913 | | /// when the resource is a directory. |
| | | 1914 | | /// |
| | | 1915 | | /// This API is intended to be used alongside <see cref="GetHandlesAsync"/> to force close handles that |
| | | 1916 | | /// block operations. These handles may have leaked or been lost track of by |
| | | 1917 | | /// SMB clients. The API has client-side impact on the handle being closed, including user visible |
| | | 1918 | | /// errors due to failed attempts to read or write files. This API is not intended for use as a replacement |
| | | 1919 | | /// or alternative for SMB close. |
| | | 1920 | | /// |
| | | 1921 | | /// For more information, see |
| | | 1922 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/force-close-handles"> |
| | | 1923 | | /// Force Close Handles</see>. |
| | | 1924 | | /// </summary> |
| | | 1925 | | /// <param name="recursive"> |
| | | 1926 | | /// Optional. A boolean value that specifies if the operation should also apply to the files and subdirectories |
| | | 1927 | | /// </param> |
| | | 1928 | | /// <param name="async"> |
| | | 1929 | | /// Whether to invoke the operation asynchronously. |
| | | 1930 | | /// </param> |
| | | 1931 | | /// <param name="cancellationToken"> |
| | | 1932 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 1933 | | /// notifications that the operation should be cancelled. |
| | | 1934 | | /// </param> |
| | | 1935 | | /// <returns> |
| | | 1936 | | /// A <see cref="CloseHandlesResult"/> describing the status of the |
| | | 1937 | | /// <see cref="ForceCloseAllHandlesInternal"/> operation. |
| | | 1938 | | /// </returns> |
| | | 1939 | | /// <remarks> |
| | | 1940 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 1941 | | /// a failure occurs. |
| | | 1942 | | /// </remarks> |
| | | 1943 | | private async Task<CloseHandlesResult> ForceCloseAllHandlesInternal( |
| | | 1944 | | bool? recursive, |
| | | 1945 | | bool async, |
| | | 1946 | | CancellationToken cancellationToken) |
| | | 1947 | | { |
| | 6 | 1948 | | int handlesClosed = 0; |
| | 6 | 1949 | | int handlesFailed = 0; |
| | 6 | 1950 | | string marker = null; |
| | | 1951 | | do |
| | | 1952 | | { |
| | 6 | 1953 | | Response<StorageClosedHandlesSegment> response = |
| | 6 | 1954 | | await ForceCloseHandlesInternal( |
| | 6 | 1955 | | Constants.CloseAllHandles, |
| | 6 | 1956 | | marker, |
| | 6 | 1957 | | recursive, |
| | 6 | 1958 | | async, |
| | 6 | 1959 | | cancellationToken) |
| | 6 | 1960 | | .ConfigureAwait(false); |
| | 4 | 1961 | | marker = response.Value.Marker; |
| | 4 | 1962 | | handlesClosed += response.Value.NumberOfHandlesClosed; |
| | 4 | 1963 | | handlesFailed += response.Value.NumberOfHandlesFailedToClose; |
| | | 1964 | | |
| | 4 | 1965 | | } while (!string.IsNullOrEmpty(marker)); |
| | | 1966 | | |
| | 4 | 1967 | | return new CloseHandlesResult() |
| | 4 | 1968 | | { |
| | 4 | 1969 | | ClosedHandlesCount = handlesClosed, |
| | 4 | 1970 | | FailedHandlesCount = handlesFailed |
| | 4 | 1971 | | }; |
| | 4 | 1972 | | } |
| | | 1973 | | |
| | | 1974 | | /// <summary> |
| | | 1975 | | /// The <see cref="ForceCloseAllHandlesAsync"/> operation closes a handle or handles opened on a directory |
| | | 1976 | | /// or a file at the service. It supports closing a single handle specified by <paramref name="handleId"/> on a |
| | | 1977 | | /// directory or closing all handles opened on that resource. It optionally supports recursively closing |
| | | 1978 | | /// handles on subresources when the resource is a directory. |
| | | 1979 | | /// |
| | | 1980 | | /// This API is intended to be used alongside <see cref="GetHandlesAsync"/> to force close handles that |
| | | 1981 | | /// block operations, such as renaming a directory. These handles may have leaked or been lost track of by |
| | | 1982 | | /// SMB clients. The API has client-side impact on the handle being closed, including user visible |
| | | 1983 | | /// errors due to failed attempts to read or write files. This API is not intended for use as a replacement |
| | | 1984 | | /// or alternative for SMB close. |
| | | 1985 | | /// |
| | | 1986 | | /// For more information, see |
| | | 1987 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/force-close-handles"> |
| | | 1988 | | /// Force Close Handles</see>. |
| | | 1989 | | /// </summary> |
| | | 1990 | | /// <param name="handleId"> |
| | | 1991 | | /// Optional. Specifies the handle ID to be closed. If not specified, or if equal to "*", will close a |
| | | 1992 | | /// </param> |
| | | 1993 | | /// <param name="marker"> |
| | | 1994 | | /// An optional string value that identifies the segment of the handles |
| | | 1995 | | /// to be closed with the next call to <see cref="ForceCloseAllHandlesAsync"/>. The |
| | | 1996 | | /// operation returns a non-empty <see cref="StorageClosedHandlesSegment.Marker"/> |
| | | 1997 | | /// if the operation did not return all items remaining to be |
| | | 1998 | | /// closed with the current segment. The NextMarker value can |
| | | 1999 | | /// be used as the value for the <paramref name="marker"/> parameter |
| | | 2000 | | /// in a subsequent call to request the closure of the next segment of handles. |
| | | 2001 | | /// </param> |
| | | 2002 | | /// <param name="recursive"> |
| | | 2003 | | /// Optional. A boolean value that specifies if the operation should also apply to the files and subdirectories |
| | | 2004 | | /// </param> |
| | | 2005 | | /// <param name="async"> |
| | | 2006 | | /// Whether to invoke the operation asynchronously. |
| | | 2007 | | /// </param> |
| | | 2008 | | /// <param name="cancellationToken"> |
| | | 2009 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2010 | | /// notifications that the operation should be cancelled. |
| | | 2011 | | /// </param> |
| | | 2012 | | /// <param name="operationName"> |
| | | 2013 | | /// Optional. Used to indicate the name of the operation. |
| | | 2014 | | /// </param> |
| | | 2015 | | /// <returns> |
| | | 2016 | | /// A <see cref="Response{StorageClosedHandlesSegment}"/> describing a |
| | | 2017 | | /// segment of the handles closed. |
| | | 2018 | | /// </returns> |
| | | 2019 | | /// <remarks> |
| | | 2020 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2021 | | /// a failure occurs. |
| | | 2022 | | /// </remarks> |
| | | 2023 | | private async Task<Response<StorageClosedHandlesSegment>> ForceCloseHandlesInternal( |
| | | 2024 | | string handleId, |
| | | 2025 | | string marker, |
| | | 2026 | | bool? recursive, |
| | | 2027 | | bool async, |
| | | 2028 | | CancellationToken cancellationToken, |
| | | 2029 | | string operationName = null) |
| | | 2030 | | { |
| | 8 | 2031 | | using (Pipeline.BeginLoggingScope(nameof(ShareDirectoryClient))) |
| | | 2032 | | { |
| | | 2033 | | Pipeline.LogMethodEnter( |
| | | 2034 | | nameof(ShareDirectoryClient), |
| | | 2035 | | message: |
| | | 2036 | | $"{nameof(Uri)}: {Uri}\n" + |
| | | 2037 | | $"{nameof(handleId)}: {handleId}\n" + |
| | | 2038 | | $"{nameof(marker)}: {marker}\n" + |
| | | 2039 | | $"{nameof(recursive)}: {recursive}"); |
| | | 2040 | | try |
| | | 2041 | | { |
| | 8 | 2042 | | return await FileRestClient.Directory.ForceCloseHandlesAsync( |
| | 8 | 2043 | | ClientDiagnostics, |
| | 8 | 2044 | | Pipeline, |
| | 8 | 2045 | | Uri, |
| | 8 | 2046 | | marker: marker, |
| | 8 | 2047 | | handleId: handleId, |
| | 8 | 2048 | | version: Version.ToVersionString(), |
| | 8 | 2049 | | recursive: recursive, |
| | 8 | 2050 | | async: async, |
| | 8 | 2051 | | operationName: operationName ?? $"{nameof(ShareDirectoryClient)}.{nameof(ForceCloseAllHandles)}" |
| | 8 | 2052 | | cancellationToken: cancellationToken) |
| | 8 | 2053 | | .ConfigureAwait(false); |
| | | 2054 | | } |
| | 4 | 2055 | | catch (Exception ex) |
| | | 2056 | | { |
| | | 2057 | | Pipeline.LogException(ex); |
| | 4 | 2058 | | throw; |
| | | 2059 | | } |
| | | 2060 | | finally |
| | | 2061 | | { |
| | | 2062 | | Pipeline.LogMethodExit(nameof(ShareDirectoryClient)); |
| | | 2063 | | } |
| | | 2064 | | } |
| | 4 | 2065 | | } |
| | | 2066 | | #endregion ForceCloseHandles |
| | | 2067 | | |
| | | 2068 | | #region CreateSubdirectory |
| | | 2069 | | /// <summary> |
| | | 2070 | | /// The <see cref="CreateSubdirectory"/> operation creates a new |
| | | 2071 | | /// subdirectory under this directory. |
| | | 2072 | | /// |
| | | 2073 | | /// For more information, see |
| | | 2074 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 2075 | | /// Create Directory</see>. |
| | | 2076 | | /// </summary> |
| | | 2077 | | /// <param name="subdirectoryName">The name of the subdirectory.</param> |
| | | 2078 | | /// <param name="metadata"> |
| | | 2079 | | /// Optional custom metadata to set for this directory. |
| | | 2080 | | /// </param> |
| | | 2081 | | /// <param name="smbProperties"> |
| | | 2082 | | /// Optional SMB properties to set for the subdirectory. |
| | | 2083 | | /// </param> |
| | | 2084 | | /// <param name="filePermission"> |
| | | 2085 | | /// Optional file permission to set for the subdirectory. |
| | | 2086 | | /// </param> |
| | | 2087 | | /// <param name="cancellationToken"> |
| | | 2088 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2089 | | /// notifications that the operation should be cancelled. |
| | | 2090 | | /// </param> |
| | | 2091 | | /// <returns> |
| | | 2092 | | /// A <see cref="Response{DirectoryClient}"/> referencing the |
| | | 2093 | | /// newly created directory. |
| | | 2094 | | /// </returns> |
| | | 2095 | | /// <remarks> |
| | | 2096 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2097 | | /// a failure occurs. |
| | | 2098 | | /// </remarks> |
| | | 2099 | | [ForwardsClientCalls] |
| | | 2100 | | public virtual Response<ShareDirectoryClient> CreateSubdirectory( |
| | | 2101 | | string subdirectoryName, |
| | | 2102 | | Metadata metadata = default, |
| | | 2103 | | FileSmbProperties smbProperties = default, |
| | | 2104 | | string filePermission = default, |
| | | 2105 | | CancellationToken cancellationToken = default) |
| | | 2106 | | { |
| | 2 | 2107 | | ShareDirectoryClient subdir = GetSubdirectoryClient(subdirectoryName); |
| | 2 | 2108 | | Response<ShareDirectoryInfo> response = subdir.Create( |
| | 2 | 2109 | | metadata, |
| | 2 | 2110 | | smbProperties, |
| | 2 | 2111 | | filePermission, |
| | 2 | 2112 | | cancellationToken); |
| | 2 | 2113 | | return Response.FromValue(subdir, response.GetRawResponse()); |
| | | 2114 | | } |
| | | 2115 | | |
| | | 2116 | | /// <summary> |
| | | 2117 | | /// The <see cref="CreateSubdirectoryAsync"/> operation creates a new |
| | | 2118 | | /// subdirectory under this directory. |
| | | 2119 | | /// |
| | | 2120 | | /// For more information, see |
| | | 2121 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-directory"> |
| | | 2122 | | /// Create Directory</see>. |
| | | 2123 | | /// </summary> |
| | | 2124 | | /// <param name="subdirectoryName">The name of the subdirectory.</param> |
| | | 2125 | | /// <param name="metadata"> |
| | | 2126 | | /// Optional custom metadata to set for the subdirectory. |
| | | 2127 | | /// </param> |
| | | 2128 | | /// <param name="smbProperties"> |
| | | 2129 | | /// Optional SMB properties to set for the subdirectory. |
| | | 2130 | | /// </param> |
| | | 2131 | | /// <param name="filePermission"> |
| | | 2132 | | /// Optional file permission to set for the subdirectory. |
| | | 2133 | | /// </param> |
| | | 2134 | | /// <param name="cancellationToken"> |
| | | 2135 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2136 | | /// notifications that the operation should be cancelled. |
| | | 2137 | | /// </param> |
| | | 2138 | | /// <returns> |
| | | 2139 | | /// A <see cref="Response{DirectoryClient}"/> referencing the |
| | | 2140 | | /// newly created directory. |
| | | 2141 | | /// </returns> |
| | | 2142 | | /// <remarks> |
| | | 2143 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2144 | | /// a failure occurs. |
| | | 2145 | | /// </remarks> |
| | | 2146 | | [ForwardsClientCalls] |
| | | 2147 | | public virtual async Task<Response<ShareDirectoryClient>> CreateSubdirectoryAsync( |
| | | 2148 | | string subdirectoryName, |
| | | 2149 | | Metadata metadata = default, |
| | | 2150 | | FileSmbProperties smbProperties = default, |
| | | 2151 | | string filePermission = default, |
| | | 2152 | | CancellationToken cancellationToken = default) |
| | | 2153 | | { |
| | 2 | 2154 | | ShareDirectoryClient subdir = GetSubdirectoryClient(subdirectoryName); |
| | 2 | 2155 | | Response<ShareDirectoryInfo> response = await subdir.CreateAsync( |
| | 2 | 2156 | | metadata, |
| | 2 | 2157 | | smbProperties, |
| | 2 | 2158 | | filePermission, |
| | 2 | 2159 | | cancellationToken) |
| | 2 | 2160 | | .ConfigureAwait(false); |
| | 2 | 2161 | | return Response.FromValue(subdir, response.GetRawResponse()); |
| | 2 | 2162 | | } |
| | | 2163 | | #endregion CreateSubdirectory |
| | | 2164 | | |
| | | 2165 | | #region DeleteSubdirectory |
| | | 2166 | | /// <summary> |
| | | 2167 | | /// The <see cref="DeleteSubdirectory"/> operation removes the |
| | | 2168 | | /// specified empty subdirectory. |
| | | 2169 | | /// |
| | | 2170 | | /// For more information, see |
| | | 2171 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 2172 | | /// Delete Directory</see>. |
| | | 2173 | | /// </summary> |
| | | 2174 | | /// <param name="subdirectoryName">The name of the subdirectory.</param> |
| | | 2175 | | /// <param name="cancellationToken"> |
| | | 2176 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2177 | | /// notifications that the operation should be cancelled. |
| | | 2178 | | /// </param> |
| | | 2179 | | /// <returns> |
| | | 2180 | | /// A <see cref="Response"/> if successful. |
| | | 2181 | | /// </returns> |
| | | 2182 | | /// <remarks> |
| | | 2183 | | /// Note that the directory must be empty before it can be deleted. |
| | | 2184 | | /// </remarks> |
| | | 2185 | | [ForwardsClientCalls] |
| | | 2186 | | public virtual Response DeleteSubdirectory( |
| | | 2187 | | string subdirectoryName, |
| | | 2188 | | CancellationToken cancellationToken = default) => |
| | 1 | 2189 | | GetSubdirectoryClient(subdirectoryName).Delete(cancellationToken); |
| | | 2190 | | |
| | | 2191 | | /// <summary> |
| | | 2192 | | /// The <see cref="DeleteSubdirectoryAsync"/> operation removes the |
| | | 2193 | | /// specified empty subdirectory. |
| | | 2194 | | /// |
| | | 2195 | | /// For more information, see |
| | | 2196 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-directory"> |
| | | 2197 | | /// Delete Directory</see>. |
| | | 2198 | | /// </summary> |
| | | 2199 | | /// <param name="subdirectoryName">The name of the subdirectory.</param> |
| | | 2200 | | /// <param name="cancellationToken"> |
| | | 2201 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2202 | | /// notifications that the operation should be cancelled. |
| | | 2203 | | /// </param> |
| | | 2204 | | /// <returns> |
| | | 2205 | | /// A <see cref="Response"/> if successful. |
| | | 2206 | | /// </returns> |
| | | 2207 | | /// <remarks> |
| | | 2208 | | /// Note that the directory must be empty before it can be deleted. |
| | | 2209 | | /// </remarks> |
| | | 2210 | | [ForwardsClientCalls] |
| | | 2211 | | public virtual async Task<Response> DeleteSubdirectoryAsync( |
| | | 2212 | | string subdirectoryName, |
| | | 2213 | | CancellationToken cancellationToken = default) => |
| | 1 | 2214 | | await GetSubdirectoryClient(subdirectoryName) |
| | 1 | 2215 | | .DeleteAsync(cancellationToken) |
| | 1 | 2216 | | .ConfigureAwait(false); |
| | | 2217 | | #endregion DeleteSubdirectory |
| | | 2218 | | |
| | | 2219 | | #region CreateFile |
| | | 2220 | | /// <summary> |
| | | 2221 | | /// Creates a new file or replaces an existing file. |
| | | 2222 | | /// |
| | | 2223 | | /// For more information, see |
| | | 2224 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-file"> |
| | | 2225 | | /// Create File</see>. |
| | | 2226 | | /// </summary> |
| | | 2227 | | /// <remarks> |
| | | 2228 | | /// This method only initializes the file. |
| | | 2229 | | /// To add content, use <see cref="ShareFileClient.UploadRange(HttpRange, System.IO.Stream, byte[], IProgress{lo |
| | | 2230 | | /// </remarks> |
| | | 2231 | | /// <param name="fileName">The name of the file.</param> |
| | | 2232 | | /// <param name="maxSize"> |
| | | 2233 | | /// Required. Specifies the maximum size for the file. |
| | | 2234 | | /// </param> |
| | | 2235 | | /// <param name="httpHeaders"> |
| | | 2236 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 2237 | | /// </param> |
| | | 2238 | | /// <param name="metadata"> |
| | | 2239 | | /// Optional custom metadata to set for the file. |
| | | 2240 | | /// </param> |
| | | 2241 | | /// <param name="smbProperties"> |
| | | 2242 | | /// Optional SMB properties to set for the file. |
| | | 2243 | | /// </param> |
| | | 2244 | | /// <param name="filePermission"> |
| | | 2245 | | /// Optional file permission to set for the file. |
| | | 2246 | | /// </param> |
| | | 2247 | | /// <param name="conditions"> |
| | | 2248 | | /// Optional <see cref="ShareFileRequestConditions"/> to add conditions |
| | | 2249 | | /// on creating the file. |
| | | 2250 | | /// </param> |
| | | 2251 | | /// <param name="cancellationToken"> |
| | | 2252 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2253 | | /// notifications that the operation should be cancelled. |
| | | 2254 | | /// </param> |
| | | 2255 | | /// <returns> |
| | | 2256 | | /// A <see cref="Response{FileClient}"/> referencing the file. |
| | | 2257 | | /// </returns> |
| | | 2258 | | /// <remarks> |
| | | 2259 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2260 | | /// a failure occurs. |
| | | 2261 | | /// </remarks> |
| | | 2262 | | [ForwardsClientCalls] |
| | | 2263 | | public virtual Response<ShareFileClient> CreateFile( |
| | | 2264 | | string fileName, |
| | | 2265 | | long maxSize, |
| | | 2266 | | ShareFileHttpHeaders httpHeaders = default, |
| | | 2267 | | Metadata metadata = default, |
| | | 2268 | | FileSmbProperties smbProperties = default, |
| | | 2269 | | string filePermission = default, |
| | | 2270 | | ShareFileRequestConditions conditions = default, |
| | | 2271 | | CancellationToken cancellationToken = default) |
| | | 2272 | | { |
| | 8 | 2273 | | ShareFileClient file = GetFileClient(fileName); |
| | 8 | 2274 | | Response<ShareFileInfo> response = file.Create( |
| | 8 | 2275 | | maxSize, |
| | 8 | 2276 | | httpHeaders, |
| | 8 | 2277 | | metadata, |
| | 8 | 2278 | | smbProperties, |
| | 8 | 2279 | | filePermission, |
| | 8 | 2280 | | conditions, |
| | 8 | 2281 | | cancellationToken); |
| | 8 | 2282 | | return Response.FromValue(file, response.GetRawResponse()); |
| | | 2283 | | } |
| | | 2284 | | |
| | | 2285 | | /// <summary> |
| | | 2286 | | /// Creates a new file or replaces an existing file. |
| | | 2287 | | /// |
| | | 2288 | | /// For more information, see |
| | | 2289 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-file"> |
| | | 2290 | | /// Create File</see>. |
| | | 2291 | | /// </summary> |
| | | 2292 | | /// <remarks> |
| | | 2293 | | /// This method only initializes the file. |
| | | 2294 | | /// To add content, use <see cref="ShareFileClient.UploadAsync(System.IO.Stream, IProgress{long}, CancellationTo |
| | | 2295 | | /// </remarks> |
| | | 2296 | | /// <param name="fileName">The name of the file.</param> |
| | | 2297 | | /// <param name="maxSize"> |
| | | 2298 | | /// Required. Specifies the maximum size for the file. |
| | | 2299 | | /// </param> |
| | | 2300 | | /// <param name="httpHeaders"> |
| | | 2301 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 2302 | | /// </param> |
| | | 2303 | | /// <param name="metadata"> |
| | | 2304 | | /// Optional custom metadata to set for the file. |
| | | 2305 | | /// </param> |
| | | 2306 | | /// <param name="smbProperties"> |
| | | 2307 | | /// Optional SMB properties to set for the file. |
| | | 2308 | | /// </param> |
| | | 2309 | | /// <param name="filePermission"> |
| | | 2310 | | /// Optional file permission to set for the file. |
| | | 2311 | | /// </param> |
| | | 2312 | | /// <param name="cancellationToken"> |
| | | 2313 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2314 | | /// notifications that the operation should be cancelled. |
| | | 2315 | | /// </param> |
| | | 2316 | | /// <returns> |
| | | 2317 | | /// A <see cref="Response{FileClient}"/> referencing the file. |
| | | 2318 | | /// </returns> |
| | | 2319 | | /// <remarks> |
| | | 2320 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2321 | | /// a failure occurs. |
| | | 2322 | | /// </remarks> |
| | | 2323 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2324 | | [ForwardsClientCalls] |
| | | 2325 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 2326 | | public virtual Response<ShareFileClient> CreateFile( |
| | | 2327 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2328 | | string fileName, |
| | | 2329 | | long maxSize, |
| | | 2330 | | ShareFileHttpHeaders httpHeaders, |
| | | 2331 | | Metadata metadata, |
| | | 2332 | | FileSmbProperties smbProperties, |
| | | 2333 | | string filePermission, |
| | | 2334 | | CancellationToken cancellationToken) |
| | | 2335 | | { |
| | 0 | 2336 | | ShareFileClient file = GetFileClient(fileName); |
| | 0 | 2337 | | Response<ShareFileInfo> response = file.Create( |
| | 0 | 2338 | | maxSize, |
| | 0 | 2339 | | httpHeaders, |
| | 0 | 2340 | | metadata, |
| | 0 | 2341 | | smbProperties, |
| | 0 | 2342 | | filePermission, |
| | 0 | 2343 | | conditions: default, |
| | 0 | 2344 | | cancellationToken); |
| | 0 | 2345 | | return Response.FromValue(file, response.GetRawResponse()); |
| | | 2346 | | } |
| | | 2347 | | |
| | | 2348 | | /// <summary> |
| | | 2349 | | /// Creates a new file or replaces an existing file. |
| | | 2350 | | /// |
| | | 2351 | | /// For more information, see |
| | | 2352 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-file"> |
| | | 2353 | | /// Create File</see>. |
| | | 2354 | | /// </summary> |
| | | 2355 | | /// <remarks> |
| | | 2356 | | /// This method only initializes the file. |
| | | 2357 | | /// To add content, use <see cref="ShareFileClient.UploadRangeAsync(HttpRange, System.IO.Stream, byte[], IProgre |
| | | 2358 | | /// </remarks> |
| | | 2359 | | /// <param name="fileName">The name of the file.</param> |
| | | 2360 | | /// <param name="maxSize"> |
| | | 2361 | | /// Required. Specifies the maximum size for the file. |
| | | 2362 | | /// </param> |
| | | 2363 | | /// <param name="httpHeaders"> |
| | | 2364 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 2365 | | /// </param> |
| | | 2366 | | /// <param name="metadata"> |
| | | 2367 | | /// Optional custom metadata to set for the file. |
| | | 2368 | | /// </param> |
| | | 2369 | | /// <param name="smbProperties"> |
| | | 2370 | | /// Optional SMB properties to set for the file. |
| | | 2371 | | /// </param> |
| | | 2372 | | /// <param name="filePermission"> |
| | | 2373 | | /// Optional file permission to set for the file. |
| | | 2374 | | /// </param> |
| | | 2375 | | /// <param name="conditions"> |
| | | 2376 | | /// Optional <see cref="ShareFileRequestConditions"/> to add conditions |
| | | 2377 | | /// on creating the file. |
| | | 2378 | | /// </param> |
| | | 2379 | | /// <param name="cancellationToken"> |
| | | 2380 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2381 | | /// notifications that the operation should be cancelled. |
| | | 2382 | | /// </param> |
| | | 2383 | | /// <returns> |
| | | 2384 | | /// A <see cref="Response{FileClient}"/> referencing the file. |
| | | 2385 | | /// </returns> |
| | | 2386 | | /// <remarks> |
| | | 2387 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2388 | | /// a failure occurs. |
| | | 2389 | | /// </remarks> |
| | | 2390 | | [ForwardsClientCalls] |
| | | 2391 | | public virtual async Task<Response<ShareFileClient>> CreateFileAsync( |
| | | 2392 | | string fileName, |
| | | 2393 | | long maxSize, |
| | | 2394 | | ShareFileHttpHeaders httpHeaders = default, |
| | | 2395 | | Metadata metadata = default, |
| | | 2396 | | FileSmbProperties smbProperties = default, |
| | | 2397 | | string filePermission = default, |
| | | 2398 | | ShareFileRequestConditions conditions = default, |
| | | 2399 | | CancellationToken cancellationToken = default) |
| | | 2400 | | { |
| | 8 | 2401 | | ShareFileClient file = GetFileClient(fileName); |
| | 8 | 2402 | | Response<ShareFileInfo> response = await file.CreateAsync( |
| | 8 | 2403 | | maxSize, |
| | 8 | 2404 | | httpHeaders, |
| | 8 | 2405 | | metadata, |
| | 8 | 2406 | | smbProperties, |
| | 8 | 2407 | | filePermission, |
| | 8 | 2408 | | conditions, |
| | 8 | 2409 | | cancellationToken).ConfigureAwait(false); |
| | 8 | 2410 | | return Response.FromValue(file, response.GetRawResponse()); |
| | 8 | 2411 | | } |
| | | 2412 | | |
| | | 2413 | | /// <summary> |
| | | 2414 | | /// Creates a new file or replaces an existing file. |
| | | 2415 | | /// |
| | | 2416 | | /// For more information, see |
| | | 2417 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-file"> |
| | | 2418 | | /// Create File</see>. |
| | | 2419 | | /// </summary> |
| | | 2420 | | /// <remarks> |
| | | 2421 | | /// This method only initializes the file. |
| | | 2422 | | /// To add content, use <see cref="ShareFileClient.UploadRangeAsync(HttpRange, System.IO.Stream, byte[], IProgre |
| | | 2423 | | /// </remarks> |
| | | 2424 | | /// <param name="fileName">The name of the file.</param> |
| | | 2425 | | /// <param name="maxSize"> |
| | | 2426 | | /// Required. Specifies the maximum size for the file. |
| | | 2427 | | /// </param> |
| | | 2428 | | /// <param name="httpHeaders"> |
| | | 2429 | | /// Optional standard HTTP header properties that can be set for the file. |
| | | 2430 | | /// </param> |
| | | 2431 | | /// <param name="metadata"> |
| | | 2432 | | /// Optional custom metadata to set for the file. |
| | | 2433 | | /// </param> |
| | | 2434 | | /// <param name="smbProperties"> |
| | | 2435 | | /// Optional SMB properties to set for the file. |
| | | 2436 | | /// </param> |
| | | 2437 | | /// <param name="filePermission"> |
| | | 2438 | | /// Optional file permission to set for the file. |
| | | 2439 | | /// </param> |
| | | 2440 | | /// <param name="cancellationToken"> |
| | | 2441 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2442 | | /// notifications that the operation should be cancelled. |
| | | 2443 | | /// </param> |
| | | 2444 | | /// <returns> |
| | | 2445 | | /// A <see cref="Response{FileClient}"/> referencing the file. |
| | | 2446 | | /// </returns> |
| | | 2447 | | /// <remarks> |
| | | 2448 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2449 | | /// a failure occurs. |
| | | 2450 | | /// </remarks> |
| | | 2451 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2452 | | [ForwardsClientCalls] |
| | | 2453 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 2454 | | public virtual async Task<Response<ShareFileClient>> CreateFileAsync( |
| | | 2455 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2456 | | string fileName, |
| | | 2457 | | long maxSize, |
| | | 2458 | | ShareFileHttpHeaders httpHeaders, |
| | | 2459 | | Metadata metadata, |
| | | 2460 | | FileSmbProperties smbProperties, |
| | | 2461 | | string filePermission, |
| | | 2462 | | CancellationToken cancellationToken) |
| | | 2463 | | { |
| | 0 | 2464 | | ShareFileClient file = GetFileClient(fileName); |
| | 0 | 2465 | | Response<ShareFileInfo> response = await file.CreateAsync( |
| | 0 | 2466 | | maxSize, |
| | 0 | 2467 | | httpHeaders, |
| | 0 | 2468 | | metadata, |
| | 0 | 2469 | | smbProperties, |
| | 0 | 2470 | | filePermission, |
| | 0 | 2471 | | conditions: default, |
| | 0 | 2472 | | cancellationToken).ConfigureAwait(false); |
| | 0 | 2473 | | return Response.FromValue(file, response.GetRawResponse()); |
| | 0 | 2474 | | } |
| | | 2475 | | #endregion CreateFile |
| | | 2476 | | |
| | | 2477 | | #region DeleteFile |
| | | 2478 | | /// <summary> |
| | | 2479 | | /// The <see cref="DeleteFile(string, ShareFileRequestConditions, CancellationToken)"/> |
| | | 2480 | | /// operation immediately removes the file from the storage account. |
| | | 2481 | | /// |
| | | 2482 | | /// For more information, see |
| | | 2483 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-file2"> |
| | | 2484 | | /// Delete File</see>. |
| | | 2485 | | /// </summary> |
| | | 2486 | | /// <param name="fileName">The name of the file.</param> |
| | | 2487 | | /// <param name="conditions"> |
| | | 2488 | | /// Optional <see cref="ShareFileRequestConditions"/> to add conditions |
| | | 2489 | | /// on creating the file. |
| | | 2490 | | /// </param> |
| | | 2491 | | /// <param name="cancellationToken"> |
| | | 2492 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2493 | | /// notifications that the operation should be cancelled. |
| | | 2494 | | /// </param> |
| | | 2495 | | /// <returns> |
| | | 2496 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 2497 | | /// </returns> |
| | | 2498 | | /// <remarks> |
| | | 2499 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2500 | | /// a failure occurs. |
| | | 2501 | | /// </remarks> |
| | | 2502 | | [ForwardsClientCalls] |
| | | 2503 | | public virtual Response DeleteFile( |
| | | 2504 | | string fileName, |
| | | 2505 | | ShareFileRequestConditions conditions = default, |
| | | 2506 | | CancellationToken cancellationToken = default) => |
| | 1 | 2507 | | GetFileClient(fileName).Delete( |
| | 1 | 2508 | | conditions, |
| | 1 | 2509 | | cancellationToken); |
| | | 2510 | | |
| | | 2511 | | /// <summary> |
| | | 2512 | | /// The <see cref="DeleteFile(string, CancellationToken)"/> |
| | | 2513 | | /// operation immediately removes the file from the storage account. |
| | | 2514 | | /// |
| | | 2515 | | /// For more information, see |
| | | 2516 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-file2"> |
| | | 2517 | | /// Delete File</see>. |
| | | 2518 | | /// </summary> |
| | | 2519 | | /// <param name="fileName">The name of the file.</param> |
| | | 2520 | | /// <param name="cancellationToken"> |
| | | 2521 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2522 | | /// notifications that the operation should be cancelled. |
| | | 2523 | | /// </param> |
| | | 2524 | | /// <returns> |
| | | 2525 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 2526 | | /// </returns> |
| | | 2527 | | /// <remarks> |
| | | 2528 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2529 | | /// a failure occurs. |
| | | 2530 | | /// </remarks> |
| | | 2531 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2532 | | [ForwardsClientCalls] |
| | | 2533 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 2534 | | public virtual Response DeleteFile( |
| | | 2535 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2536 | | string fileName, |
| | | 2537 | | CancellationToken cancellationToken) => |
| | 0 | 2538 | | GetFileClient(fileName).Delete( |
| | 0 | 2539 | | conditions: default, |
| | 0 | 2540 | | cancellationToken); |
| | | 2541 | | |
| | | 2542 | | /// <summary> |
| | | 2543 | | /// The <see cref="DeleteFile(string, ShareFileRequestConditions, CancellationToken)"/> |
| | | 2544 | | /// operation immediately removes the file from the storage account. |
| | | 2545 | | /// |
| | | 2546 | | /// For more information, see |
| | | 2547 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-file2"> |
| | | 2548 | | /// Delete File</see>. |
| | | 2549 | | /// </summary> |
| | | 2550 | | /// <param name="fileName">The name of the file.</param> |
| | | 2551 | | /// <param name="conditions"> |
| | | 2552 | | /// Optional <see cref="ShareFileRequestConditions"/> to add conditions |
| | | 2553 | | /// on creating the file. |
| | | 2554 | | /// </param> |
| | | 2555 | | /// <param name="cancellationToken"> |
| | | 2556 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2557 | | /// notifications that the operation should be cancelled. |
| | | 2558 | | /// </param> |
| | | 2559 | | /// <returns> |
| | | 2560 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 2561 | | /// </returns> |
| | | 2562 | | /// <remarks> |
| | | 2563 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 2564 | | /// a failure occurs. |
| | | 2565 | | /// </remarks> |
| | | 2566 | | [ForwardsClientCalls] |
| | | 2567 | | public virtual async Task<Response> DeleteFileAsync( |
| | | 2568 | | string fileName, |
| | | 2569 | | ShareFileRequestConditions conditions = default, |
| | | 2570 | | CancellationToken cancellationToken = default) => |
| | 1 | 2571 | | await GetFileClient(fileName) |
| | 1 | 2572 | | .DeleteAsync( |
| | 1 | 2573 | | conditions, |
| | 1 | 2574 | | cancellationToken) |
| | 1 | 2575 | | .ConfigureAwait(false); |
| | | 2576 | | |
| | | 2577 | | /// <summary> |
| | | 2578 | | /// The <see cref="DeleteFileAsync(string, CancellationToken)"/> |
| | | 2579 | | /// operation immediately removesthe file from the storage account. |
| | | 2580 | | /// |
| | | 2581 | | /// For more information, see |
| | | 2582 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-file2"> |
| | | 2583 | | /// Delete File</see>. |
| | | 2584 | | /// </summary> |
| | | 2585 | | /// <param name="fileName">The name of the file.</param> |
| | | 2586 | | /// <param name="cancellationToken"> |
| | | 2587 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 2588 | | /// notifications that the operation should be cancelled. |
| | | 2589 | | /// </param> |
| | | 2590 | | /// <returns> |
| | | 2591 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 2592 | | /// </returns> |
| | | 2593 | | /// <remarks> |
| | | 2594 | | /// A <see cref="RequestFailedException"/> will bse thrown if |
| | | 2595 | | /// a failure occurs. |
| | | 2596 | | /// </remarks> |
| | | 2597 | | #pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2598 | | [ForwardsClientCalls] |
| | | 2599 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 2600 | | public virtual async Task<Response> DeleteFileAsync( |
| | | 2601 | | #pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional Ca |
| | | 2602 | | string fileName, |
| | | 2603 | | CancellationToken cancellationToken) => |
| | 0 | 2604 | | await GetFileClient(fileName) |
| | 0 | 2605 | | .DeleteAsync( |
| | 0 | 2606 | | conditions: default, |
| | 0 | 2607 | | cancellationToken) |
| | 0 | 2608 | | .ConfigureAwait(false); |
| | | 2609 | | #endregion DeleteFile |
| | | 2610 | | } |
| | | 2611 | | } |