< Summary

Class:Azure.ResourceManager.Compute.VirtualMachineExtensionImagesRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineExtensionImagesRestOperations.cs
Covered lines:149
Uncovered lines:38
Coverable lines:187
Total lines:433
Line coverage:79.6% (149 of 187)
Covered branches:47
Total branches:86
Branch coverage:54.6% (47 of 86)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateGetRequest(...)-100%100%
GetAsync()-68.42%50%
Get(...)-68.42%50%
CreateListTypesRequest(...)-100%100%
ListTypesAsync()-75%58.33%
ListTypes(...)-75%58.33%
CreateListVersionsRequest(...)-86.96%50%
ListVersionsAsync()-72.73%57.14%
ListVersions(...)-72.73%57.14%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineExtensionImagesRestOperations.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.Collections.Generic;
 10using System.Text.Json;
 11using System.Threading;
 12using System.Threading.Tasks;
 13using Azure;
 14using Azure.Core;
 15using Azure.Core.Pipeline;
 16using Azure.ResourceManager.Compute.Models;
 17
 18namespace Azure.ResourceManager.Compute
 19{
 20    internal partial class VirtualMachineExtensionImagesRestOperations
 21    {
 22        private string subscriptionId;
 23        private Uri endpoint;
 24        private ClientDiagnostics _clientDiagnostics;
 25        private HttpPipeline _pipeline;
 26
 27        /// <summary> Initializes a new instance of VirtualMachineExtensionImagesRestOperations. </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"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 31        /// <param name="endpoint"> server parameter. </param>
 32        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 39633        public VirtualMachineExtensionImagesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, s
 34        {
 39635            if (subscriptionId == null)
 36            {
 037                throw new ArgumentNullException(nameof(subscriptionId));
 38            }
 39639            endpoint ??= new Uri("https://management.azure.com");
 40
 39641            this.subscriptionId = subscriptionId;
 39642            this.endpoint = endpoint;
 39643            _clientDiagnostics = clientDiagnostics;
 39644            _pipeline = pipeline;
 39645        }
 46
 47        internal HttpMessage CreateGetRequest(string location, string publisherName, string type, string version)
 48        {
 449            var message = _pipeline.CreateMessage();
 450            var request = message.Request;
 451            request.Method = RequestMethod.Get;
 452            var uri = new RawRequestUriBuilder();
 453            uri.Reset(endpoint);
 454            uri.AppendPath("/subscriptions/", false);
 455            uri.AppendPath(subscriptionId, true);
 456            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 457            uri.AppendPath(location, true);
 458            uri.AppendPath("/publishers/", false);
 459            uri.AppendPath(publisherName, true);
 460            uri.AppendPath("/artifacttypes/vmextension/types/", false);
 461            uri.AppendPath(type, true);
 462            uri.AppendPath("/versions/", false);
 463            uri.AppendPath(version, true);
 464            uri.AppendQuery("api-version", "2019-12-01", true);
 465            request.Uri = uri;
 466            return message;
 67        }
 68
 69        /// <summary> Gets a virtual machine extension image. </summary>
 70        /// <param name="location"> The name of a supported Azure region. </param>
 71        /// <param name="publisherName"> The String to use. </param>
 72        /// <param name="type"> The String to use. </param>
 73        /// <param name="version"> The String to use. </param>
 74        /// <param name="cancellationToken"> The cancellation token to use. </param>
 75        public async Task<Response<VirtualMachineExtensionImage>> GetAsync(string location, string publisherName, string
 76        {
 277            if (location == null)
 78            {
 079                throw new ArgumentNullException(nameof(location));
 80            }
 281            if (publisherName == null)
 82            {
 083                throw new ArgumentNullException(nameof(publisherName));
 84            }
 285            if (type == null)
 86            {
 087                throw new ArgumentNullException(nameof(type));
 88            }
 289            if (version == null)
 90            {
 091                throw new ArgumentNullException(nameof(version));
 92            }
 93
 294            using var message = CreateGetRequest(location, publisherName, type, version);
 295            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 296            switch (message.Response.Status)
 97            {
 98                case 200:
 99                    {
 2100                        VirtualMachineExtensionImage value = default;
 2101                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2102                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 103                        {
 0104                            value = null;
 105                        }
 106                        else
 107                        {
 2108                            value = VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(document.RootEl
 109                        }
 2110                        return Response.FromValue(value, message.Response);
 111                    }
 112                default:
 0113                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 114            }
 2115        }
 116
 117        /// <summary> Gets a virtual machine extension image. </summary>
 118        /// <param name="location"> The name of a supported Azure region. </param>
 119        /// <param name="publisherName"> The String to use. </param>
 120        /// <param name="type"> The String to use. </param>
 121        /// <param name="version"> The String to use. </param>
 122        /// <param name="cancellationToken"> The cancellation token to use. </param>
 123        public Response<VirtualMachineExtensionImage> Get(string location, string publisherName, string type, string ver
 124        {
 2125            if (location == null)
 126            {
 0127                throw new ArgumentNullException(nameof(location));
 128            }
 2129            if (publisherName == null)
 130            {
 0131                throw new ArgumentNullException(nameof(publisherName));
 132            }
 2133            if (type == null)
 134            {
 0135                throw new ArgumentNullException(nameof(type));
 136            }
 2137            if (version == null)
 138            {
 0139                throw new ArgumentNullException(nameof(version));
 140            }
 141
 2142            using var message = CreateGetRequest(location, publisherName, type, version);
 2143            _pipeline.Send(message, cancellationToken);
 2144            switch (message.Response.Status)
 145            {
 146                case 200:
 147                    {
 2148                        VirtualMachineExtensionImage value = default;
 2149                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2150                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 151                        {
 0152                            value = null;
 153                        }
 154                        else
 155                        {
 2156                            value = VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(document.RootEl
 157                        }
 2158                        return Response.FromValue(value, message.Response);
 159                    }
 160                default:
 0161                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 162            }
 2163        }
 164
 165        internal HttpMessage CreateListTypesRequest(string location, string publisherName)
 166        {
 4167            var message = _pipeline.CreateMessage();
 4168            var request = message.Request;
 4169            request.Method = RequestMethod.Get;
 4170            var uri = new RawRequestUriBuilder();
 4171            uri.Reset(endpoint);
 4172            uri.AppendPath("/subscriptions/", false);
 4173            uri.AppendPath(subscriptionId, true);
 4174            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 4175            uri.AppendPath(location, true);
 4176            uri.AppendPath("/publishers/", false);
 4177            uri.AppendPath(publisherName, true);
 4178            uri.AppendPath("/artifacttypes/vmextension/types", false);
 4179            uri.AppendQuery("api-version", "2019-12-01", true);
 4180            request.Uri = uri;
 4181            return message;
 182        }
 183
 184        /// <summary> Gets a list of virtual machine extension image types. </summary>
 185        /// <param name="location"> The name of a supported Azure region. </param>
 186        /// <param name="publisherName"> The String to use. </param>
 187        /// <param name="cancellationToken"> The cancellation token to use. </param>
 188        public async Task<Response<IReadOnlyList<VirtualMachineExtensionImage>>> ListTypesAsync(string location, string 
 189        {
 2190            if (location == null)
 191            {
 0192                throw new ArgumentNullException(nameof(location));
 193            }
 2194            if (publisherName == null)
 195            {
 0196                throw new ArgumentNullException(nameof(publisherName));
 197            }
 198
 2199            using var message = CreateListTypesRequest(location, publisherName);
 2200            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2201            switch (message.Response.Status)
 202            {
 203                case 200:
 204                    {
 2205                        IReadOnlyList<VirtualMachineExtensionImage> value = default;
 2206                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2207                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 208                        {
 0209                            value = null;
 210                        }
 211                        else
 212                        {
 2213                            List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>();
 20214                            foreach (var item in document.RootElement.EnumerateArray())
 215                            {
 8216                                if (item.ValueKind == JsonValueKind.Null)
 217                                {
 0218                                    array.Add(null);
 219                                }
 220                                else
 221                                {
 8222                                    array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item)
 223                                }
 224                            }
 2225                            value = array;
 226                        }
 2227                        return Response.FromValue(value, message.Response);
 228                    }
 229                default:
 0230                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 231            }
 2232        }
 233
 234        /// <summary> Gets a list of virtual machine extension image types. </summary>
 235        /// <param name="location"> The name of a supported Azure region. </param>
 236        /// <param name="publisherName"> The String to use. </param>
 237        /// <param name="cancellationToken"> The cancellation token to use. </param>
 238        public Response<IReadOnlyList<VirtualMachineExtensionImage>> ListTypes(string location, string publisherName, Ca
 239        {
 2240            if (location == null)
 241            {
 0242                throw new ArgumentNullException(nameof(location));
 243            }
 2244            if (publisherName == null)
 245            {
 0246                throw new ArgumentNullException(nameof(publisherName));
 247            }
 248
 2249            using var message = CreateListTypesRequest(location, publisherName);
 2250            _pipeline.Send(message, cancellationToken);
 2251            switch (message.Response.Status)
 252            {
 253                case 200:
 254                    {
 2255                        IReadOnlyList<VirtualMachineExtensionImage> value = default;
 2256                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2257                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 258                        {
 0259                            value = null;
 260                        }
 261                        else
 262                        {
 2263                            List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>();
 20264                            foreach (var item in document.RootElement.EnumerateArray())
 265                            {
 8266                                if (item.ValueKind == JsonValueKind.Null)
 267                                {
 0268                                    array.Add(null);
 269                                }
 270                                else
 271                                {
 8272                                    array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item)
 273                                }
 274                            }
 2275                            value = array;
 276                        }
 2277                        return Response.FromValue(value, message.Response);
 278                    }
 279                default:
 0280                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 281            }
 2282        }
 283
 284        internal HttpMessage CreateListVersionsRequest(string location, string publisherName, string type, string filter
 285        {
 4286            var message = _pipeline.CreateMessage();
 4287            var request = message.Request;
 4288            request.Method = RequestMethod.Get;
 4289            var uri = new RawRequestUriBuilder();
 4290            uri.Reset(endpoint);
 4291            uri.AppendPath("/subscriptions/", false);
 4292            uri.AppendPath(subscriptionId, true);
 4293            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 4294            uri.AppendPath(location, true);
 4295            uri.AppendPath("/publishers/", false);
 4296            uri.AppendPath(publisherName, true);
 4297            uri.AppendPath("/artifacttypes/vmextension/types/", false);
 4298            uri.AppendPath(type, true);
 4299            uri.AppendPath("/versions", false);
 4300            if (filter != null)
 301            {
 0302                uri.AppendQuery("$filter", filter, true);
 303            }
 4304            if (top != null)
 305            {
 0306                uri.AppendQuery("$top", top.Value, true);
 307            }
 4308            if (orderby != null)
 309            {
 0310                uri.AppendQuery("$orderby", orderby, true);
 311            }
 4312            uri.AppendQuery("api-version", "2019-12-01", true);
 4313            request.Uri = uri;
 4314            return message;
 315        }
 316
 317        /// <summary> Gets a list of virtual machine extension image versions. </summary>
 318        /// <param name="location"> The name of a supported Azure region. </param>
 319        /// <param name="publisherName"> The String to use. </param>
 320        /// <param name="type"> The String to use. </param>
 321        /// <param name="filter"> The filter to apply on the operation. </param>
 322        /// <param name="top"> The Integer to use. </param>
 323        /// <param name="orderby"> The String to use. </param>
 324        /// <param name="cancellationToken"> The cancellation token to use. </param>
 325        public async Task<Response<IReadOnlyList<VirtualMachineExtensionImage>>> ListVersionsAsync(string location, stri
 326        {
 2327            if (location == null)
 328            {
 0329                throw new ArgumentNullException(nameof(location));
 330            }
 2331            if (publisherName == null)
 332            {
 0333                throw new ArgumentNullException(nameof(publisherName));
 334            }
 2335            if (type == null)
 336            {
 0337                throw new ArgumentNullException(nameof(type));
 338            }
 339
 2340            using var message = CreateListVersionsRequest(location, publisherName, type, filter, top, orderby);
 2341            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2342            switch (message.Response.Status)
 343            {
 344                case 200:
 345                    {
 2346                        IReadOnlyList<VirtualMachineExtensionImage> value = default;
 2347                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2348                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 349                        {
 0350                            value = null;
 351                        }
 352                        else
 353                        {
 2354                            List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>();
 60355                            foreach (var item in document.RootElement.EnumerateArray())
 356                            {
 28357                                if (item.ValueKind == JsonValueKind.Null)
 358                                {
 0359                                    array.Add(null);
 360                                }
 361                                else
 362                                {
 28363                                    array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item)
 364                                }
 365                            }
 2366                            value = array;
 367                        }
 2368                        return Response.FromValue(value, message.Response);
 369                    }
 370                default:
 0371                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 372            }
 2373        }
 374
 375        /// <summary> Gets a list of virtual machine extension image versions. </summary>
 376        /// <param name="location"> The name of a supported Azure region. </param>
 377        /// <param name="publisherName"> The String to use. </param>
 378        /// <param name="type"> The String to use. </param>
 379        /// <param name="filter"> The filter to apply on the operation. </param>
 380        /// <param name="top"> The Integer to use. </param>
 381        /// <param name="orderby"> The String to use. </param>
 382        /// <param name="cancellationToken"> The cancellation token to use. </param>
 383        public Response<IReadOnlyList<VirtualMachineExtensionImage>> ListVersions(string location, string publisherName,
 384        {
 2385            if (location == null)
 386            {
 0387                throw new ArgumentNullException(nameof(location));
 388            }
 2389            if (publisherName == null)
 390            {
 0391                throw new ArgumentNullException(nameof(publisherName));
 392            }
 2393            if (type == null)
 394            {
 0395                throw new ArgumentNullException(nameof(type));
 396            }
 397
 2398            using var message = CreateListVersionsRequest(location, publisherName, type, filter, top, orderby);
 2399            _pipeline.Send(message, cancellationToken);
 2400            switch (message.Response.Status)
 401            {
 402                case 200:
 403                    {
 2404                        IReadOnlyList<VirtualMachineExtensionImage> value = default;
 2405                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2406                        if (document.RootElement.ValueKind == JsonValueKind.Null)
 407                        {
 0408                            value = null;
 409                        }
 410                        else
 411                        {
 2412                            List<VirtualMachineExtensionImage> array = new List<VirtualMachineExtensionImage>();
 60413                            foreach (var item in document.RootElement.EnumerateArray())
 414                            {
 28415                                if (item.ValueKind == JsonValueKind.Null)
 416                                {
 0417                                    array.Add(null);
 418                                }
 419                                else
 420                                {
 28421                                    array.Add(VirtualMachineExtensionImage.DeserializeVirtualMachineExtensionImage(item)
 422                                }
 423                            }
 2424                            value = array;
 425                        }
 2426                        return Response.FromValue(value, message.Response);
 427                    }
 428                default:
 0429                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 430            }
 2431        }
 432    }
 433}