| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Storage.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Storage |
| | 18 | | { |
| | 19 | | internal partial class FileSharesRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private string apiVersion; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of FileSharesRestOperations. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 31 | | /// <param name="endpoint"> server parameter. </param> |
| | 32 | | /// <param name="apiVersion"> Api Version. </param> |
| | 33 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 240 | 34 | | public FileSharesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionI |
| | 35 | | { |
| 240 | 36 | | if (subscriptionId == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 39 | | } |
| 240 | 40 | | endpoint ??= new Uri("https://management.azure.com"); |
| 240 | 41 | | if (apiVersion == null) |
| | 42 | | { |
| 0 | 43 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 44 | | } |
| | 45 | |
|
| 240 | 46 | | this.subscriptionId = subscriptionId; |
| 240 | 47 | | this.endpoint = endpoint; |
| 240 | 48 | | this.apiVersion = apiVersion; |
| 240 | 49 | | _clientDiagnostics = clientDiagnostics; |
| 240 | 50 | | _pipeline = pipeline; |
| 240 | 51 | | } |
| | 52 | |
|
| | 53 | | internal HttpMessage CreateListRequest(string resourceGroupName, string accountName, string maxpagesize, string |
| | 54 | | { |
| 8 | 55 | | var message = _pipeline.CreateMessage(); |
| 8 | 56 | | var request = message.Request; |
| 8 | 57 | | request.Method = RequestMethod.Get; |
| 8 | 58 | | var uri = new RawRequestUriBuilder(); |
| 8 | 59 | | uri.Reset(endpoint); |
| 8 | 60 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 61 | | uri.AppendPath(subscriptionId, true); |
| 8 | 62 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 63 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 64 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 8 | 65 | | uri.AppendPath(accountName, true); |
| 8 | 66 | | uri.AppendPath("/fileServices/default/shares", false); |
| 8 | 67 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 68 | | if (maxpagesize != null) |
| | 69 | | { |
| 0 | 70 | | uri.AppendQuery("$maxpagesize", maxpagesize, true); |
| | 71 | | } |
| 8 | 72 | | if (filter != null) |
| | 73 | | { |
| 0 | 74 | | uri.AppendQuery("$filter", filter, true); |
| | 75 | | } |
| 8 | 76 | | uri.AppendQuery("$expand", "deleted", true); |
| 8 | 77 | | request.Uri = uri; |
| 8 | 78 | | return message; |
| | 79 | | } |
| | 80 | |
|
| | 81 | | /// <summary> Lists all shares. </summary> |
| | 82 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 83 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 84 | | /// <param name="maxpagesize"> Optional. Specified maximum number of shares that can be included in the list. </ |
| | 85 | | /// <param name="filter"> Optional. When specified, only share names starting with the filter will be listed. </ |
| | 86 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 87 | | public async Task<Response<FileShareItems>> ListAsync(string resourceGroupName, string accountName, string maxpa |
| | 88 | | { |
| 4 | 89 | | if (resourceGroupName == null) |
| | 90 | | { |
| 0 | 91 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 92 | | } |
| 4 | 93 | | if (accountName == null) |
| | 94 | | { |
| 0 | 95 | | throw new ArgumentNullException(nameof(accountName)); |
| | 96 | | } |
| | 97 | |
|
| 4 | 98 | | using var message = CreateListRequest(resourceGroupName, accountName, maxpagesize, filter); |
| 4 | 99 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 100 | | switch (message.Response.Status) |
| | 101 | | { |
| | 102 | | case 200: |
| | 103 | | { |
| 4 | 104 | | FileShareItems value = default; |
| 4 | 105 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 106 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 107 | | { |
| 0 | 108 | | value = null; |
| | 109 | | } |
| | 110 | | else |
| | 111 | | { |
| 4 | 112 | | value = FileShareItems.DeserializeFileShareItems(document.RootElement); |
| | 113 | | } |
| 4 | 114 | | return Response.FromValue(value, message.Response); |
| | 115 | | } |
| | 116 | | default: |
| 0 | 117 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 118 | | } |
| 4 | 119 | | } |
| | 120 | |
|
| | 121 | | /// <summary> Lists all shares. </summary> |
| | 122 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 123 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 124 | | /// <param name="maxpagesize"> Optional. Specified maximum number of shares that can be included in the list. </ |
| | 125 | | /// <param name="filter"> Optional. When specified, only share names starting with the filter will be listed. </ |
| | 126 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 127 | | public Response<FileShareItems> List(string resourceGroupName, string accountName, string maxpagesize = null, st |
| | 128 | | { |
| 4 | 129 | | if (resourceGroupName == null) |
| | 130 | | { |
| 0 | 131 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 132 | | } |
| 4 | 133 | | if (accountName == null) |
| | 134 | | { |
| 0 | 135 | | throw new ArgumentNullException(nameof(accountName)); |
| | 136 | | } |
| | 137 | |
|
| 4 | 138 | | using var message = CreateListRequest(resourceGroupName, accountName, maxpagesize, filter); |
| 4 | 139 | | _pipeline.Send(message, cancellationToken); |
| 4 | 140 | | switch (message.Response.Status) |
| | 141 | | { |
| | 142 | | case 200: |
| | 143 | | { |
| 4 | 144 | | FileShareItems value = default; |
| 4 | 145 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 146 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 147 | | { |
| 0 | 148 | | value = null; |
| | 149 | | } |
| | 150 | | else |
| | 151 | | { |
| 4 | 152 | | value = FileShareItems.DeserializeFileShareItems(document.RootElement); |
| | 153 | | } |
| 4 | 154 | | return Response.FromValue(value, message.Response); |
| | 155 | | } |
| | 156 | | default: |
| 0 | 157 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 158 | | } |
| 4 | 159 | | } |
| | 160 | |
|
| | 161 | | internal HttpMessage CreateCreateRequest(string resourceGroupName, string accountName, string shareName, FileSha |
| | 162 | | { |
| 12 | 163 | | var message = _pipeline.CreateMessage(); |
| 12 | 164 | | var request = message.Request; |
| 12 | 165 | | request.Method = RequestMethod.Put; |
| 12 | 166 | | var uri = new RawRequestUriBuilder(); |
| 12 | 167 | | uri.Reset(endpoint); |
| 12 | 168 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 169 | | uri.AppendPath(subscriptionId, true); |
| 12 | 170 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 171 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 172 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 173 | | uri.AppendPath(accountName, true); |
| 12 | 174 | | uri.AppendPath("/fileServices/default/shares/", false); |
| 12 | 175 | | uri.AppendPath(shareName, true); |
| 12 | 176 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 177 | | request.Uri = uri; |
| 12 | 178 | | request.Headers.Add("Content-Type", "application/json"); |
| 12 | 179 | | var content = new Utf8JsonRequestContent(); |
| 12 | 180 | | content.JsonWriter.WriteObjectValue(fileShare); |
| 12 | 181 | | request.Content = content; |
| 12 | 182 | | return message; |
| | 183 | | } |
| | 184 | |
|
| | 185 | | /// <summary> Creates a new share under the specified account as described by request body. The share resource i |
| | 186 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 187 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 188 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 189 | | /// <param name="fileShare"> Properties of the file share to create. </param> |
| | 190 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 191 | | public async Task<Response<FileShare>> CreateAsync(string resourceGroupName, string accountName, string shareNam |
| | 192 | | { |
| 6 | 193 | | if (resourceGroupName == null) |
| | 194 | | { |
| 0 | 195 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 196 | | } |
| 6 | 197 | | if (accountName == null) |
| | 198 | | { |
| 0 | 199 | | throw new ArgumentNullException(nameof(accountName)); |
| | 200 | | } |
| 6 | 201 | | if (shareName == null) |
| | 202 | | { |
| 0 | 203 | | throw new ArgumentNullException(nameof(shareName)); |
| | 204 | | } |
| 6 | 205 | | if (fileShare == null) |
| | 206 | | { |
| 0 | 207 | | throw new ArgumentNullException(nameof(fileShare)); |
| | 208 | | } |
| | 209 | |
|
| 6 | 210 | | using var message = CreateCreateRequest(resourceGroupName, accountName, shareName, fileShare); |
| 6 | 211 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 212 | | switch (message.Response.Status) |
| | 213 | | { |
| | 214 | | case 200: |
| | 215 | | case 201: |
| | 216 | | { |
| 6 | 217 | | FileShare value = default; |
| 6 | 218 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 219 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 220 | | { |
| 0 | 221 | | value = null; |
| | 222 | | } |
| | 223 | | else |
| | 224 | | { |
| 6 | 225 | | value = FileShare.DeserializeFileShare(document.RootElement); |
| | 226 | | } |
| 6 | 227 | | return Response.FromValue(value, message.Response); |
| | 228 | | } |
| | 229 | | default: |
| 0 | 230 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 231 | | } |
| 6 | 232 | | } |
| | 233 | |
|
| | 234 | | /// <summary> Creates a new share under the specified account as described by request body. The share resource i |
| | 235 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 236 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 237 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 238 | | /// <param name="fileShare"> Properties of the file share to create. </param> |
| | 239 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 240 | | public Response<FileShare> Create(string resourceGroupName, string accountName, string shareName, FileShare file |
| | 241 | | { |
| 6 | 242 | | if (resourceGroupName == null) |
| | 243 | | { |
| 0 | 244 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 245 | | } |
| 6 | 246 | | if (accountName == null) |
| | 247 | | { |
| 0 | 248 | | throw new ArgumentNullException(nameof(accountName)); |
| | 249 | | } |
| 6 | 250 | | if (shareName == null) |
| | 251 | | { |
| 0 | 252 | | throw new ArgumentNullException(nameof(shareName)); |
| | 253 | | } |
| 6 | 254 | | if (fileShare == null) |
| | 255 | | { |
| 0 | 256 | | throw new ArgumentNullException(nameof(fileShare)); |
| | 257 | | } |
| | 258 | |
|
| 6 | 259 | | using var message = CreateCreateRequest(resourceGroupName, accountName, shareName, fileShare); |
| 6 | 260 | | _pipeline.Send(message, cancellationToken); |
| 6 | 261 | | switch (message.Response.Status) |
| | 262 | | { |
| | 263 | | case 200: |
| | 264 | | case 201: |
| | 265 | | { |
| 6 | 266 | | FileShare value = default; |
| 6 | 267 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 268 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 269 | | { |
| 0 | 270 | | value = null; |
| | 271 | | } |
| | 272 | | else |
| | 273 | | { |
| 6 | 274 | | value = FileShare.DeserializeFileShare(document.RootElement); |
| | 275 | | } |
| 6 | 276 | | return Response.FromValue(value, message.Response); |
| | 277 | | } |
| | 278 | | default: |
| 0 | 279 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 280 | | } |
| 6 | 281 | | } |
| | 282 | |
|
| | 283 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string accountName, string shareName, FileSha |
| | 284 | | { |
| 4 | 285 | | var message = _pipeline.CreateMessage(); |
| 4 | 286 | | var request = message.Request; |
| 4 | 287 | | request.Method = RequestMethod.Patch; |
| 4 | 288 | | var uri = new RawRequestUriBuilder(); |
| 4 | 289 | | uri.Reset(endpoint); |
| 4 | 290 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 291 | | uri.AppendPath(subscriptionId, true); |
| 4 | 292 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 293 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 294 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 4 | 295 | | uri.AppendPath(accountName, true); |
| 4 | 296 | | uri.AppendPath("/fileServices/default/shares/", false); |
| 4 | 297 | | uri.AppendPath(shareName, true); |
| 4 | 298 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 299 | | request.Uri = uri; |
| 4 | 300 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 301 | | var content = new Utf8JsonRequestContent(); |
| 4 | 302 | | content.JsonWriter.WriteObjectValue(fileShare); |
| 4 | 303 | | request.Content = content; |
| 4 | 304 | | return message; |
| | 305 | | } |
| | 306 | |
|
| | 307 | | /// <summary> Updates share properties as specified in request body. Properties not mentioned in the request wil |
| | 308 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 309 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 310 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 311 | | /// <param name="fileShare"> Properties to update for the file share. </param> |
| | 312 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 313 | | public async Task<Response<FileShare>> UpdateAsync(string resourceGroupName, string accountName, string shareNam |
| | 314 | | { |
| 2 | 315 | | if (resourceGroupName == null) |
| | 316 | | { |
| 0 | 317 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 318 | | } |
| 2 | 319 | | if (accountName == null) |
| | 320 | | { |
| 0 | 321 | | throw new ArgumentNullException(nameof(accountName)); |
| | 322 | | } |
| 2 | 323 | | if (shareName == null) |
| | 324 | | { |
| 0 | 325 | | throw new ArgumentNullException(nameof(shareName)); |
| | 326 | | } |
| 2 | 327 | | if (fileShare == null) |
| | 328 | | { |
| 0 | 329 | | throw new ArgumentNullException(nameof(fileShare)); |
| | 330 | | } |
| | 331 | |
|
| 2 | 332 | | using var message = CreateUpdateRequest(resourceGroupName, accountName, shareName, fileShare); |
| 2 | 333 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 334 | | switch (message.Response.Status) |
| | 335 | | { |
| | 336 | | case 200: |
| | 337 | | { |
| 2 | 338 | | FileShare value = default; |
| 2 | 339 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 340 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 341 | | { |
| 0 | 342 | | value = null; |
| | 343 | | } |
| | 344 | | else |
| | 345 | | { |
| 2 | 346 | | value = FileShare.DeserializeFileShare(document.RootElement); |
| | 347 | | } |
| 2 | 348 | | return Response.FromValue(value, message.Response); |
| | 349 | | } |
| | 350 | | default: |
| 0 | 351 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 352 | | } |
| 2 | 353 | | } |
| | 354 | |
|
| | 355 | | /// <summary> Updates share properties as specified in request body. Properties not mentioned in the request wil |
| | 356 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 357 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 358 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 359 | | /// <param name="fileShare"> Properties to update for the file share. </param> |
| | 360 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 361 | | public Response<FileShare> Update(string resourceGroupName, string accountName, string shareName, FileShare file |
| | 362 | | { |
| 2 | 363 | | if (resourceGroupName == null) |
| | 364 | | { |
| 0 | 365 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 366 | | } |
| 2 | 367 | | if (accountName == null) |
| | 368 | | { |
| 0 | 369 | | throw new ArgumentNullException(nameof(accountName)); |
| | 370 | | } |
| 2 | 371 | | if (shareName == null) |
| | 372 | | { |
| 0 | 373 | | throw new ArgumentNullException(nameof(shareName)); |
| | 374 | | } |
| 2 | 375 | | if (fileShare == null) |
| | 376 | | { |
| 0 | 377 | | throw new ArgumentNullException(nameof(fileShare)); |
| | 378 | | } |
| | 379 | |
|
| 2 | 380 | | using var message = CreateUpdateRequest(resourceGroupName, accountName, shareName, fileShare); |
| 2 | 381 | | _pipeline.Send(message, cancellationToken); |
| 2 | 382 | | switch (message.Response.Status) |
| | 383 | | { |
| | 384 | | case 200: |
| | 385 | | { |
| 2 | 386 | | FileShare value = default; |
| 2 | 387 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 388 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 389 | | { |
| 0 | 390 | | value = null; |
| | 391 | | } |
| | 392 | | else |
| | 393 | | { |
| 2 | 394 | | value = FileShare.DeserializeFileShare(document.RootElement); |
| | 395 | | } |
| 2 | 396 | | return Response.FromValue(value, message.Response); |
| | 397 | | } |
| | 398 | | default: |
| 0 | 399 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 400 | | } |
| 2 | 401 | | } |
| | 402 | |
|
| | 403 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string accountName, string shareName) |
| | 404 | | { |
| 12 | 405 | | var message = _pipeline.CreateMessage(); |
| 12 | 406 | | var request = message.Request; |
| 12 | 407 | | request.Method = RequestMethod.Get; |
| 12 | 408 | | var uri = new RawRequestUriBuilder(); |
| 12 | 409 | | uri.Reset(endpoint); |
| 12 | 410 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 411 | | uri.AppendPath(subscriptionId, true); |
| 12 | 412 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 413 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 414 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 415 | | uri.AppendPath(accountName, true); |
| 12 | 416 | | uri.AppendPath("/fileServices/default/shares/", false); |
| 12 | 417 | | uri.AppendPath(shareName, true); |
| 12 | 418 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 419 | | uri.AppendQuery("$expand", "stats", true); |
| 12 | 420 | | request.Uri = uri; |
| 12 | 421 | | return message; |
| | 422 | | } |
| | 423 | |
|
| | 424 | | /// <summary> Gets properties of a specified share. </summary> |
| | 425 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 426 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 427 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 428 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 429 | | public async Task<Response<FileShare>> GetAsync(string resourceGroupName, string accountName, string shareName, |
| | 430 | | { |
| 6 | 431 | | if (resourceGroupName == null) |
| | 432 | | { |
| 0 | 433 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 434 | | } |
| 6 | 435 | | if (accountName == null) |
| | 436 | | { |
| 0 | 437 | | throw new ArgumentNullException(nameof(accountName)); |
| | 438 | | } |
| 6 | 439 | | if (shareName == null) |
| | 440 | | { |
| 0 | 441 | | throw new ArgumentNullException(nameof(shareName)); |
| | 442 | | } |
| | 443 | |
|
| 6 | 444 | | using var message = CreateGetRequest(resourceGroupName, accountName, shareName); |
| 6 | 445 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 446 | | switch (message.Response.Status) |
| | 447 | | { |
| | 448 | | case 200: |
| | 449 | | { |
| 6 | 450 | | FileShare value = default; |
| 6 | 451 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 452 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 453 | | { |
| 0 | 454 | | value = null; |
| | 455 | | } |
| | 456 | | else |
| | 457 | | { |
| 6 | 458 | | value = FileShare.DeserializeFileShare(document.RootElement); |
| | 459 | | } |
| 6 | 460 | | return Response.FromValue(value, message.Response); |
| | 461 | | } |
| | 462 | | default: |
| 0 | 463 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 464 | | } |
| 6 | 465 | | } |
| | 466 | |
|
| | 467 | | /// <summary> Gets properties of a specified share. </summary> |
| | 468 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 469 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 470 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 471 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 472 | | public Response<FileShare> Get(string resourceGroupName, string accountName, string shareName, CancellationToken |
| | 473 | | { |
| 6 | 474 | | if (resourceGroupName == null) |
| | 475 | | { |
| 0 | 476 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 477 | | } |
| 6 | 478 | | if (accountName == null) |
| | 479 | | { |
| 0 | 480 | | throw new ArgumentNullException(nameof(accountName)); |
| | 481 | | } |
| 6 | 482 | | if (shareName == null) |
| | 483 | | { |
| 0 | 484 | | throw new ArgumentNullException(nameof(shareName)); |
| | 485 | | } |
| | 486 | |
|
| 6 | 487 | | using var message = CreateGetRequest(resourceGroupName, accountName, shareName); |
| 6 | 488 | | _pipeline.Send(message, cancellationToken); |
| 6 | 489 | | switch (message.Response.Status) |
| | 490 | | { |
| | 491 | | case 200: |
| | 492 | | { |
| 6 | 493 | | FileShare value = default; |
| 6 | 494 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 495 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 496 | | { |
| 0 | 497 | | value = null; |
| | 498 | | } |
| | 499 | | else |
| | 500 | | { |
| 6 | 501 | | value = FileShare.DeserializeFileShare(document.RootElement); |
| | 502 | | } |
| 6 | 503 | | return Response.FromValue(value, message.Response); |
| | 504 | | } |
| | 505 | | default: |
| 0 | 506 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 507 | | } |
| 6 | 508 | | } |
| | 509 | |
|
| | 510 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string accountName, string shareName) |
| | 511 | | { |
| 12 | 512 | | var message = _pipeline.CreateMessage(); |
| 12 | 513 | | var request = message.Request; |
| 12 | 514 | | request.Method = RequestMethod.Delete; |
| 12 | 515 | | var uri = new RawRequestUriBuilder(); |
| 12 | 516 | | uri.Reset(endpoint); |
| 12 | 517 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 518 | | uri.AppendPath(subscriptionId, true); |
| 12 | 519 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 520 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 521 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 522 | | uri.AppendPath(accountName, true); |
| 12 | 523 | | uri.AppendPath("/fileServices/default/shares/", false); |
| 12 | 524 | | uri.AppendPath(shareName, true); |
| 12 | 525 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 526 | | request.Uri = uri; |
| 12 | 527 | | return message; |
| | 528 | | } |
| | 529 | |
|
| | 530 | | /// <summary> Deletes specified share under its account. </summary> |
| | 531 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 532 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 533 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 534 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 535 | | public async Task<Response> DeleteAsync(string resourceGroupName, string accountName, string shareName, Cancella |
| | 536 | | { |
| 6 | 537 | | if (resourceGroupName == null) |
| | 538 | | { |
| 0 | 539 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 540 | | } |
| 6 | 541 | | if (accountName == null) |
| | 542 | | { |
| 0 | 543 | | throw new ArgumentNullException(nameof(accountName)); |
| | 544 | | } |
| 6 | 545 | | if (shareName == null) |
| | 546 | | { |
| 0 | 547 | | throw new ArgumentNullException(nameof(shareName)); |
| | 548 | | } |
| | 549 | |
|
| 6 | 550 | | using var message = CreateDeleteRequest(resourceGroupName, accountName, shareName); |
| 6 | 551 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 552 | | switch (message.Response.Status) |
| | 553 | | { |
| | 554 | | case 200: |
| | 555 | | case 204: |
| 6 | 556 | | return message.Response; |
| | 557 | | default: |
| 0 | 558 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 559 | | } |
| 6 | 560 | | } |
| | 561 | |
|
| | 562 | | /// <summary> Deletes specified share under its account. </summary> |
| | 563 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 564 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 565 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 566 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 567 | | public Response Delete(string resourceGroupName, string accountName, string shareName, CancellationToken cancell |
| | 568 | | { |
| 6 | 569 | | if (resourceGroupName == null) |
| | 570 | | { |
| 0 | 571 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 572 | | } |
| 6 | 573 | | if (accountName == null) |
| | 574 | | { |
| 0 | 575 | | throw new ArgumentNullException(nameof(accountName)); |
| | 576 | | } |
| 6 | 577 | | if (shareName == null) |
| | 578 | | { |
| 0 | 579 | | throw new ArgumentNullException(nameof(shareName)); |
| | 580 | | } |
| | 581 | |
|
| 6 | 582 | | using var message = CreateDeleteRequest(resourceGroupName, accountName, shareName); |
| 6 | 583 | | _pipeline.Send(message, cancellationToken); |
| 6 | 584 | | switch (message.Response.Status) |
| | 585 | | { |
| | 586 | | case 200: |
| | 587 | | case 204: |
| 6 | 588 | | return message.Response; |
| | 589 | | default: |
| 0 | 590 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 591 | | } |
| 6 | 592 | | } |
| | 593 | |
|
| | 594 | | internal HttpMessage CreateRestoreRequest(string resourceGroupName, string accountName, string shareName, Delete |
| | 595 | | { |
| 0 | 596 | | var message = _pipeline.CreateMessage(); |
| 0 | 597 | | var request = message.Request; |
| 0 | 598 | | request.Method = RequestMethod.Post; |
| 0 | 599 | | var uri = new RawRequestUriBuilder(); |
| 0 | 600 | | uri.Reset(endpoint); |
| 0 | 601 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 602 | | uri.AppendPath(subscriptionId, true); |
| 0 | 603 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 604 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 605 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 0 | 606 | | uri.AppendPath(accountName, true); |
| 0 | 607 | | uri.AppendPath("/fileServices/default/shares/", false); |
| 0 | 608 | | uri.AppendPath(shareName, true); |
| 0 | 609 | | uri.AppendPath("/restore", false); |
| 0 | 610 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 611 | | request.Uri = uri; |
| 0 | 612 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 613 | | var content = new Utf8JsonRequestContent(); |
| 0 | 614 | | content.JsonWriter.WriteObjectValue(deletedShare); |
| 0 | 615 | | request.Content = content; |
| 0 | 616 | | return message; |
| | 617 | | } |
| | 618 | |
|
| | 619 | | /// <summary> Restore a file share within a valid retention days if share soft delete is enabled. </summary> |
| | 620 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 621 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 622 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 623 | | /// <param name="deletedShare"> The DeletedShare to use. </param> |
| | 624 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 625 | | public async Task<Response> RestoreAsync(string resourceGroupName, string accountName, string shareName, Deleted |
| | 626 | | { |
| 0 | 627 | | if (resourceGroupName == null) |
| | 628 | | { |
| 0 | 629 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 630 | | } |
| 0 | 631 | | if (accountName == null) |
| | 632 | | { |
| 0 | 633 | | throw new ArgumentNullException(nameof(accountName)); |
| | 634 | | } |
| 0 | 635 | | if (shareName == null) |
| | 636 | | { |
| 0 | 637 | | throw new ArgumentNullException(nameof(shareName)); |
| | 638 | | } |
| 0 | 639 | | if (deletedShare == null) |
| | 640 | | { |
| 0 | 641 | | throw new ArgumentNullException(nameof(deletedShare)); |
| | 642 | | } |
| | 643 | |
|
| 0 | 644 | | using var message = CreateRestoreRequest(resourceGroupName, accountName, shareName, deletedShare); |
| 0 | 645 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 646 | | switch (message.Response.Status) |
| | 647 | | { |
| | 648 | | case 200: |
| 0 | 649 | | return message.Response; |
| | 650 | | default: |
| 0 | 651 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 652 | | } |
| 0 | 653 | | } |
| | 654 | |
|
| | 655 | | /// <summary> Restore a file share within a valid retention days if share soft delete is enabled. </summary> |
| | 656 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 657 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 658 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 659 | | /// <param name="deletedShare"> The DeletedShare to use. </param> |
| | 660 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 661 | | public Response Restore(string resourceGroupName, string accountName, string shareName, DeletedShare deletedShar |
| | 662 | | { |
| 0 | 663 | | if (resourceGroupName == null) |
| | 664 | | { |
| 0 | 665 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 666 | | } |
| 0 | 667 | | if (accountName == null) |
| | 668 | | { |
| 0 | 669 | | throw new ArgumentNullException(nameof(accountName)); |
| | 670 | | } |
| 0 | 671 | | if (shareName == null) |
| | 672 | | { |
| 0 | 673 | | throw new ArgumentNullException(nameof(shareName)); |
| | 674 | | } |
| 0 | 675 | | if (deletedShare == null) |
| | 676 | | { |
| 0 | 677 | | throw new ArgumentNullException(nameof(deletedShare)); |
| | 678 | | } |
| | 679 | |
|
| 0 | 680 | | using var message = CreateRestoreRequest(resourceGroupName, accountName, shareName, deletedShare); |
| 0 | 681 | | _pipeline.Send(message, cancellationToken); |
| 0 | 682 | | switch (message.Response.Status) |
| | 683 | | { |
| | 684 | | case 200: |
| 0 | 685 | | return message.Response; |
| | 686 | | default: |
| 0 | 687 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 688 | | } |
| 0 | 689 | | } |
| | 690 | |
|
| | 691 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string accountName, st |
| | 692 | | { |
| 0 | 693 | | var message = _pipeline.CreateMessage(); |
| 0 | 694 | | var request = message.Request; |
| 0 | 695 | | request.Method = RequestMethod.Get; |
| 0 | 696 | | var uri = new RawRequestUriBuilder(); |
| 0 | 697 | | uri.Reset(endpoint); |
| 0 | 698 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 699 | | request.Uri = uri; |
| 0 | 700 | | return message; |
| | 701 | | } |
| | 702 | |
|
| | 703 | | /// <summary> Lists all shares. </summary> |
| | 704 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 705 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 706 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 707 | | /// <param name="maxpagesize"> Optional. Specified maximum number of shares that can be included in the list. </ |
| | 708 | | /// <param name="filter"> Optional. When specified, only share names starting with the filter will be listed. </ |
| | 709 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 710 | | public async Task<Response<FileShareItems>> ListNextPageAsync(string nextLink, string resourceGroupName, string |
| | 711 | | { |
| 0 | 712 | | if (nextLink == null) |
| | 713 | | { |
| 0 | 714 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 715 | | } |
| 0 | 716 | | if (resourceGroupName == null) |
| | 717 | | { |
| 0 | 718 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 719 | | } |
| 0 | 720 | | if (accountName == null) |
| | 721 | | { |
| 0 | 722 | | throw new ArgumentNullException(nameof(accountName)); |
| | 723 | | } |
| | 724 | |
|
| 0 | 725 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, accountName, maxpagesize, filter) |
| 0 | 726 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 727 | | switch (message.Response.Status) |
| | 728 | | { |
| | 729 | | case 200: |
| | 730 | | { |
| 0 | 731 | | FileShareItems value = default; |
| 0 | 732 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 733 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 734 | | { |
| 0 | 735 | | value = null; |
| | 736 | | } |
| | 737 | | else |
| | 738 | | { |
| 0 | 739 | | value = FileShareItems.DeserializeFileShareItems(document.RootElement); |
| | 740 | | } |
| 0 | 741 | | return Response.FromValue(value, message.Response); |
| | 742 | | } |
| | 743 | | default: |
| 0 | 744 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 745 | | } |
| 0 | 746 | | } |
| | 747 | |
|
| | 748 | | /// <summary> Lists all shares. </summary> |
| | 749 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 750 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 751 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 752 | | /// <param name="maxpagesize"> Optional. Specified maximum number of shares that can be included in the list. </ |
| | 753 | | /// <param name="filter"> Optional. When specified, only share names starting with the filter will be listed. </ |
| | 754 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 755 | | public Response<FileShareItems> ListNextPage(string nextLink, string resourceGroupName, string accountName, stri |
| | 756 | | { |
| 0 | 757 | | if (nextLink == null) |
| | 758 | | { |
| 0 | 759 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 760 | | } |
| 0 | 761 | | if (resourceGroupName == null) |
| | 762 | | { |
| 0 | 763 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 764 | | } |
| 0 | 765 | | if (accountName == null) |
| | 766 | | { |
| 0 | 767 | | throw new ArgumentNullException(nameof(accountName)); |
| | 768 | | } |
| | 769 | |
|
| 0 | 770 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, accountName, maxpagesize, filter) |
| 0 | 771 | | _pipeline.Send(message, cancellationToken); |
| 0 | 772 | | switch (message.Response.Status) |
| | 773 | | { |
| | 774 | | case 200: |
| | 775 | | { |
| 0 | 776 | | FileShareItems value = default; |
| 0 | 777 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 778 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 779 | | { |
| 0 | 780 | | value = null; |
| | 781 | | } |
| | 782 | | else |
| | 783 | | { |
| 0 | 784 | | value = FileShareItems.DeserializeFileShareItems(document.RootElement); |
| | 785 | | } |
| 0 | 786 | | return Response.FromValue(value, message.Response); |
| | 787 | | } |
| | 788 | | default: |
| 0 | 789 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 790 | | } |
| 0 | 791 | | } |
| | 792 | | } |
| | 793 | | } |