| | 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.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Storage.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Storage |
| | 17 | | { |
| | 18 | | /// <summary> The FileShares service client. </summary> |
| | 19 | | public partial class FileSharesOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 48 | 23 | | internal FileSharesRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of FileSharesOperations for mocking. </summary> |
| 240 | 25 | | protected FileSharesOperations() |
| | 26 | | { |
| 240 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of FileSharesOperations. </summary> |
| | 29 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 30 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 31 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| | 33 | | /// <param name="apiVersion"> Api Version. </param> |
| 240 | 34 | | internal FileSharesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, |
| | 35 | | { |
| 240 | 36 | | RestClient = new FileSharesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint, apiVersion) |
| 240 | 37 | | _clientDiagnostics = clientDiagnostics; |
| 240 | 38 | | _pipeline = pipeline; |
| 240 | 39 | | } |
| | 40 | |
|
| | 41 | | /// <summary> Creates a new share under the specified account as described by request body. The share resource i |
| | 42 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 43 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 44 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 45 | | /// <param name="fileShare"> Properties of the file share to create. </param> |
| | 46 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 47 | | public virtual async Task<Response<FileShare>> CreateAsync(string resourceGroupName, string accountName, string |
| | 48 | | { |
| 6 | 49 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Create"); |
| 6 | 50 | | scope.Start(); |
| | 51 | | try |
| | 52 | | { |
| 6 | 53 | | return await RestClient.CreateAsync(resourceGroupName, accountName, shareName, fileShare, cancellationTo |
| | 54 | | } |
| 0 | 55 | | catch (Exception e) |
| | 56 | | { |
| 0 | 57 | | scope.Failed(e); |
| 0 | 58 | | throw; |
| | 59 | | } |
| 6 | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> Creates a new share under the specified account as described by request body. The share resource i |
| | 63 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 64 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 65 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 66 | | /// <param name="fileShare"> Properties of the file share to create. </param> |
| | 67 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 68 | | public virtual Response<FileShare> Create(string resourceGroupName, string accountName, string shareName, FileSh |
| | 69 | | { |
| 6 | 70 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Create"); |
| 6 | 71 | | scope.Start(); |
| | 72 | | try |
| | 73 | | { |
| 6 | 74 | | return RestClient.Create(resourceGroupName, accountName, shareName, fileShare, cancellationToken); |
| | 75 | | } |
| 0 | 76 | | catch (Exception e) |
| | 77 | | { |
| 0 | 78 | | scope.Failed(e); |
| 0 | 79 | | throw; |
| | 80 | | } |
| 6 | 81 | | } |
| | 82 | |
|
| | 83 | | /// <summary> Updates share properties as specified in request body. Properties not mentioned in the request wil |
| | 84 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 85 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 86 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 87 | | /// <param name="fileShare"> Properties to update for the file share. </param> |
| | 88 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 89 | | public virtual async Task<Response<FileShare>> UpdateAsync(string resourceGroupName, string accountName, string |
| | 90 | | { |
| 2 | 91 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Update"); |
| 2 | 92 | | scope.Start(); |
| | 93 | | try |
| | 94 | | { |
| 2 | 95 | | return await RestClient.UpdateAsync(resourceGroupName, accountName, shareName, fileShare, cancellationTo |
| | 96 | | } |
| 0 | 97 | | catch (Exception e) |
| | 98 | | { |
| 0 | 99 | | scope.Failed(e); |
| 0 | 100 | | throw; |
| | 101 | | } |
| 2 | 102 | | } |
| | 103 | |
|
| | 104 | | /// <summary> Updates share properties as specified in request body. Properties not mentioned in the request wil |
| | 105 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 106 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 107 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 108 | | /// <param name="fileShare"> Properties to update for the file share. </param> |
| | 109 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 110 | | public virtual Response<FileShare> Update(string resourceGroupName, string accountName, string shareName, FileSh |
| | 111 | | { |
| 2 | 112 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Update"); |
| 2 | 113 | | scope.Start(); |
| | 114 | | try |
| | 115 | | { |
| 2 | 116 | | return RestClient.Update(resourceGroupName, accountName, shareName, fileShare, cancellationToken); |
| | 117 | | } |
| 0 | 118 | | catch (Exception e) |
| | 119 | | { |
| 0 | 120 | | scope.Failed(e); |
| 0 | 121 | | throw; |
| | 122 | | } |
| 2 | 123 | | } |
| | 124 | |
|
| | 125 | | /// <summary> Gets properties of a specified share. </summary> |
| | 126 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 127 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 128 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 129 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 130 | | public virtual async Task<Response<FileShare>> GetAsync(string resourceGroupName, string accountName, string sha |
| | 131 | | { |
| 6 | 132 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Get"); |
| 6 | 133 | | scope.Start(); |
| | 134 | | try |
| | 135 | | { |
| 6 | 136 | | return await RestClient.GetAsync(resourceGroupName, accountName, shareName, cancellationToken).Configure |
| | 137 | | } |
| 0 | 138 | | catch (Exception e) |
| | 139 | | { |
| 0 | 140 | | scope.Failed(e); |
| 0 | 141 | | throw; |
| | 142 | | } |
| 6 | 143 | | } |
| | 144 | |
|
| | 145 | | /// <summary> Gets properties of a specified share. </summary> |
| | 146 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 147 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 148 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 149 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 150 | | public virtual Response<FileShare> Get(string resourceGroupName, string accountName, string shareName, Cancellat |
| | 151 | | { |
| 6 | 152 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Get"); |
| 6 | 153 | | scope.Start(); |
| | 154 | | try |
| | 155 | | { |
| 6 | 156 | | return RestClient.Get(resourceGroupName, accountName, shareName, cancellationToken); |
| | 157 | | } |
| 0 | 158 | | catch (Exception e) |
| | 159 | | { |
| 0 | 160 | | scope.Failed(e); |
| 0 | 161 | | throw; |
| | 162 | | } |
| 6 | 163 | | } |
| | 164 | |
|
| | 165 | | /// <summary> Deletes specified share under its account. </summary> |
| | 166 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 167 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 168 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 169 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 170 | | public virtual async Task<Response> DeleteAsync(string resourceGroupName, string accountName, string shareName, |
| | 171 | | { |
| 6 | 172 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Delete"); |
| 6 | 173 | | scope.Start(); |
| | 174 | | try |
| | 175 | | { |
| 6 | 176 | | return await RestClient.DeleteAsync(resourceGroupName, accountName, shareName, cancellationToken).Config |
| | 177 | | } |
| 0 | 178 | | catch (Exception e) |
| | 179 | | { |
| 0 | 180 | | scope.Failed(e); |
| 0 | 181 | | throw; |
| | 182 | | } |
| 6 | 183 | | } |
| | 184 | |
|
| | 185 | | /// <summary> Deletes specified share under its account. </summary> |
| | 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="cancellationToken"> The cancellation token to use. </param> |
| | 190 | | public virtual Response Delete(string resourceGroupName, string accountName, string shareName, CancellationToken |
| | 191 | | { |
| 6 | 192 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Delete"); |
| 6 | 193 | | scope.Start(); |
| | 194 | | try |
| | 195 | | { |
| 6 | 196 | | return RestClient.Delete(resourceGroupName, accountName, shareName, cancellationToken); |
| | 197 | | } |
| 0 | 198 | | catch (Exception e) |
| | 199 | | { |
| 0 | 200 | | scope.Failed(e); |
| 0 | 201 | | throw; |
| | 202 | | } |
| 6 | 203 | | } |
| | 204 | |
|
| | 205 | | /// <summary> Restore a file share within a valid retention days if share soft delete is enabled. </summary> |
| | 206 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 207 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 208 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 209 | | /// <param name="deletedShare"> The DeletedShare to use. </param> |
| | 210 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 211 | | public virtual async Task<Response> RestoreAsync(string resourceGroupName, string accountName, string shareName, |
| | 212 | | { |
| 0 | 213 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Restore"); |
| 0 | 214 | | scope.Start(); |
| | 215 | | try |
| | 216 | | { |
| 0 | 217 | | return await RestClient.RestoreAsync(resourceGroupName, accountName, shareName, deletedShare, cancellati |
| | 218 | | } |
| 0 | 219 | | catch (Exception e) |
| | 220 | | { |
| 0 | 221 | | scope.Failed(e); |
| 0 | 222 | | throw; |
| | 223 | | } |
| 0 | 224 | | } |
| | 225 | |
|
| | 226 | | /// <summary> Restore a file share within a valid retention days if share soft delete is enabled. </summary> |
| | 227 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 228 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 229 | | /// <param name="shareName"> The name of the file share within the specified storage account. File share names m |
| | 230 | | /// <param name="deletedShare"> The DeletedShare to use. </param> |
| | 231 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 232 | | public virtual Response Restore(string resourceGroupName, string accountName, string shareName, DeletedShare del |
| | 233 | | { |
| 0 | 234 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Restore"); |
| 0 | 235 | | scope.Start(); |
| | 236 | | try |
| | 237 | | { |
| 0 | 238 | | return RestClient.Restore(resourceGroupName, accountName, shareName, deletedShare, cancellationToken); |
| | 239 | | } |
| 0 | 240 | | catch (Exception e) |
| | 241 | | { |
| 0 | 242 | | scope.Failed(e); |
| 0 | 243 | | throw; |
| | 244 | | } |
| 0 | 245 | | } |
| | 246 | |
|
| | 247 | | /// <summary> Lists all shares. </summary> |
| | 248 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 249 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 250 | | /// <param name="maxpagesize"> Optional. Specified maximum number of shares that can be included in the list. </ |
| | 251 | | /// <param name="filter"> Optional. When specified, only share names starting with the filter will be listed. </ |
| | 252 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 253 | | public virtual AsyncPageable<FileShareItem> ListAsync(string resourceGroupName, string accountName, string maxpa |
| | 254 | | { |
| 4 | 255 | | if (resourceGroupName == null) |
| | 256 | | { |
| 0 | 257 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 258 | | } |
| 4 | 259 | | if (accountName == null) |
| | 260 | | { |
| 0 | 261 | | throw new ArgumentNullException(nameof(accountName)); |
| | 262 | | } |
| | 263 | |
|
| | 264 | | async Task<Page<FileShareItem>> FirstPageFunc(int? pageSizeHint) |
| | 265 | | { |
| 4 | 266 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List"); |
| 4 | 267 | | scope.Start(); |
| | 268 | | try |
| | 269 | | { |
| 4 | 270 | | var response = await RestClient.ListAsync(resourceGroupName, accountName, maxpagesize, filter, cance |
| 4 | 271 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 272 | | } |
| 0 | 273 | | catch (Exception e) |
| | 274 | | { |
| 0 | 275 | | scope.Failed(e); |
| 0 | 276 | | throw; |
| | 277 | | } |
| 4 | 278 | | } |
| | 279 | | async Task<Page<FileShareItem>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 280 | | { |
| 0 | 281 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List"); |
| 0 | 282 | | scope.Start(); |
| | 283 | | try |
| | 284 | | { |
| 0 | 285 | | var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, accountName, maxpages |
| 0 | 286 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 287 | | } |
| 0 | 288 | | catch (Exception e) |
| | 289 | | { |
| 0 | 290 | | scope.Failed(e); |
| 0 | 291 | | throw; |
| | 292 | | } |
| 0 | 293 | | } |
| 4 | 294 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 295 | | } |
| | 296 | |
|
| | 297 | | /// <summary> Lists all shares. </summary> |
| | 298 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 299 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 300 | | /// <param name="maxpagesize"> Optional. Specified maximum number of shares that can be included in the list. </ |
| | 301 | | /// <param name="filter"> Optional. When specified, only share names starting with the filter will be listed. </ |
| | 302 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 303 | | public virtual Pageable<FileShareItem> List(string resourceGroupName, string accountName, string maxpagesize = n |
| | 304 | | { |
| 4 | 305 | | if (resourceGroupName == null) |
| | 306 | | { |
| 0 | 307 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 308 | | } |
| 4 | 309 | | if (accountName == null) |
| | 310 | | { |
| 0 | 311 | | throw new ArgumentNullException(nameof(accountName)); |
| | 312 | | } |
| | 313 | |
|
| | 314 | | Page<FileShareItem> FirstPageFunc(int? pageSizeHint) |
| | 315 | | { |
| 4 | 316 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List"); |
| 4 | 317 | | scope.Start(); |
| | 318 | | try |
| | 319 | | { |
| 4 | 320 | | var response = RestClient.List(resourceGroupName, accountName, maxpagesize, filter, cancellationToke |
| 4 | 321 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 322 | | } |
| 0 | 323 | | catch (Exception e) |
| | 324 | | { |
| 0 | 325 | | scope.Failed(e); |
| 0 | 326 | | throw; |
| | 327 | | } |
| 4 | 328 | | } |
| | 329 | | Page<FileShareItem> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 330 | | { |
| 0 | 331 | | using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List"); |
| 0 | 332 | | scope.Start(); |
| | 333 | | try |
| | 334 | | { |
| 0 | 335 | | var response = RestClient.ListNextPage(nextLink, resourceGroupName, accountName, maxpagesize, filter |
| 0 | 336 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 337 | | } |
| 0 | 338 | | catch (Exception e) |
| | 339 | | { |
| 0 | 340 | | scope.Failed(e); |
| 0 | 341 | | throw; |
| | 342 | | } |
| 0 | 343 | | } |
| 4 | 344 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 345 | | } |
| | 346 | | } |
| | 347 | | } |