| | | 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.Linq; |
| | | 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 | | |
| | | 13 | | namespace Azure.Storage.Files.Shares |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// The <see cref="ShareServiceClient"/> allows you to manipulate Azure |
| | | 17 | | /// Storage service resources and shares. The storage account provides |
| | | 18 | | /// the top-level namespace for the File service. |
| | | 19 | | /// </summary> |
| | | 20 | | public class ShareServiceClient |
| | | 21 | | { |
| | | 22 | | /// <summary> |
| | | 23 | | /// The file service's primary <see cref="Uri"/> endpoint. |
| | | 24 | | /// </summary> |
| | | 25 | | private readonly Uri _uri; |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets the file service's primary <see cref="Uri"/> endpoint. |
| | | 29 | | /// </summary> |
| | 591 | 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 tghe <see cref="HttpPipeline"/> transport pipeline used to |
| | | 40 | | /// send every request. |
| | | 41 | | /// </summary> |
| | 613 | 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> |
| | 585 | 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> |
| | 585 | 64 | | internal virtual ClientDiagnostics ClientDiagnostics => _clientDiagnostics; |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// The Storage account name corresponding to the file service client. |
| | | 68 | | /// </summary> |
| | | 69 | | private string _accountName; |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Gets the Storage account name corresponding to the file service client. |
| | | 73 | | /// </summary> |
| | | 74 | | public virtual string AccountName |
| | | 75 | | { |
| | | 76 | | get |
| | | 77 | | { |
| | 4 | 78 | | if (_accountName == null) |
| | | 79 | | { |
| | 2 | 80 | | _accountName = new ShareUriBuilder(Uri).AccountName; |
| | | 81 | | } |
| | 4 | 82 | | return _accountName; |
| | | 83 | | } |
| | | 84 | | } |
| | | 85 | | |
| | | 86 | | #region ctors |
| | | 87 | | /// <summary> |
| | | 88 | | /// Initializes a new instance of the <see cref="ShareServiceClient"/> |
| | | 89 | | /// class for mocking. |
| | | 90 | | /// </summary> |
| | 513 | 91 | | protected ShareServiceClient() |
| | | 92 | | { |
| | 513 | 93 | | } |
| | | 94 | | |
| | | 95 | | /// <summary> |
| | | 96 | | /// Initializes a new instance of the <see cref="ShareServiceClient"/> |
| | | 97 | | /// class. |
| | | 98 | | /// </summary> |
| | | 99 | | /// <param name="connectionString"> |
| | | 100 | | /// A connection string includes the authentication information |
| | | 101 | | /// required for your application to access data in an Azure Storage |
| | | 102 | | /// account at runtime. |
| | | 103 | | /// |
| | | 104 | | /// For more information, |
| | | 105 | | /// <see href="https://docs.microsoft.com/azure/storage/common/storage-configure-connection-string"> |
| | | 106 | | /// Configure Azure Storage connection strings</see>. |
| | | 107 | | /// </param> |
| | | 108 | | public ShareServiceClient(string connectionString) |
| | 0 | 109 | | : this(connectionString, null) |
| | | 110 | | { |
| | 0 | 111 | | } |
| | | 112 | | |
| | | 113 | | /// <summary> |
| | | 114 | | /// Initializes a new instance of the <see cref="ShareServiceClient"/> |
| | | 115 | | /// class. |
| | | 116 | | /// </summary> |
| | | 117 | | /// <param name="connectionString"> |
| | | 118 | | /// A connection string includes the authentication information |
| | | 119 | | /// required for your application to access data in an Azure Storage |
| | | 120 | | /// account at runtime. |
| | | 121 | | /// |
| | | 122 | | /// For more information, |
| | | 123 | | /// <see href="https://docs.microsoft.com/azure/storage/common/storage-configure-connection-string"> |
| | | 124 | | /// Configure Azure Storage connection strings</see>. |
| | | 125 | | /// </param> |
| | | 126 | | /// <param name="options"> |
| | | 127 | | /// Optional client options that define the transport pipeline |
| | | 128 | | /// policies for authentication, retries, etc., that are applied to |
| | | 129 | | /// every request. |
| | | 130 | | /// </param> |
| | 2 | 131 | | public ShareServiceClient(string connectionString, ShareClientOptions options) |
| | | 132 | | { |
| | 2 | 133 | | options ??= new ShareClientOptions(); |
| | 2 | 134 | | var conn = StorageConnectionString.Parse(connectionString); |
| | 2 | 135 | | _uri = conn.FileEndpoint; |
| | 2 | 136 | | _pipeline = options.Build(conn.Credentials); |
| | 2 | 137 | | _version = options.Version; |
| | 2 | 138 | | _clientDiagnostics = new ClientDiagnostics(options); |
| | 2 | 139 | | } |
| | | 140 | | |
| | | 141 | | /// <summary> |
| | | 142 | | /// Initializes a new instance of the <see cref="ShareServiceClient"/> |
| | | 143 | | /// class. |
| | | 144 | | /// </summary> |
| | | 145 | | /// <param name="serviceUri"> |
| | | 146 | | /// A <see cref="Uri"/> referencing the file service. |
| | | 147 | | /// </param> |
| | | 148 | | /// <param name="options"> |
| | | 149 | | /// Optional client options that define the transport pipeline |
| | | 150 | | /// policies for authentication, retries, etc., that are applied to |
| | | 151 | | /// every request. |
| | | 152 | | /// </param> |
| | | 153 | | public ShareServiceClient(Uri serviceUri, ShareClientOptions options = default) |
| | 26 | 154 | | : this(serviceUri, (HttpPipelinePolicy)null, options) |
| | | 155 | | { |
| | 26 | 156 | | } |
| | | 157 | | |
| | | 158 | | /// <summary> |
| | | 159 | | /// Initializes a new instance of the <see cref="ShareServiceClient"/> |
| | | 160 | | /// class. |
| | | 161 | | /// </summary> |
| | | 162 | | /// <param name="serviceUri"> |
| | | 163 | | /// A <see cref="Uri"/> referencing the file service. |
| | | 164 | | /// </param> |
| | | 165 | | /// <param name="credential"> |
| | | 166 | | /// The shared key credential used to sign requests. |
| | | 167 | | /// </param> |
| | | 168 | | /// <param name="options"> |
| | | 169 | | /// Optional client options that define the transport pipeline |
| | | 170 | | /// policies for authentication, retries, etc., that are applied to |
| | | 171 | | /// every request. |
| | | 172 | | /// </param> |
| | | 173 | | public ShareServiceClient(Uri serviceUri, StorageSharedKeyCredential credential, ShareClientOptions options = de |
| | 485 | 174 | | : this(serviceUri, credential.AsPolicy(), options) |
| | | 175 | | { |
| | 485 | 176 | | } |
| | | 177 | | |
| | | 178 | | /// <summary> |
| | | 179 | | /// Initializes a new instance of the <see cref="ShareServiceClient"/> |
| | | 180 | | /// class. |
| | | 181 | | /// </summary> |
| | | 182 | | /// <param name="serviceUri"> |
| | | 183 | | /// A <see cref="Uri"/> referencing the file service. |
| | | 184 | | /// </param> |
| | | 185 | | /// <param name="authentication"> |
| | | 186 | | /// An optional authentication policy used to sign requests. |
| | | 187 | | /// </param> |
| | | 188 | | /// <param name="options"> |
| | | 189 | | /// Optional client options that define the transport pipeline |
| | | 190 | | /// policies for authentication, retries, etc., that are applied to |
| | | 191 | | /// every request. |
| | | 192 | | /// </param> |
| | 511 | 193 | | internal ShareServiceClient(Uri serviceUri, HttpPipelinePolicy authentication, ShareClientOptions options) |
| | | 194 | | { |
| | 511 | 195 | | options ??= new ShareClientOptions(); |
| | 511 | 196 | | _uri = serviceUri; |
| | 511 | 197 | | _pipeline = options.Build(authentication); |
| | 511 | 198 | | _version = options.Version; |
| | 511 | 199 | | _clientDiagnostics = new ClientDiagnostics(options); |
| | 511 | 200 | | } |
| | | 201 | | #endregion ctors |
| | | 202 | | |
| | | 203 | | /// <summary> |
| | | 204 | | /// Create a new <see cref="ShareClient"/> object by appending |
| | | 205 | | /// <paramref name="shareName"/> to the end of <see cref="Uri"/>. |
| | | 206 | | /// The new <see cref="ShareClient"/> uses the same request |
| | | 207 | | /// policy pipeline as the <see cref="ShareServiceClient"/>. |
| | | 208 | | /// </summary> |
| | | 209 | | /// <param name="shareName"> |
| | | 210 | | /// The name of the share to reference. |
| | | 211 | | /// </param> |
| | | 212 | | /// <returns> |
| | | 213 | | /// A <see cref="ShareClient"/> for the desired share. |
| | | 214 | | /// </returns> |
| | | 215 | | public virtual ShareClient GetShareClient(string shareName) => |
| | 557 | 216 | | new ShareClient(Uri.AppendToPath(shareName), Pipeline, Version, ClientDiagnostics); |
| | | 217 | | |
| | | 218 | | #region GetShares |
| | | 219 | | /// <summary> |
| | | 220 | | /// The <see cref="GetShares"/> operation returns an async sequence |
| | | 221 | | /// of the shares in the storage account. Enumerating the shares may |
| | | 222 | | /// make multiple requests to the service while fetching all the |
| | | 223 | | /// values. |
| | | 224 | | /// |
| | | 225 | | /// For more information, see |
| | | 226 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-shares"> |
| | | 227 | | /// List Shares</see>. |
| | | 228 | | /// </summary> |
| | | 229 | | /// <param name="traits"> |
| | | 230 | | /// Specifies traits to include in the <see cref="ShareItem"/>s. |
| | | 231 | | /// </param> |
| | | 232 | | /// <param name="states"> |
| | | 233 | | /// Specifies states to include when listing shares. |
| | | 234 | | /// </param> |
| | | 235 | | /// <param name="prefix"> |
| | | 236 | | /// String that filters the results to return only shares whose name |
| | | 237 | | /// begins with the specified prefix. |
| | | 238 | | /// </param> |
| | | 239 | | /// <param name="cancellationToken"> |
| | | 240 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 241 | | /// notifications that the operation should be cancelled. |
| | | 242 | | /// </param> |
| | | 243 | | /// <returns> |
| | | 244 | | /// An <see cref="IEnumerable{T}"/> of <see cref="Response{ShareItem}"/> |
| | | 245 | | /// describing the shares in the storage account. |
| | | 246 | | /// </returns> |
| | | 247 | | /// <remarks> |
| | | 248 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 249 | | /// a failure occurs. |
| | | 250 | | /// </remarks> |
| | | 251 | | public virtual Pageable<ShareItem> GetShares( |
| | | 252 | | ShareTraits traits = ShareTraits.None, |
| | | 253 | | ShareStates states = ShareStates.None, |
| | | 254 | | string prefix = default, |
| | | 255 | | CancellationToken cancellationToken = default) => |
| | 5 | 256 | | new GetSharesAsyncCollection(this, traits, states, prefix).ToSyncCollection(cancellationToken); |
| | | 257 | | |
| | | 258 | | /// <summary> |
| | | 259 | | /// The <see cref="GetSharesAsync"/> operation returns an async collection |
| | | 260 | | /// of the shares in the storage account. Enumerating the shares may |
| | | 261 | | /// make multiple requests to the service while fetching all the |
| | | 262 | | /// values. |
| | | 263 | | /// |
| | | 264 | | /// For more information, see |
| | | 265 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-shares"> |
| | | 266 | | /// List Shares</see>. |
| | | 267 | | /// </summary> |
| | | 268 | | /// <param name="traits"> |
| | | 269 | | /// Specifies traits to include in the <see cref="ShareItem"/>s. |
| | | 270 | | /// </param> |
| | | 271 | | /// <param name="states"> |
| | | 272 | | /// Specifies states to include when listing shares. |
| | | 273 | | /// </param> |
| | | 274 | | /// <param name="prefix"> |
| | | 275 | | /// String that filters the results to return only shares whose name |
| | | 276 | | /// begins with the specified prefix. |
| | | 277 | | /// </param> |
| | | 278 | | /// <param name="cancellationToken"> |
| | | 279 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 280 | | /// notifications that the operation should be cancelled. |
| | | 281 | | /// </param> |
| | | 282 | | /// <returns> |
| | | 283 | | /// A <see cref="AsyncPageable{T}"/> describing the shares in |
| | | 284 | | /// the storage account. |
| | | 285 | | /// </returns> |
| | | 286 | | /// <remarks> |
| | | 287 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 288 | | /// a failure occurs. |
| | | 289 | | /// </remarks> |
| | | 290 | | public virtual AsyncPageable<ShareItem> GetSharesAsync( |
| | | 291 | | ShareTraits traits = ShareTraits.None, |
| | | 292 | | ShareStates states = ShareStates.None, |
| | | 293 | | string prefix = default, |
| | | 294 | | CancellationToken cancellationToken = default) => |
| | 5 | 295 | | new GetSharesAsyncCollection(this, traits, states, prefix).ToAsyncCollection(cancellationToken); |
| | | 296 | | |
| | | 297 | | /// <summary> |
| | | 298 | | /// The <see cref="GetSharesInternal"/> operation returns a |
| | | 299 | | /// single segment of shares in the storage account, starting |
| | | 300 | | /// from the specified <paramref name="marker"/>. Use an empty |
| | | 301 | | /// <paramref name="marker"/> to start enumeration from the beginning |
| | | 302 | | /// and the <see cref="SharesSegment.NextMarker"/> if it's not |
| | | 303 | | /// empty to make subsequent calls to <see cref="GetSharesAsync"/> |
| | | 304 | | /// to continue enumerating the shares segment by segment. |
| | | 305 | | /// |
| | | 306 | | /// For more information, see |
| | | 307 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/list-shares"> |
| | | 308 | | /// List Shares</see>. |
| | | 309 | | /// </summary> |
| | | 310 | | /// <param name="marker"> |
| | | 311 | | /// An optional string value that identifies the segment of the list |
| | | 312 | | /// of shares to be returned with the next listing operation. The |
| | | 313 | | /// operation returns a non-empty <see cref="SharesSegment.NextMarker"/> |
| | | 314 | | /// if the listing operation did not return all shares remaining |
| | | 315 | | /// to be listed with the current segment. The NextMarker value can |
| | | 316 | | /// be used as the value for the <paramref name="marker"/> parameter |
| | | 317 | | /// in a subsequent call to request the next segment of list items. |
| | | 318 | | /// </param> |
| | | 319 | | /// <param name="traits"> |
| | | 320 | | /// Specifies traits to include in the <see cref="ShareItem"/>s. |
| | | 321 | | /// </param> |
| | | 322 | | /// <param name="states"> |
| | | 323 | | /// Specifies states to include when listing shares. |
| | | 324 | | /// </param> |
| | | 325 | | /// <param name="prefix"> |
| | | 326 | | /// String that filters the results to return only shares whose name |
| | | 327 | | /// begins with the specified prefix. |
| | | 328 | | /// </param> |
| | | 329 | | /// <param name="pageSizeHint"> |
| | | 330 | | /// Gets or sets a value indicating the size of the page that should be |
| | | 331 | | /// requested. |
| | | 332 | | /// </param> |
| | | 333 | | /// <param name="async"> |
| | | 334 | | /// Whether to invoke the operation asynchronously. |
| | | 335 | | /// </param> |
| | | 336 | | /// <param name="cancellationToken"> |
| | | 337 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 338 | | /// notifications that the operation should be cancelled. |
| | | 339 | | /// </param> |
| | | 340 | | /// <returns> |
| | | 341 | | /// A <see cref="Response{SharesSegment}"/> describing a |
| | | 342 | | /// segment of the shares in the storage account. |
| | | 343 | | /// </returns> |
| | | 344 | | /// <remarks> |
| | | 345 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 346 | | /// a failure occurs. |
| | | 347 | | /// </remarks> |
| | | 348 | | internal async Task<Response<SharesSegment>> GetSharesInternal( |
| | | 349 | | string marker, |
| | | 350 | | ShareTraits traits, |
| | | 351 | | ShareStates states, |
| | | 352 | | string prefix, |
| | | 353 | | int? pageSizeHint, |
| | | 354 | | bool async, |
| | | 355 | | CancellationToken cancellationToken) |
| | | 356 | | { |
| | 10 | 357 | | using (Pipeline.BeginLoggingScope(nameof(ShareServiceClient))) |
| | | 358 | | { |
| | | 359 | | Pipeline.LogMethodEnter( |
| | | 360 | | nameof(ShareServiceClient), |
| | | 361 | | message: |
| | | 362 | | $"{nameof(Uri)}: {Uri}\n" + |
| | | 363 | | $"{nameof(marker)}: {marker}"); |
| | | 364 | | try |
| | | 365 | | { |
| | 10 | 366 | | Response<SharesSegment> response = await FileRestClient.Service.ListSharesSegmentAsync( |
| | 10 | 367 | | ClientDiagnostics, |
| | 10 | 368 | | Pipeline, |
| | 10 | 369 | | Uri, |
| | 10 | 370 | | version: Version.ToVersionString(), |
| | 10 | 371 | | marker: marker, |
| | 10 | 372 | | prefix: prefix, |
| | 10 | 373 | | maxresults: pageSizeHint, |
| | 10 | 374 | | include: ShareExtensions.AsIncludeItems(traits, states), |
| | 10 | 375 | | async: async, |
| | 10 | 376 | | cancellationToken: cancellationToken) |
| | 10 | 377 | | .ConfigureAwait(false); |
| | 8 | 378 | | if ((traits & ShareTraits.Metadata) != ShareTraits.Metadata) |
| | | 379 | | { |
| | 6 | 380 | | IEnumerable<ShareItem> shareItems = response.Value.ShareItems; |
| | 392 | 381 | | foreach (ShareItem shareItem in shareItems) |
| | | 382 | | { |
| | 190 | 383 | | shareItem.Properties.Metadata = null; |
| | | 384 | | } |
| | | 385 | | } |
| | 8 | 386 | | return response; |
| | | 387 | | } |
| | 2 | 388 | | catch (Exception ex) |
| | | 389 | | { |
| | | 390 | | Pipeline.LogException(ex); |
| | 2 | 391 | | throw; |
| | | 392 | | } |
| | | 393 | | finally |
| | | 394 | | { |
| | | 395 | | Pipeline.LogMethodExit(nameof(ShareServiceClient)); |
| | | 396 | | } |
| | | 397 | | } |
| | 8 | 398 | | } |
| | | 399 | | #endregion GetShares |
| | | 400 | | |
| | | 401 | | #region GetProperties |
| | | 402 | | /// <summary> |
| | | 403 | | /// The <see cref="GetProperties"/> operation gets the properties |
| | | 404 | | /// of a storage account’s file service, including properties for |
| | | 405 | | /// Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. |
| | | 406 | | /// |
| | | 407 | | /// For more information, see |
| | | 408 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-service-properties"> |
| | | 409 | | /// Get File Service Properties</see>. |
| | | 410 | | /// </summary> |
| | | 411 | | /// <param name="cancellationToken"> |
| | | 412 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 413 | | /// notifications that the operation should be cancelled. |
| | | 414 | | /// </param> |
| | | 415 | | /// <returns> |
| | | 416 | | /// A <see cref="Response{FileServiceProperties}"/> describing |
| | | 417 | | /// the service properties. |
| | | 418 | | /// </returns> |
| | | 419 | | /// <remarks> |
| | | 420 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 421 | | /// a failure occurs. |
| | | 422 | | /// </remarks> |
| | | 423 | | public virtual Response<ShareServiceProperties> GetProperties( |
| | | 424 | | CancellationToken cancellationToken = default) => |
| | 5 | 425 | | GetPropertiesInternal( |
| | 5 | 426 | | false, // async |
| | 5 | 427 | | cancellationToken) |
| | 5 | 428 | | .EnsureCompleted(); |
| | | 429 | | |
| | | 430 | | /// <summary> |
| | | 431 | | /// The <see cref="GetPropertiesAsync"/> operation gets the properties |
| | | 432 | | /// of a storage account’s file service, including properties for |
| | | 433 | | /// Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. |
| | | 434 | | /// |
| | | 435 | | /// For more information, see |
| | | 436 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-service-properties"> |
| | | 437 | | /// Get File Service Properties</see>. |
| | | 438 | | /// </summary> |
| | | 439 | | /// <param name="cancellationToken"> |
| | | 440 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 441 | | /// notifications that the operation should be cancelled. |
| | | 442 | | /// </param> |
| | | 443 | | /// <returns> |
| | | 444 | | /// A <see cref="Response{FileServiceProperties}"/> describing |
| | | 445 | | /// the service properties. |
| | | 446 | | /// </returns> |
| | | 447 | | /// <remarks> |
| | | 448 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 449 | | /// a failure occurs. |
| | | 450 | | /// </remarks> |
| | | 451 | | public virtual async Task<Response<ShareServiceProperties>> GetPropertiesAsync( |
| | | 452 | | CancellationToken cancellationToken = default) => |
| | 5 | 453 | | await GetPropertiesInternal( |
| | 5 | 454 | | true, // async |
| | 5 | 455 | | cancellationToken) |
| | 5 | 456 | | .ConfigureAwait(false); |
| | | 457 | | |
| | | 458 | | /// <summary> |
| | | 459 | | /// The <see cref="GetPropertiesInternal"/> operation gets the properties |
| | | 460 | | /// of a storage account’s file service, including properties for |
| | | 461 | | /// Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. |
| | | 462 | | /// |
| | | 463 | | /// For more information, see |
| | | 464 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/get-file-service-properties"> |
| | | 465 | | /// Get File Service Properties</see>. |
| | | 466 | | /// </summary> |
| | | 467 | | /// <param name="async"> |
| | | 468 | | /// Whether to invoke the operation asynchronously. |
| | | 469 | | /// </param> |
| | | 470 | | /// <param name="cancellationToken"> |
| | | 471 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 472 | | /// notifications that the operation should be cancelled. |
| | | 473 | | /// </param> |
| | | 474 | | /// <returns> |
| | | 475 | | /// A <see cref="Response{FileServiceProperties}"/> describing |
| | | 476 | | /// the service properties. |
| | | 477 | | /// </returns> |
| | | 478 | | /// <remarks> |
| | | 479 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 480 | | /// a failure occurs. |
| | | 481 | | /// </remarks> |
| | | 482 | | private async Task<Response<ShareServiceProperties>> GetPropertiesInternal( |
| | | 483 | | bool async, |
| | | 484 | | CancellationToken cancellationToken) |
| | | 485 | | { |
| | 10 | 486 | | using (Pipeline.BeginLoggingScope(nameof(ShareServiceClient))) |
| | | 487 | | { |
| | | 488 | | Pipeline.LogMethodEnter( |
| | | 489 | | nameof(ShareServiceClient), |
| | | 490 | | message: $"{nameof(Uri)}: {Uri}"); |
| | | 491 | | try |
| | | 492 | | { |
| | 10 | 493 | | return await FileRestClient.Service.GetPropertiesAsync( |
| | 10 | 494 | | ClientDiagnostics, |
| | 10 | 495 | | Pipeline, |
| | 10 | 496 | | Uri, |
| | 10 | 497 | | version: Version.ToVersionString(), |
| | 10 | 498 | | async: async, |
| | 10 | 499 | | operationName: $"{nameof(ShareServiceClient)}.{nameof(GetProperties)}", |
| | 10 | 500 | | cancellationToken: cancellationToken) |
| | 10 | 501 | | .ConfigureAwait(false); |
| | | 502 | | } |
| | 2 | 503 | | catch (Exception ex) |
| | | 504 | | { |
| | | 505 | | Pipeline.LogException(ex); |
| | 2 | 506 | | throw; |
| | | 507 | | } |
| | | 508 | | finally |
| | | 509 | | { |
| | | 510 | | Pipeline.LogMethodExit(nameof(ShareServiceClient)); |
| | | 511 | | } |
| | | 512 | | } |
| | 8 | 513 | | } |
| | | 514 | | #endregion GetProperties |
| | | 515 | | |
| | | 516 | | #region SetProperties |
| | | 517 | | /// <summary> |
| | | 518 | | /// The <see cref="SetProperties"/> operation sets properties for |
| | | 519 | | /// a storage account’s File service endpoint, including properties |
| | | 520 | | /// for Storage Analytics, CORS (Cross-Origin Resource Sharing) rules |
| | | 521 | | /// and soft delete settings. You can also use this operation to set |
| | | 522 | | /// the default request version for all incoming requests to the File |
| | | 523 | | /// service that do not have a version specified. |
| | | 524 | | /// |
| | | 525 | | /// For more information, see |
| | | 526 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-file-service-properties"> |
| | | 527 | | /// Set File Service Properties</see>. |
| | | 528 | | /// </summary> |
| | | 529 | | /// <param name="properties">The file service properties.</param> |
| | | 530 | | /// <param name="cancellationToken"> |
| | | 531 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 532 | | /// notifications that the operation should be cancelled. |
| | | 533 | | /// </param> |
| | | 534 | | /// <returns> |
| | | 535 | | /// A <see cref="Response"/> if the operation was successful. |
| | | 536 | | /// </returns> |
| | | 537 | | /// <remarks> |
| | | 538 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 539 | | /// a failure occurs. |
| | | 540 | | /// </remarks> |
| | | 541 | | public virtual Response SetProperties( |
| | | 542 | | ShareServiceProperties properties, |
| | | 543 | | CancellationToken cancellationToken = default) => |
| | 2 | 544 | | SetPropertiesInternal( |
| | 2 | 545 | | properties, |
| | 2 | 546 | | false, // async |
| | 2 | 547 | | cancellationToken) |
| | 2 | 548 | | .EnsureCompleted(); |
| | | 549 | | |
| | | 550 | | /// <summary> |
| | | 551 | | /// The <see cref="SetPropertiesAsync"/> operation sets properties for |
| | | 552 | | /// a storage account’s File service endpoint, including properties |
| | | 553 | | /// for Storage Analytics, CORS (Cross-Origin Resource Sharing) rules |
| | | 554 | | /// and soft delete settings. You can also use this operation to set |
| | | 555 | | /// the default request version for all incoming requests to the File |
| | | 556 | | /// service that do not have a version specified. |
| | | 557 | | /// |
| | | 558 | | /// For more information, see |
| | | 559 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-file-service-properties"> |
| | | 560 | | /// Set File Service Properties</see>. |
| | | 561 | | /// </summary> |
| | | 562 | | /// <param name="properties">The file service properties.</param> |
| | | 563 | | /// <param name="cancellationToken"> |
| | | 564 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 565 | | /// notifications that the operation should be cancelled. |
| | | 566 | | /// </param> |
| | | 567 | | /// <returns> |
| | | 568 | | /// A <see cref="Response"/> if the operation was successful. |
| | | 569 | | /// </returns> |
| | | 570 | | /// <remarks> |
| | | 571 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 572 | | /// a failure occurs. |
| | | 573 | | /// </remarks> |
| | | 574 | | public virtual async Task<Response> SetPropertiesAsync( |
| | | 575 | | ShareServiceProperties properties, |
| | | 576 | | CancellationToken cancellationToken = default) => |
| | 2 | 577 | | await SetPropertiesInternal( |
| | 2 | 578 | | properties, |
| | 2 | 579 | | true, // async |
| | 2 | 580 | | cancellationToken) |
| | 2 | 581 | | .ConfigureAwait(false); |
| | | 582 | | |
| | | 583 | | /// <summary> |
| | | 584 | | /// The <see cref="SetPropertiesInternal"/> operation sets properties for |
| | | 585 | | /// a storage account’s File service endpoint, including properties |
| | | 586 | | /// for Storage Analytics, CORS (Cross-Origin Resource Sharing) rules |
| | | 587 | | /// and soft delete settings. You can also use this operation to set |
| | | 588 | | /// the default request version for all incoming requests to the File |
| | | 589 | | /// service that do not have a version specified. |
| | | 590 | | /// |
| | | 591 | | /// For more information, see |
| | | 592 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/set-file-service-properties"> |
| | | 593 | | /// Set File Service Properties</see>. |
| | | 594 | | /// </summary> |
| | | 595 | | /// <param name="properties">The file service properties.</param> |
| | | 596 | | /// <param name="async"> |
| | | 597 | | /// Whether to invoke the operation asynchronously. |
| | | 598 | | /// </param> |
| | | 599 | | /// <param name="cancellationToken"> |
| | | 600 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 601 | | /// notifications that the operation should be cancelled. |
| | | 602 | | /// </param> |
| | | 603 | | /// <returns> |
| | | 604 | | /// A <see cref="Response"/> if the operation was successful. |
| | | 605 | | /// </returns> |
| | | 606 | | /// <remarks> |
| | | 607 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 608 | | /// a failure occurs. |
| | | 609 | | /// </remarks> |
| | | 610 | | private async Task<Response> SetPropertiesInternal( |
| | | 611 | | ShareServiceProperties properties, |
| | | 612 | | bool async, |
| | | 613 | | CancellationToken cancellationToken) |
| | | 614 | | { |
| | 4 | 615 | | using (Pipeline.BeginLoggingScope(nameof(ShareServiceClient))) |
| | | 616 | | { |
| | | 617 | | Pipeline.LogMethodEnter( |
| | | 618 | | nameof(ShareServiceClient), |
| | | 619 | | message: $"{nameof(Uri)}: {Uri}"); |
| | | 620 | | try |
| | | 621 | | { |
| | 4 | 622 | | return await FileRestClient.Service.SetPropertiesAsync( |
| | 4 | 623 | | ClientDiagnostics, |
| | 4 | 624 | | Pipeline, |
| | 4 | 625 | | Uri, |
| | 4 | 626 | | version: Version.ToVersionString(), |
| | 4 | 627 | | properties: properties, |
| | 4 | 628 | | async: async, |
| | 4 | 629 | | operationName: $"{nameof(ShareServiceClient)}.{nameof(SetProperties)}", |
| | 4 | 630 | | cancellationToken: cancellationToken) |
| | 4 | 631 | | .ConfigureAwait(false); |
| | | 632 | | } |
| | 2 | 633 | | catch (Exception ex) |
| | | 634 | | { |
| | | 635 | | Pipeline.LogException(ex); |
| | 2 | 636 | | throw; |
| | | 637 | | } |
| | | 638 | | finally |
| | | 639 | | { |
| | | 640 | | Pipeline.LogMethodExit(nameof(ShareServiceClient)); |
| | | 641 | | } |
| | | 642 | | } |
| | 2 | 643 | | } |
| | | 644 | | #endregion SetProperties |
| | | 645 | | |
| | | 646 | | #region CreateShare |
| | | 647 | | /// <summary> |
| | | 648 | | /// The <see cref="CreateShare"/> operation creates a new share |
| | | 649 | | /// under the specified account. If a share with the same name |
| | | 650 | | /// already exists, the operation fails. |
| | | 651 | | /// |
| | | 652 | | /// For more information, see |
| | | 653 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-share"> |
| | | 654 | | /// Create Share</see>. |
| | | 655 | | /// </summary> |
| | | 656 | | /// <param name="shareName"> |
| | | 657 | | /// The name of the share to create. |
| | | 658 | | /// </param> |
| | | 659 | | /// <param name="metadata"> |
| | | 660 | | /// Optional custom metadata to set for this share. |
| | | 661 | | /// </param> |
| | | 662 | | /// <param name="quotaInGB"> |
| | | 663 | | /// Optional. Maximum size of the share in bytes. If unspecified, use the service's default value. |
| | | 664 | | /// </param> |
| | | 665 | | /// <param name="cancellationToken"> |
| | | 666 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 667 | | /// notifications that the operation should be cancelled. |
| | | 668 | | /// </param> |
| | | 669 | | /// <returns> |
| | | 670 | | /// A <see cref="Response{ShareClient}"/> referencing the newly |
| | | 671 | | /// created share. |
| | | 672 | | /// </returns> |
| | | 673 | | /// <remarks> |
| | | 674 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 675 | | /// a failure occurs. |
| | | 676 | | /// </remarks> |
| | | 677 | | public virtual Response<ShareClient> CreateShare( |
| | | 678 | | string shareName, |
| | | 679 | | IDictionary<string, string> metadata = default, |
| | | 680 | | int? quotaInGB = default, |
| | | 681 | | CancellationToken cancellationToken = default) |
| | | 682 | | { |
| | 2 | 683 | | ShareClient share = GetShareClient(shareName); |
| | | 684 | | |
| | 2 | 685 | | Response<ShareInfo> response = share.CreateInternal( |
| | 2 | 686 | | metadata, |
| | 2 | 687 | | quotaInGB, |
| | 2 | 688 | | async: false, |
| | 2 | 689 | | cancellationToken, |
| | 2 | 690 | | operationName: $"{nameof(ShareServiceClient)}.{nameof(CreateShare)}") |
| | 2 | 691 | | .EnsureCompleted(); |
| | | 692 | | |
| | 2 | 693 | | return Response.FromValue(share, response.GetRawResponse()); |
| | | 694 | | } |
| | | 695 | | |
| | | 696 | | /// <summary> |
| | | 697 | | /// The <see cref="CreateShareAsync"/> operation creates a new share |
| | | 698 | | /// under the specified account. If a share with the same name |
| | | 699 | | /// already exists, the operation fails. |
| | | 700 | | /// |
| | | 701 | | /// For more information, see |
| | | 702 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/create-share"> |
| | | 703 | | /// Create Share</see>. |
| | | 704 | | /// </summary> |
| | | 705 | | /// <param name="shareName"> |
| | | 706 | | /// The name of the share to create. |
| | | 707 | | /// </param> |
| | | 708 | | /// <param name="metadata"> |
| | | 709 | | /// Optional custom metadata to set for this share. |
| | | 710 | | /// </param> |
| | | 711 | | /// <param name="quotaInGB"> |
| | | 712 | | /// Optional. Maximum size of the share in bytes. If unspecified, use the service's default value. |
| | | 713 | | /// </param> |
| | | 714 | | /// <param name="cancellationToken"> |
| | | 715 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 716 | | /// notifications that the operation should be cancelled. |
| | | 717 | | /// </param> |
| | | 718 | | /// <returns> |
| | | 719 | | /// A <see cref="Response{ShareClient}"/> referencing the newly |
| | | 720 | | /// created share. |
| | | 721 | | /// </returns> |
| | | 722 | | /// <remarks> |
| | | 723 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 724 | | /// a failure occurs. |
| | | 725 | | /// </remarks> |
| | | 726 | | public virtual async Task<Response<ShareClient>> CreateShareAsync( |
| | | 727 | | string shareName, |
| | | 728 | | IDictionary<string, string> metadata = default, |
| | | 729 | | int? quotaInGB = default, |
| | | 730 | | CancellationToken cancellationToken = default) |
| | | 731 | | { |
| | 2 | 732 | | ShareClient share = GetShareClient(shareName); |
| | | 733 | | |
| | 2 | 734 | | Response<ShareInfo> response = await share.CreateInternal( |
| | 2 | 735 | | metadata, |
| | 2 | 736 | | quotaInGB, |
| | 2 | 737 | | async: true, |
| | 2 | 738 | | cancellationToken, |
| | 2 | 739 | | operationName: $"{nameof(ShareServiceClient)}.{nameof(CreateShare)}") |
| | 2 | 740 | | .ConfigureAwait(false); |
| | | 741 | | |
| | 2 | 742 | | return Response.FromValue(share, response.GetRawResponse()); |
| | 2 | 743 | | } |
| | | 744 | | #endregion CreateShare |
| | | 745 | | |
| | | 746 | | #region DeleteShare |
| | | 747 | | /// <summary> |
| | | 748 | | /// Marks the specified share or share snapshot for deletion. |
| | | 749 | | /// The share or share snapshot and any files contained within it are later deleted during garbage collection. |
| | | 750 | | /// |
| | | 751 | | /// Currently, this method will always delete snapshots. |
| | | 752 | | /// There's no way to specify a separate value for x-ms-delete-snapshots. |
| | | 753 | | /// |
| | | 754 | | /// For more information, see |
| | | 755 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-share"> |
| | | 756 | | /// Delete Share</see>. |
| | | 757 | | /// </summary> |
| | | 758 | | /// <param name="shareName"> |
| | | 759 | | /// The name of the share to delete. |
| | | 760 | | /// </param> |
| | | 761 | | /// <param name="includeSnapshots"> |
| | | 762 | | /// A value indicating whether to delete a share's snapshots in addition |
| | | 763 | | /// to the share itself. |
| | | 764 | | /// </param> |
| | | 765 | | /// <param name="cancellationToken"> |
| | | 766 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 767 | | /// notifications that the operation should be cancelled. |
| | | 768 | | /// </param> |
| | | 769 | | /// <returns> |
| | | 770 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 771 | | /// </returns> |
| | | 772 | | /// <remarks> |
| | | 773 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 774 | | /// a failure occurs. |
| | | 775 | | /// </remarks> |
| | | 776 | | public virtual Response DeleteShare( |
| | | 777 | | string shareName, |
| | | 778 | | bool includeSnapshots = true, |
| | | 779 | | CancellationToken cancellationToken = default) => |
| | 2 | 780 | | GetShareClient(shareName).DeleteInternal( |
| | 2 | 781 | | includeSnapshots, |
| | 2 | 782 | | async: false, |
| | 2 | 783 | | cancellationToken, |
| | 2 | 784 | | operationName: $"{nameof(ShareServiceClient)}.{nameof(DeleteShare)}") |
| | 2 | 785 | | .EnsureCompleted(); |
| | | 786 | | |
| | | 787 | | /// <summary> |
| | | 788 | | /// Marks the specified share or share snapshot for deletion. |
| | | 789 | | /// The share or share snapshot and any files contained within it are later deleted during garbage collection. |
| | | 790 | | /// |
| | | 791 | | /// Currently, this method will always delete snapshots. There's no way to specify a separate value for x-ms-de |
| | | 792 | | /// |
| | | 793 | | /// For more information, see |
| | | 794 | | /// <see href="https://docs.microsoft.com/rest/api/storageservices/delete-share"> |
| | | 795 | | /// Delete Share</see>. |
| | | 796 | | /// </summary> |
| | | 797 | | /// <param name="shareName"> |
| | | 798 | | /// The name of the share to delete. |
| | | 799 | | /// </param> |
| | | 800 | | /// <param name="includeSnapshots"> |
| | | 801 | | /// A value indicating whether to delete a share's snapshots in addition |
| | | 802 | | /// to the share itself. |
| | | 803 | | /// </param> |
| | | 804 | | /// <param name="cancellationToken"> |
| | | 805 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 806 | | /// notifications that the operation should be cancelled. |
| | | 807 | | /// </param> |
| | | 808 | | /// <returns> |
| | | 809 | | /// A <see cref="Response"/> on successfully deleting. |
| | | 810 | | /// </returns> |
| | | 811 | | /// <remarks> |
| | | 812 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 813 | | /// a failure occurs. |
| | | 814 | | /// </remarks> |
| | | 815 | | public virtual async Task<Response> DeleteShareAsync( |
| | | 816 | | string shareName, |
| | | 817 | | bool includeSnapshots = true, |
| | | 818 | | CancellationToken cancellationToken = default) => |
| | 2 | 819 | | await GetShareClient(shareName) |
| | 2 | 820 | | .DeleteInternal( |
| | 2 | 821 | | includeSnapshots, |
| | 2 | 822 | | async: true, |
| | 2 | 823 | | cancellationToken, |
| | 2 | 824 | | operationName: $"{nameof(ShareServiceClient)}.{nameof(DeleteShare)}") |
| | 2 | 825 | | .ConfigureAwait(false); |
| | | 826 | | #endregion DeleteShare |
| | | 827 | | |
| | | 828 | | #region UndeleteShare |
| | | 829 | | /// <summary> |
| | | 830 | | /// Restores a previously deleted Share. |
| | | 831 | | /// This API is only functional is Share Soft Delete is enabled |
| | | 832 | | /// for the storage account associated with the share. |
| | | 833 | | /// </summary> |
| | | 834 | | /// <param name="deletedShareName"> |
| | | 835 | | /// The name of the share to restore. |
| | | 836 | | /// </param> |
| | | 837 | | /// <param name="deletedShareVersion"> |
| | | 838 | | /// The version of the share to restore. |
| | | 839 | | /// </param> |
| | | 840 | | /// <param name="cancellationToken"> |
| | | 841 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 842 | | /// notifications that the operation should be cancelled. |
| | | 843 | | /// </param> |
| | | 844 | | /// <returns> |
| | | 845 | | /// A <see cref="Response{ShareClient}"/> pointed at the restored Share. |
| | | 846 | | /// </returns> |
| | | 847 | | /// <remarks> |
| | | 848 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 849 | | /// a failure occurs. |
| | | 850 | | /// </remarks> |
| | | 851 | | public virtual Response<ShareClient> UndeleteShare( |
| | | 852 | | string deletedShareName, |
| | | 853 | | string deletedShareVersion, |
| | | 854 | | CancellationToken cancellationToken = default) |
| | 2 | 855 | | => UndeleteShareInternal( |
| | 2 | 856 | | deletedShareName, |
| | 2 | 857 | | deletedShareVersion, |
| | 2 | 858 | | async: false, |
| | 2 | 859 | | cancellationToken).EnsureCompleted(); |
| | | 860 | | |
| | | 861 | | /// <summary> |
| | | 862 | | /// Restores a previously deleted Share. |
| | | 863 | | /// This API is only functional is Share Soft Delete is enabled |
| | | 864 | | /// for the storage account associated with the share. |
| | | 865 | | /// </summary> |
| | | 866 | | /// <param name="deletedShareName"> |
| | | 867 | | /// The name of the share to restore. |
| | | 868 | | /// </param> |
| | | 869 | | /// <param name="deletedShareVersion"> |
| | | 870 | | /// The version of the share to restore. |
| | | 871 | | /// </param> |
| | | 872 | | /// <param name="cancellationToken"> |
| | | 873 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 874 | | /// notifications that the operation should be cancelled. |
| | | 875 | | /// </param> |
| | | 876 | | /// <returns> |
| | | 877 | | /// A <see cref="Response{ShareClient}"/> pointed at the restored Share. |
| | | 878 | | /// </returns> |
| | | 879 | | /// <remarks> |
| | | 880 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 881 | | /// a failure occurs |
| | | 882 | | /// </remarks> |
| | | 883 | | public virtual async Task<Response<ShareClient>> UndeleteShareAsync( |
| | | 884 | | string deletedShareName, |
| | | 885 | | string deletedShareVersion, |
| | | 886 | | CancellationToken cancellationToken = default) |
| | 2 | 887 | | => await UndeleteShareInternal( |
| | 2 | 888 | | deletedShareName, |
| | 2 | 889 | | deletedShareVersion, |
| | 2 | 890 | | async: true, |
| | 2 | 891 | | cancellationToken).ConfigureAwait(false); |
| | | 892 | | |
| | | 893 | | /// <summary> |
| | | 894 | | /// Restores a previously deleted Share. |
| | | 895 | | /// This API is only functional is Share Soft Delete is enabled |
| | | 896 | | /// for the storage account associated with the share. |
| | | 897 | | /// </summary> |
| | | 898 | | /// <param name="deletedShareName"> |
| | | 899 | | /// The name of the share to restore. |
| | | 900 | | /// </param> |
| | | 901 | | /// <param name="deletedShareVersion"> |
| | | 902 | | /// The version of the share to restore. |
| | | 903 | | /// </param> |
| | | 904 | | /// <param name="async"> |
| | | 905 | | /// Whether to invoke the operation asynchronously. |
| | | 906 | | /// </param> |
| | | 907 | | /// <param name="cancellationToken"> |
| | | 908 | | /// Optional <see cref="CancellationToken"/> to propagate |
| | | 909 | | /// notifications that the operation should be cancelled. |
| | | 910 | | /// </param> |
| | | 911 | | /// <returns> |
| | | 912 | | /// A <see cref="Response{ShareClient}"/> pointed at the restored Share. |
| | | 913 | | /// </returns> |
| | | 914 | | /// <remarks> |
| | | 915 | | /// A <see cref="RequestFailedException"/> will be thrown if |
| | | 916 | | /// a failure occurs. |
| | | 917 | | /// </remarks> |
| | | 918 | | private async Task<Response<ShareClient>> UndeleteShareInternal( |
| | | 919 | | string deletedShareName, |
| | | 920 | | string deletedShareVersion, |
| | | 921 | | bool async, |
| | | 922 | | CancellationToken cancellationToken) |
| | | 923 | | { |
| | 4 | 924 | | using (Pipeline.BeginLoggingScope(nameof(ShareServiceClient))) |
| | | 925 | | { |
| | | 926 | | Pipeline.LogMethodEnter( |
| | | 927 | | nameof(ShareServiceClient), |
| | | 928 | | message: |
| | | 929 | | $"{nameof(Uri)}: {Uri}\n" + |
| | | 930 | | $"{nameof(deletedShareName)}: {deletedShareName}\n" + |
| | | 931 | | $"{nameof(deletedShareVersion)}: {deletedShareVersion}"); |
| | | 932 | | |
| | | 933 | | try |
| | | 934 | | { |
| | 4 | 935 | | ShareClient shareClient = GetShareClient(deletedShareName); |
| | | 936 | | |
| | 4 | 937 | | Response<ShareInfo> response = await FileRestClient.Share.RestoreAsync( |
| | 4 | 938 | | ClientDiagnostics, |
| | 4 | 939 | | Pipeline, |
| | 4 | 940 | | shareClient.Uri, |
| | 4 | 941 | | Version.ToVersionString(), |
| | 4 | 942 | | deletedShareName: deletedShareName, |
| | 4 | 943 | | deletedShareVersion: deletedShareVersion, |
| | 4 | 944 | | async: async, |
| | 4 | 945 | | operationName: $"{nameof(ShareServiceClient)}.{nameof(UndeleteShare)}", |
| | 4 | 946 | | cancellationToken: cancellationToken) |
| | 4 | 947 | | .ConfigureAwait(false); |
| | | 948 | | |
| | 2 | 949 | | return Response.FromValue(shareClient, response.GetRawResponse()); |
| | | 950 | | } |
| | 2 | 951 | | catch (Exception ex) |
| | | 952 | | { |
| | | 953 | | Pipeline.LogException(ex); |
| | 2 | 954 | | throw; |
| | | 955 | | } |
| | | 956 | | finally |
| | | 957 | | { |
| | | 958 | | Pipeline.LogMethodExit(nameof(ShareServiceClient)); |
| | | 959 | | } |
| | | 960 | | } |
| | 2 | 961 | | } |
| | | 962 | | #endregion |
| | | 963 | | } |
| | | 964 | | } |