< Summary

Class:Azure.ResourceManager.Compute.VirtualMachineRunCommandsOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineRunCommandsOperations.cs
Covered lines:30
Uncovered lines:30
Coverable lines:60
Total lines:164
Line coverage:50% (30 of 60)
Covered branches:2
Total branches:4
Branch coverage:50% (2 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
ListAsync(...)-36.84%50%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
List(...)-36.84%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineRunCommandsOperations.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.Compute.Models;
 15
 16namespace Azure.ResourceManager.Compute
 17{
 18    /// <summary> The VirtualMachineRunCommands service client. </summary>
 19    public partial class VirtualMachineRunCommandsOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 823        internal VirtualMachineRunCommandsRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of VirtualMachineRunCommandsOperations for mocking. </summary>
 39625        protected VirtualMachineRunCommandsOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of VirtualMachineRunCommandsOperations. </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"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 32        /// <param name="endpoint"> server parameter. </param>
 39633        internal VirtualMachineRunCommandsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string 
 34        {
 39635            RestClient = new VirtualMachineRunCommandsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoi
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> Gets specific run command for a subscription in a location. </summary>
 41        /// <param name="location"> The location upon which run commands is queried. </param>
 42        /// <param name="commandId"> The command id. </param>
 43        /// <param name="cancellationToken"> The cancellation token to use. </param>
 44        public virtual async Task<Response<RunCommandDocument>> GetAsync(string location, string commandId, Cancellation
 45        {
 246            using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandsOperations.Get");
 247            scope.Start();
 48            try
 49            {
 250                return await RestClient.GetAsync(location, commandId, cancellationToken).ConfigureAwait(false);
 51            }
 052            catch (Exception e)
 53            {
 054                scope.Failed(e);
 055                throw;
 56            }
 257        }
 58
 59        /// <summary> Gets specific run command for a subscription in a location. </summary>
 60        /// <param name="location"> The location upon which run commands is queried. </param>
 61        /// <param name="commandId"> The command id. </param>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public virtual Response<RunCommandDocument> Get(string location, string commandId, CancellationToken cancellatio
 64        {
 265            using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandsOperations.Get");
 266            scope.Start();
 67            try
 68            {
 269                return RestClient.Get(location, commandId, cancellationToken);
 70            }
 071            catch (Exception e)
 72            {
 073                scope.Failed(e);
 074                throw;
 75            }
 276        }
 77
 78        /// <summary> Lists all available run commands for a subscription in a location. </summary>
 79        /// <param name="location"> The location upon which run commands is queried. </param>
 80        /// <param name="cancellationToken"> The cancellation token to use. </param>
 81        public virtual AsyncPageable<RunCommandDocumentBase> ListAsync(string location, CancellationToken cancellationTo
 82        {
 283            if (location == null)
 84            {
 085                throw new ArgumentNullException(nameof(location));
 86            }
 87
 88            async Task<Page<RunCommandDocumentBase>> FirstPageFunc(int? pageSizeHint)
 89            {
 290                using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandsOperations.List");
 291                scope.Start();
 92                try
 93                {
 294                    var response = await RestClient.ListAsync(location, cancellationToken).ConfigureAwait(false);
 295                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 96                }
 097                catch (Exception e)
 98                {
 099                    scope.Failed(e);
 0100                    throw;
 101                }
 2102            }
 103            async Task<Page<RunCommandDocumentBase>> NextPageFunc(string nextLink, int? pageSizeHint)
 104            {
 0105                using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandsOperations.List");
 0106                scope.Start();
 107                try
 108                {
 0109                    var response = await RestClient.ListNextPageAsync(nextLink, location, cancellationToken).ConfigureAw
 0110                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 111                }
 0112                catch (Exception e)
 113                {
 0114                    scope.Failed(e);
 0115                    throw;
 116                }
 0117            }
 2118            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 119        }
 120
 121        /// <summary> Lists all available run commands for a subscription in a location. </summary>
 122        /// <param name="location"> The location upon which run commands is queried. </param>
 123        /// <param name="cancellationToken"> The cancellation token to use. </param>
 124        public virtual Pageable<RunCommandDocumentBase> List(string location, CancellationToken cancellationToken = defa
 125        {
 2126            if (location == null)
 127            {
 0128                throw new ArgumentNullException(nameof(location));
 129            }
 130
 131            Page<RunCommandDocumentBase> FirstPageFunc(int? pageSizeHint)
 132            {
 2133                using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandsOperations.List");
 2134                scope.Start();
 135                try
 136                {
 2137                    var response = RestClient.List(location, cancellationToken);
 2138                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 139                }
 0140                catch (Exception e)
 141                {
 0142                    scope.Failed(e);
 0143                    throw;
 144                }
 2145            }
 146            Page<RunCommandDocumentBase> NextPageFunc(string nextLink, int? pageSizeHint)
 147            {
 0148                using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandsOperations.List");
 0149                scope.Start();
 150                try
 151                {
 0152                    var response = RestClient.ListNextPage(nextLink, location, cancellationToken);
 0153                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 154                }
 0155                catch (Exception e)
 156                {
 0157                    scope.Failed(e);
 0158                    throw;
 159                }
 0160            }
 2161            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 162        }
 163    }
 164}