< Summary

Class:Azure.ResourceManager.Storage.FileServicesRestOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\FileServicesRestOperations.cs
Covered lines:92
Uncovered lines:65
Coverable lines:157
Total lines:354
Line coverage:58.5% (92 of 157)
Covered branches:21
Total branches:58
Branch coverage:36.2% (21 of 58)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateSetServicePropertiesRequest(...)-100%100%
SetServicePropertiesAsync()-70.59%50%
SetServiceProperties(...)-70.59%50%
CreateGetServicePropertiesRequest(...)-100%100%
GetServicePropertiesAsync()-73.33%50%
GetServiceProperties(...)-73.33%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\FileServicesRestOperations.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.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.Storage.Models;
 16
 17namespace Azure.ResourceManager.Storage
 18{
 19    internal partial class FileServicesRestOperations
 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 FileServicesRestOperations. </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
 24034        public FileServicesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 35        {
 24036            if (subscriptionId == null)
 37            {
 038                throw new ArgumentNullException(nameof(subscriptionId));
 39            }
 24040            endpoint ??= new Uri("https://management.azure.com");
 24041            if (apiVersion == null)
 42            {
 043                throw new ArgumentNullException(nameof(apiVersion));
 44            }
 45
 24046            this.subscriptionId = subscriptionId;
 24047            this.endpoint = endpoint;
 24048            this.apiVersion = apiVersion;
 24049            _clientDiagnostics = clientDiagnostics;
 24050            _pipeline = pipeline;
 24051        }
 52
 53        internal HttpMessage CreateListRequest(string resourceGroupName, string accountName)
 54        {
 055            var message = _pipeline.CreateMessage();
 056            var request = message.Request;
 057            request.Method = RequestMethod.Get;
 058            var uri = new RawRequestUriBuilder();
 059            uri.Reset(endpoint);
 060            uri.AppendPath("/subscriptions/", false);
 061            uri.AppendPath(subscriptionId, true);
 062            uri.AppendPath("/resourceGroups/", false);
 063            uri.AppendPath(resourceGroupName, true);
 064            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 065            uri.AppendPath(accountName, true);
 066            uri.AppendPath("/fileServices", false);
 067            uri.AppendQuery("api-version", apiVersion, true);
 068            request.Uri = uri;
 069            return message;
 70        }
 71
 72        /// <summary> List all file services in storage accounts. </summary>
 73        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 74        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        public async Task<Response<FileServiceItems>> ListAsync(string resourceGroupName, string accountName, Cancellati
 77        {
 078            if (resourceGroupName == null)
 79            {
 080                throw new ArgumentNullException(nameof(resourceGroupName));
 81            }
 082            if (accountName == null)
 83            {
 084                throw new ArgumentNullException(nameof(accountName));
 85            }
 86
 087            using var message = CreateListRequest(resourceGroupName, accountName);
 088            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 089            switch (message.Response.Status)
 90            {
 91                case 200:
 92                    {
 093                        FileServiceItems value = default;
 094                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 095                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 96                        {
 097                            value = null;
 98                        }
 99                        else
 100                        {
 0101                            value = FileServiceItems.DeserializeFileServiceItems(document.RootElement);
 102                        }
 0103                        return Response.FromValue(value, message.Response);
 104                    }
 105                default:
 0106                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 107            }
 0108        }
 109
 110        /// <summary> List all file services in storage accounts. </summary>
 111        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 112        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 113        /// <param name="cancellationToken"> The cancellation token to use. </param>
 114        public Response<FileServiceItems> List(string resourceGroupName, string accountName, CancellationToken cancellat
 115        {
 0116            if (resourceGroupName == null)
 117            {
 0118                throw new ArgumentNullException(nameof(resourceGroupName));
 119            }
 0120            if (accountName == null)
 121            {
 0122                throw new ArgumentNullException(nameof(accountName));
 123            }
 124
 0125            using var message = CreateListRequest(resourceGroupName, accountName);
 0126            _pipeline.Send(message, cancellationToken);
 0127            switch (message.Response.Status)
 128            {
 129                case 200:
 130                    {
 0131                        FileServiceItems value = default;
 0132                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0133                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 134                        {
 0135                            value = null;
 136                        }
 137                        else
 138                        {
 0139                            value = FileServiceItems.DeserializeFileServiceItems(document.RootElement);
 140                        }
 0141                        return Response.FromValue(value, message.Response);
 142                    }
 143                default:
 0144                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 145            }
 0146        }
 147
 148        internal HttpMessage CreateSetServicePropertiesRequest(string resourceGroupName, string accountName, FileService
 149        {
 4150            var message = _pipeline.CreateMessage();
 4151            var request = message.Request;
 4152            request.Method = RequestMethod.Put;
 4153            var uri = new RawRequestUriBuilder();
 4154            uri.Reset(endpoint);
 4155            uri.AppendPath("/subscriptions/", false);
 4156            uri.AppendPath(subscriptionId, true);
 4157            uri.AppendPath("/resourceGroups/", false);
 4158            uri.AppendPath(resourceGroupName, true);
 4159            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 4160            uri.AppendPath(accountName, true);
 4161            uri.AppendPath("/fileServices/", false);
 4162            uri.AppendPath("default", true);
 4163            uri.AppendQuery("api-version", apiVersion, true);
 4164            request.Uri = uri;
 4165            request.Headers.Add("Content-Type", "application/json");
 4166            var content = new Utf8JsonRequestContent();
 4167            content.JsonWriter.WriteObjectValue(parameters);
 4168            request.Content = content;
 4169            return message;
 170        }
 171
 172        /// <summary> Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sh
 173        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 174        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 175        /// <param name="parameters"> The properties of file services in storage accounts, including CORS (Cross-Origin 
 176        /// <param name="cancellationToken"> The cancellation token to use. </param>
 177        public async Task<Response<FileServiceProperties>> SetServicePropertiesAsync(string resourceGroupName, string ac
 178        {
 2179            if (resourceGroupName == null)
 180            {
 0181                throw new ArgumentNullException(nameof(resourceGroupName));
 182            }
 2183            if (accountName == null)
 184            {
 0185                throw new ArgumentNullException(nameof(accountName));
 186            }
 2187            if (parameters == null)
 188            {
 0189                throw new ArgumentNullException(nameof(parameters));
 190            }
 191
 2192            using var message = CreateSetServicePropertiesRequest(resourceGroupName, accountName, parameters);
 2193            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2194            switch (message.Response.Status)
 195            {
 196                case 200:
 197                    {
 2198                        FileServiceProperties value = default;
 2199                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2200                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 201                        {
 0202                            value = null;
 203                        }
 204                        else
 205                        {
 2206                            value = FileServiceProperties.DeserializeFileServiceProperties(document.RootElement);
 207                        }
 2208                        return Response.FromValue(value, message.Response);
 209                    }
 210                default:
 0211                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 212            }
 2213        }
 214
 215        /// <summary> Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sh
 216        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 217        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 218        /// <param name="parameters"> The properties of file services in storage accounts, including CORS (Cross-Origin 
 219        /// <param name="cancellationToken"> The cancellation token to use. </param>
 220        public Response<FileServiceProperties> SetServiceProperties(string resourceGroupName, string accountName, FileSe
 221        {
 2222            if (resourceGroupName == null)
 223            {
 0224                throw new ArgumentNullException(nameof(resourceGroupName));
 225            }
 2226            if (accountName == null)
 227            {
 0228                throw new ArgumentNullException(nameof(accountName));
 229            }
 2230            if (parameters == null)
 231            {
 0232                throw new ArgumentNullException(nameof(parameters));
 233            }
 234
 2235            using var message = CreateSetServicePropertiesRequest(resourceGroupName, accountName, parameters);
 2236            _pipeline.Send(message, cancellationToken);
 2237            switch (message.Response.Status)
 238            {
 239                case 200:
 240                    {
 2241                        FileServiceProperties value = default;
 2242                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2243                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 244                        {
 0245                            value = null;
 246                        }
 247                        else
 248                        {
 2249                            value = FileServiceProperties.DeserializeFileServiceProperties(document.RootElement);
 250                        }
 2251                        return Response.FromValue(value, message.Response);
 252                    }
 253                default:
 0254                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 255            }
 2256        }
 257
 258        internal HttpMessage CreateGetServicePropertiesRequest(string resourceGroupName, string accountName)
 259        {
 8260            var message = _pipeline.CreateMessage();
 8261            var request = message.Request;
 8262            request.Method = RequestMethod.Get;
 8263            var uri = new RawRequestUriBuilder();
 8264            uri.Reset(endpoint);
 8265            uri.AppendPath("/subscriptions/", false);
 8266            uri.AppendPath(subscriptionId, true);
 8267            uri.AppendPath("/resourceGroups/", false);
 8268            uri.AppendPath(resourceGroupName, true);
 8269            uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false);
 8270            uri.AppendPath(accountName, true);
 8271            uri.AppendPath("/fileServices/", false);
 8272            uri.AppendPath("default", true);
 8273            uri.AppendQuery("api-version", apiVersion, true);
 8274            request.Uri = uri;
 8275            return message;
 276        }
 277
 278        /// <summary> Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sh
 279        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 280        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 281        /// <param name="cancellationToken"> The cancellation token to use. </param>
 282        public async Task<Response<FileServiceProperties>> GetServicePropertiesAsync(string resourceGroupName, string ac
 283        {
 4284            if (resourceGroupName == null)
 285            {
 0286                throw new ArgumentNullException(nameof(resourceGroupName));
 287            }
 4288            if (accountName == null)
 289            {
 0290                throw new ArgumentNullException(nameof(accountName));
 291            }
 292
 4293            using var message = CreateGetServicePropertiesRequest(resourceGroupName, accountName);
 4294            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 4295            switch (message.Response.Status)
 296            {
 297                case 200:
 298                    {
 4299                        FileServiceProperties value = default;
 4300                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 4301                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 302                        {
 0303                            value = null;
 304                        }
 305                        else
 306                        {
 4307                            value = FileServiceProperties.DeserializeFileServiceProperties(document.RootElement);
 308                        }
 4309                        return Response.FromValue(value, message.Response);
 310                    }
 311                default:
 0312                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 313            }
 4314        }
 315
 316        /// <summary> Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sh
 317        /// <param name="resourceGroupName"> The name of the resource group within the user&apos;s subscription. The nam
 318        /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco
 319        /// <param name="cancellationToken"> The cancellation token to use. </param>
 320        public Response<FileServiceProperties> GetServiceProperties(string resourceGroupName, string accountName, Cancel
 321        {
 4322            if (resourceGroupName == null)
 323            {
 0324                throw new ArgumentNullException(nameof(resourceGroupName));
 325            }
 4326            if (accountName == null)
 327            {
 0328                throw new ArgumentNullException(nameof(accountName));
 329            }
 330
 4331            using var message = CreateGetServicePropertiesRequest(resourceGroupName, accountName);
 4332            _pipeline.Send(message, cancellationToken);
 4333            switch (message.Response.Status)
 334            {
 335                case 200:
 336                    {
 4337                        FileServiceProperties value = default;
 4338                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 4339                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 340                        {
 0341                            value = null;
 342                        }
 343                        else
 344                        {
 4345                            value = FileServiceProperties.DeserializeFileServiceProperties(document.RootElement);
 346                        }
 4347                        return Response.FromValue(value, message.Response);
 348                    }
 349                default:
 0350                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 351            }
 4352        }
 353    }
 354}