< Summary

Class:Azure.ResourceManager.Compute.LogAnalyticsRestOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\LogAnalyticsRestOperations.cs
Covered lines:8
Uncovered lines:75
Coverable lines:83
Total lines:195
Line coverage:9.6% (8 of 83)
Covered branches:2
Total branches:36
Branch coverage:5.5% (2 of 36)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-88.89%50%
CreateExportRequestRateByIntervalRequest(...)-0%100%
ExportRequestRateByIntervalAsync()-0%0%
ExportRequestRateByInterval(...)-0%0%
CreateExportThrottledRequestsRequest(...)-0%100%
ExportThrottledRequestsAsync()-0%0%
ExportThrottledRequests(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\LogAnalyticsRestOperations.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    internal partial class LogAnalyticsRestOperations
 19    {
 20        private string subscriptionId;
 21        private Uri endpoint;
 22        private ClientDiagnostics _clientDiagnostics;
 23        private HttpPipeline _pipeline;
 24
 25        /// <summary> Initializes a new instance of LogAnalyticsRestOperations. </summary>
 26        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 27        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 28        /// <param name="subscriptionId"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 29        /// <param name="endpoint"> server parameter. </param>
 30        /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception
 39631        public LogAnalyticsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 32        {
 39633            if (subscriptionId == null)
 34            {
 035                throw new ArgumentNullException(nameof(subscriptionId));
 36            }
 39637            endpoint ??= new Uri("https://management.azure.com");
 38
 39639            this.subscriptionId = subscriptionId;
 39640            this.endpoint = endpoint;
 39641            _clientDiagnostics = clientDiagnostics;
 39642            _pipeline = pipeline;
 39643        }
 44
 45        internal HttpMessage CreateExportRequestRateByIntervalRequest(string location, RequestRateByIntervalInput parame
 46        {
 047            var message = _pipeline.CreateMessage();
 048            var request = message.Request;
 049            request.Method = RequestMethod.Post;
 050            var uri = new RawRequestUriBuilder();
 051            uri.Reset(endpoint);
 052            uri.AppendPath("/subscriptions/", false);
 053            uri.AppendPath(subscriptionId, true);
 054            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 055            uri.AppendPath(location, true);
 056            uri.AppendPath("/logAnalytics/apiAccess/getRequestRateByInterval", false);
 057            uri.AppendQuery("api-version", "2019-12-01", true);
 058            request.Uri = uri;
 059            request.Headers.Add("Content-Type", "application/json");
 060            var content = new Utf8JsonRequestContent();
 061            content.JsonWriter.WriteObjectValue(parameters);
 062            request.Content = content;
 063            return message;
 64        }
 65
 66        /// <summary> Export logs that show Api requests made by this subscription in the given time window to show thro
 67        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 68        /// <param name="parameters"> Parameters supplied to the LogAnalytics getRequestRateByInterval Api. </param>
 69        /// <param name="cancellationToken"> The cancellation token to use. </param>
 70        public async Task<Response> ExportRequestRateByIntervalAsync(string location, RequestRateByIntervalInput paramet
 71        {
 072            if (location == null)
 73            {
 074                throw new ArgumentNullException(nameof(location));
 75            }
 076            if (parameters == null)
 77            {
 078                throw new ArgumentNullException(nameof(parameters));
 79            }
 80
 081            using var message = CreateExportRequestRateByIntervalRequest(location, parameters);
 082            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 083            switch (message.Response.Status)
 84            {
 85                case 200:
 86                case 202:
 087                    return message.Response;
 88                default:
 089                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 90            }
 091        }
 92
 93        /// <summary> Export logs that show Api requests made by this subscription in the given time window to show thro
 94        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 95        /// <param name="parameters"> Parameters supplied to the LogAnalytics getRequestRateByInterval Api. </param>
 96        /// <param name="cancellationToken"> The cancellation token to use. </param>
 97        public Response ExportRequestRateByInterval(string location, RequestRateByIntervalInput parameters, Cancellation
 98        {
 099            if (location == null)
 100            {
 0101                throw new ArgumentNullException(nameof(location));
 102            }
 0103            if (parameters == null)
 104            {
 0105                throw new ArgumentNullException(nameof(parameters));
 106            }
 107
 0108            using var message = CreateExportRequestRateByIntervalRequest(location, parameters);
 0109            _pipeline.Send(message, cancellationToken);
 0110            switch (message.Response.Status)
 111            {
 112                case 200:
 113                case 202:
 0114                    return message.Response;
 115                default:
 0116                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 117            }
 0118        }
 119
 120        internal HttpMessage CreateExportThrottledRequestsRequest(string location, LogAnalyticsInputBase parameters)
 121        {
 0122            var message = _pipeline.CreateMessage();
 0123            var request = message.Request;
 0124            request.Method = RequestMethod.Post;
 0125            var uri = new RawRequestUriBuilder();
 0126            uri.Reset(endpoint);
 0127            uri.AppendPath("/subscriptions/", false);
 0128            uri.AppendPath(subscriptionId, true);
 0129            uri.AppendPath("/providers/Microsoft.Compute/locations/", false);
 0130            uri.AppendPath(location, true);
 0131            uri.AppendPath("/logAnalytics/apiAccess/getThrottledRequests", false);
 0132            uri.AppendQuery("api-version", "2019-12-01", true);
 0133            request.Uri = uri;
 0134            request.Headers.Add("Content-Type", "application/json");
 0135            var content = new Utf8JsonRequestContent();
 0136            content.JsonWriter.WriteObjectValue(parameters);
 0137            request.Content = content;
 0138            return message;
 139        }
 140
 141        /// <summary> Export logs that show total throttled Api requests for this subscription in the given time window.
 142        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 143        /// <param name="parameters"> Parameters supplied to the LogAnalytics getThrottledRequests Api. </param>
 144        /// <param name="cancellationToken"> The cancellation token to use. </param>
 145        public async Task<Response> ExportThrottledRequestsAsync(string location, LogAnalyticsInputBase parameters, Canc
 146        {
 0147            if (location == null)
 148            {
 0149                throw new ArgumentNullException(nameof(location));
 150            }
 0151            if (parameters == null)
 152            {
 0153                throw new ArgumentNullException(nameof(parameters));
 154            }
 155
 0156            using var message = CreateExportThrottledRequestsRequest(location, parameters);
 0157            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0158            switch (message.Response.Status)
 159            {
 160                case 200:
 161                case 202:
 0162                    return message.Response;
 163                default:
 0164                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 165            }
 0166        }
 167
 168        /// <summary> Export logs that show total throttled Api requests for this subscription in the given time window.
 169        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 170        /// <param name="parameters"> Parameters supplied to the LogAnalytics getThrottledRequests Api. </param>
 171        /// <param name="cancellationToken"> The cancellation token to use. </param>
 172        public Response ExportThrottledRequests(string location, LogAnalyticsInputBase parameters, CancellationToken can
 173        {
 0174            if (location == null)
 175            {
 0176                throw new ArgumentNullException(nameof(location));
 177            }
 0178            if (parameters == null)
 179            {
 0180                throw new ArgumentNullException(nameof(parameters));
 181            }
 182
 0183            using var message = CreateExportThrottledRequestsRequest(location, parameters);
 0184            _pipeline.Send(message, cancellationToken);
 0185            switch (message.Response.Status)
 186            {
 187                case 200:
 188                case 202:
 0189                    return message.Response;
 190                default:
 0191                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 192            }
 0193        }
 194    }
 195}