< Summary

Class:Azure.ResourceManager.Storage.FileSharesOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\FileSharesOperations.cs
Covered lines:56
Uncovered lines:64
Coverable lines:120
Total lines:347
Line coverage:46.6% (56 of 120)
Covered branches:4
Total branches:8
Branch coverage:50% (4 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
CreateAsync()-57.14%100%
Create(...)-57.14%100%
UpdateAsync()-57.14%100%
Update(...)-57.14%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
DeleteAsync()-57.14%100%
Delete(...)-57.14%100%
RestoreAsync()-0%100%
Restore(...)-0%100%
ListAsync(...)-38.1%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-38.1%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\FileSharesOperations.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.ResourceManager.Storage.Models;
 15
 16namespace 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;
 4823        internal FileSharesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of FileSharesOperations for mocking. </summary>
 24025        protected FileSharesOperations()
 26        {
 24027        }
 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>
 24034        internal FileSharesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId,
 35        {
 24036            RestClient = new FileSharesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint, apiVersion)
 24037            _clientDiagnostics = clientDiagnostics;
 24038            _pipeline = pipeline;
 24039        }
 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&apos;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        {
 649            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Create");
 650            scope.Start();
 51            try
 52            {
 653                return await RestClient.CreateAsync(resourceGroupName, accountName, shareName, fileShare, cancellationTo
 54            }
 055            catch (Exception e)
 56            {
 057                scope.Failed(e);
 058                throw;
 59            }
 660        }
 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&apos;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        {
 670            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Create");
 671            scope.Start();
 72            try
 73            {
 674                return RestClient.Create(resourceGroupName, accountName, shareName, fileShare, cancellationToken);
 75            }
 076            catch (Exception e)
 77            {
 078                scope.Failed(e);
 079                throw;
 80            }
 681        }
 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&apos;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        {
 291            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Update");
 292            scope.Start();
 93            try
 94            {
 295                return await RestClient.UpdateAsync(resourceGroupName, accountName, shareName, fileShare, cancellationTo
 96            }
 097            catch (Exception e)
 98            {
 099                scope.Failed(e);
 0100                throw;
 101            }
 2102        }
 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&apos;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        {
 2112            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Update");
 2113            scope.Start();
 114            try
 115            {
 2116                return RestClient.Update(resourceGroupName, accountName, shareName, fileShare, cancellationToken);
 117            }
 0118            catch (Exception e)
 119            {
 0120                scope.Failed(e);
 0121                throw;
 122            }
 2123        }
 124
 125        /// <summary> Gets properties of a specified share. </summary>
 126        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;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        {
 6132            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Get");
 6133            scope.Start();
 134            try
 135            {
 6136                return await RestClient.GetAsync(resourceGroupName, accountName, shareName, cancellationToken).Configure
 137            }
 0138            catch (Exception e)
 139            {
 0140                scope.Failed(e);
 0141                throw;
 142            }
 6143        }
 144
 145        /// <summary> Gets properties of a specified share. </summary>
 146        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;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        {
 6152            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Get");
 6153            scope.Start();
 154            try
 155            {
 6156                return RestClient.Get(resourceGroupName, accountName, shareName, cancellationToken);
 157            }
 0158            catch (Exception e)
 159            {
 0160                scope.Failed(e);
 0161                throw;
 162            }
 6163        }
 164
 165        /// <summary> Deletes specified share under its account. </summary>
 166        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;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        {
 6172            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Delete");
 6173            scope.Start();
 174            try
 175            {
 6176                return await RestClient.DeleteAsync(resourceGroupName, accountName, shareName, cancellationToken).Config
 177            }
 0178            catch (Exception e)
 179            {
 0180                scope.Failed(e);
 0181                throw;
 182            }
 6183        }
 184
 185        /// <summary> Deletes specified share under its account. </summary>
 186        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;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        {
 6192            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Delete");
 6193            scope.Start();
 194            try
 195            {
 6196                return RestClient.Delete(resourceGroupName, accountName, shareName, cancellationToken);
 197            }
 0198            catch (Exception e)
 199            {
 0200                scope.Failed(e);
 0201                throw;
 202            }
 6203        }
 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&apos;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        {
 0213            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Restore");
 0214            scope.Start();
 215            try
 216            {
 0217                return await RestClient.RestoreAsync(resourceGroupName, accountName, shareName, deletedShare, cancellati
 218            }
 0219            catch (Exception e)
 220            {
 0221                scope.Failed(e);
 0222                throw;
 223            }
 0224        }
 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&apos;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        {
 0234            using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Restore");
 0235            scope.Start();
 236            try
 237            {
 0238                return RestClient.Restore(resourceGroupName, accountName, shareName, deletedShare, cancellationToken);
 239            }
 0240            catch (Exception e)
 241            {
 0242                scope.Failed(e);
 0243                throw;
 244            }
 0245        }
 246
 247        /// <summary> Lists all shares. </summary>
 248        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;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        {
 4255            if (resourceGroupName == null)
 256            {
 0257                throw new ArgumentNullException(nameof(resourceGroupName));
 258            }
 4259            if (accountName == null)
 260            {
 0261                throw new ArgumentNullException(nameof(accountName));
 262            }
 263
 264            async Task<Page<FileShareItem>> FirstPageFunc(int? pageSizeHint)
 265            {
 4266                using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List");
 4267                scope.Start();
 268                try
 269                {
 4270                    var response = await RestClient.ListAsync(resourceGroupName, accountName, maxpagesize, filter, cance
 4271                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 272                }
 0273                catch (Exception e)
 274                {
 0275                    scope.Failed(e);
 0276                    throw;
 277                }
 4278            }
 279            async Task<Page<FileShareItem>> NextPageFunc(string nextLink, int? pageSizeHint)
 280            {
 0281                using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List");
 0282                scope.Start();
 283                try
 284                {
 0285                    var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, accountName, maxpages
 0286                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 287                }
 0288                catch (Exception e)
 289                {
 0290                    scope.Failed(e);
 0291                    throw;
 292                }
 0293            }
 4294            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&apos;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        {
 4305            if (resourceGroupName == null)
 306            {
 0307                throw new ArgumentNullException(nameof(resourceGroupName));
 308            }
 4309            if (accountName == null)
 310            {
 0311                throw new ArgumentNullException(nameof(accountName));
 312            }
 313
 314            Page<FileShareItem> FirstPageFunc(int? pageSizeHint)
 315            {
 4316                using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List");
 4317                scope.Start();
 318                try
 319                {
 4320                    var response = RestClient.List(resourceGroupName, accountName, maxpagesize, filter, cancellationToke
 4321                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 322                }
 0323                catch (Exception e)
 324                {
 0325                    scope.Failed(e);
 0326                    throw;
 327                }
 4328            }
 329            Page<FileShareItem> NextPageFunc(string nextLink, int? pageSizeHint)
 330            {
 0331                using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.List");
 0332                scope.Start();
 333                try
 334                {
 0335                    var response = RestClient.ListNextPage(nextLink, resourceGroupName, accountName, maxpagesize, filter
 0336                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 337                }
 0338                catch (Exception e)
 339                {
 0340                    scope.Failed(e);
 0341                    throw;
 342                }
 0343            }
 4344            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 345        }
 346    }
 347}