< Summary

Class:Azure.ResourceManager.Compute.VirtualMachineRunCommandsRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineRunCommandsRestOperations.cs
Covered lines:77
Uncovered lines:53
Coverable lines:130
Total lines:311
Line coverage:59.2% (77 of 130)
Covered branches:16
Total branches:48
Branch coverage:33.3% (16 of 48)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateListRequest(...)-100%100%
ListAsync()-76.92%50%
List(...)-76.92%50%
CreateGetRequest(...)-100%100%
GetAsync()-73.33%50%
Get(...)-73.33%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineRunCommandsRestOperations.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.Compute.Models;
 16
 17namespace Azure.ResourceManager.Compute
 18{
 19    internal partial class VirtualMachineRunCommandsRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private ClientDiagnostics _clientDiagnostics;
 24        private HttpPipeline _pipeline;
 25
 26        /// <summary> Initializes a new instance of VirtualMachineRunCommandsRestOperations. </summary>
 27        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 28        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 29        /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 30        /// <param name="endpoint"> server parameter. </param>
 31        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 39632        public VirtualMachineRunCommandsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, strin
 33        {
 39634            if (subscriptionId == null)
 35            {
 036                throw new ArgumentNullException(nameof(subscriptionId));
 37            }
 39638            endpoint ??= new Uri("https://management.azure.com");
 39
 39640            this.subscriptionId = subscriptionId;
 39641            this.endpoint = endpoint;
 39642            _clientDiagnostics = clientDiagnostics;
 39643            _pipeline = pipeline;
 39644        }
 45
 46        internal HttpMessage CreateListRequest(string location)
 47        {
 448            var message = _pipeline.CreateMessage();
 449            var request = message.Request;
 450            request.Method = RequestMethod.Get;
 451            var uri = new RawRequestUriBuilder();
 452            uri.Reset(endpoint);
 453            uri.AppendPath("/subscriptions/", false);
 454            uri.AppendPath(subscriptionId, true);
 455            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 456            uri.AppendPath(location, true);
 457            uri.AppendPath("/runCommands", false);
 458            uri.AppendQuery("api-version", "2019-12-01", true);
 459            request.Uri = uri;
 460            return message;
 61        }
 62
 63        /// <summary> Lists all available run commands for a subscription in a location. </summary>
 64        /// <param name="location"> The location upon which run commands is queried. </param>
 65        /// <param name="cancellationToken"> The cancellation token to use. </param>
 66        public async Task<Response<RunCommandListResult>> ListAsync(string location, CancellationToken cancellationToken
 67        {
 268            if (location == null)
 69            {
 070                throw new ArgumentNullException(nameof(location));
 71            }
 72
 273            using var message = CreateListRequest(location);
 274            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 275            switch (message.Response.Status)
 76            {
 77                case 200:
 78                    {
 279                        RunCommandListResult value = default;
 280                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 281                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 82                        {
 083                            value = null;
 84                        }
 85                        else
 86                        {
 287                            value = RunCommandListResult.DeserializeRunCommandListResult(document.RootElement);
 88                        }
 289                        return Response.FromValue(value, message.Response);
 90                    }
 91                default:
 092                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 93            }
 294        }
 95
 96        /// <summary> Lists all available run commands for a subscription in a location. </summary>
 97        /// <param name="location"> The location upon which run commands is queried. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public Response<RunCommandListResult> List(string location, CancellationToken cancellationToken = default)
 100        {
 2101            if (location == null)
 102            {
 0103                throw new ArgumentNullException(nameof(location));
 104            }
 105
 2106            using var message = CreateListRequest(location);
 2107            _pipeline.Send(message, cancellationToken);
 2108            switch (message.Response.Status)
 109            {
 110                case 200:
 111                    {
 2112                        RunCommandListResult value = default;
 2113                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2114                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 115                        {
 0116                            value = null;
 117                        }
 118                        else
 119                        {
 2120                            value = RunCommandListResult.DeserializeRunCommandListResult(document.RootElement);
 121                        }
 2122                        return Response.FromValue(value, message.Response);
 123                    }
 124                default:
 0125                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 126            }
 2127        }
 128
 129        internal HttpMessage CreateGetRequest(string location, string commandId)
 130        {
 4131            var message = _pipeline.CreateMessage();
 4132            var request = message.Request;
 4133            request.Method = RequestMethod.Get;
 4134            var uri = new RawRequestUriBuilder();
 4135            uri.Reset(endpoint);
 4136            uri.AppendPath("/subscriptions/", false);
 4137            uri.AppendPath(subscriptionId, true);
 4138            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 4139            uri.AppendPath(location, true);
 4140            uri.AppendPath("/runCommands/", false);
 4141            uri.AppendPath(commandId, true);
 4142            uri.AppendQuery("api-version", "2019-12-01", true);
 4143            request.Uri = uri;
 4144            return message;
 145        }
 146
 147        /// <summary> Gets specific run command for a subscription in a location. </summary>
 148        /// <param name="location"> The location upon which run commands is queried. </param>
 149        /// <param name="commandId"> The command id. </param>
 150        /// <param name="cancellationToken"> The cancellation token to use. </param>
 151        public async Task<Response<RunCommandDocument>> GetAsync(string location, string commandId, CancellationToken ca
 152        {
 2153            if (location == null)
 154            {
 0155                throw new ArgumentNullException(nameof(location));
 156            }
 2157            if (commandId == null)
 158            {
 0159                throw new ArgumentNullException(nameof(commandId));
 160            }
 161
 2162            using var message = CreateGetRequest(location, commandId);
 2163            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2164            switch (message.Response.Status)
 165            {
 166                case 200:
 167                    {
 2168                        RunCommandDocument value = default;
 2169                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2170                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 171                        {
 0172                            value = null;
 173                        }
 174                        else
 175                        {
 2176                            value = RunCommandDocument.DeserializeRunCommandDocument(document.RootElement);
 177                        }
 2178                        return Response.FromValue(value, message.Response);
 179                    }
 180                default:
 0181                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 182            }
 2183        }
 184
 185        /// <summary> Gets specific run command for a subscription in a location. </summary>
 186        /// <param name="location"> The location upon which run commands is queried. </param>
 187        /// <param name="commandId"> The command id. </param>
 188        /// <param name="cancellationToken"> The cancellation token to use. </param>
 189        public Response<RunCommandDocument> Get(string location, string commandId, CancellationToken cancellationToken =
 190        {
 2191            if (location == null)
 192            {
 0193                throw new ArgumentNullException(nameof(location));
 194            }
 2195            if (commandId == null)
 196            {
 0197                throw new ArgumentNullException(nameof(commandId));
 198            }
 199
 2200            using var message = CreateGetRequest(location, commandId);
 2201            _pipeline.Send(message, cancellationToken);
 2202            switch (message.Response.Status)
 203            {
 204                case 200:
 205                    {
 2206                        RunCommandDocument value = default;
 2207                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2208                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 209                        {
 0210                            value = null;
 211                        }
 212                        else
 213                        {
 2214                            value = RunCommandDocument.DeserializeRunCommandDocument(document.RootElement);
 215                        }
 2216                        return Response.FromValue(value, message.Response);
 217                    }
 218                default:
 0219                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 220            }
 2221        }
 222
 223        internal HttpMessage CreateListNextPageRequest(string nextLink, string location)
 224        {
 0225            var message = _pipeline.CreateMessage();
 0226            var request = message.Request;
 0227            request.Method = RequestMethod.Get;
 0228            var uri = new RawRequestUriBuilder();
 0229            uri.Reset(endpoint);
 0230            uri.AppendRawNextLink(nextLink, false);
 0231            request.Uri = uri;
 0232            return message;
 233        }
 234
 235        /// <summary> Lists all available run commands for a subscription in a location. </summary>
 236        /// <param name="nextLink"> The URL to the next page of results. </param>
 237        /// <param name="location"> The location upon which run commands is queried. </param>
 238        /// <param name="cancellationToken"> The cancellation token to use. </param>
 239        public async Task<Response<RunCommandListResult>> ListNextPageAsync(string nextLink, string location, Cancellati
 240        {
 0241            if (nextLink == null)
 242            {
 0243                throw new ArgumentNullException(nameof(nextLink));
 244            }
 0245            if (location == null)
 246            {
 0247                throw new ArgumentNullException(nameof(location));
 248            }
 249
 0250            using var message = CreateListNextPageRequest(nextLink, location);
 0251            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0252            switch (message.Response.Status)
 253            {
 254                case 200:
 255                    {
 0256                        RunCommandListResult value = default;
 0257                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0258                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 259                        {
 0260                            value = null;
 261                        }
 262                        else
 263                        {
 0264                            value = RunCommandListResult.DeserializeRunCommandListResult(document.RootElement);
 265                        }
 0266                        return Response.FromValue(value, message.Response);
 267                    }
 268                default:
 0269                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 270            }
 0271        }
 272
 273        /// <summary> Lists all available run commands for a subscription in a location. </summary>
 274        /// <param name="nextLink"> The URL to the next page of results. </param>
 275        /// <param name="location"> The location upon which run commands is queried. </param>
 276        /// <param name="cancellationToken"> The cancellation token to use. </param>
 277        public Response<RunCommandListResult> ListNextPage(string nextLink, string location, CancellationToken cancellat
 278        {
 0279            if (nextLink == null)
 280            {
 0281                throw new ArgumentNullException(nameof(nextLink));
 282            }
 0283            if (location == null)
 284            {
 0285                throw new ArgumentNullException(nameof(location));
 286            }
 287
 0288            using var message = CreateListNextPageRequest(nextLink, location);
 0289            _pipeline.Send(message, cancellationToken);
 0290            switch (message.Response.Status)
 291            {
 292                case 200:
 293                    {
 0294                        RunCommandListResult value = default;
 0295                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0296                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 297                        {
 0298                            value = null;
 299                        }
 300                        else
 301                        {
 0302                            value = RunCommandListResult.DeserializeRunCommandListResult(document.RootElement);
 303                        }
 0304                        return Response.FromValue(value, message.Response);
 305                    }
 306                default:
 0307                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 308            }
 0309        }
 310    }
 311}