| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Compute.Models; |
| | 15 | |
|
| | 16 | | namespace 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 |
| 396 | 31 | | public LogAnalyticsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | 32 | | { |
| 396 | 33 | | if (subscriptionId == null) |
| | 34 | | { |
| 0 | 35 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 36 | | } |
| 396 | 37 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 38 | |
|
| 396 | 39 | | this.subscriptionId = subscriptionId; |
| 396 | 40 | | this.endpoint = endpoint; |
| 396 | 41 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 42 | | _pipeline = pipeline; |
| 396 | 43 | | } |
| | 44 | |
|
| | 45 | | internal HttpMessage CreateExportRequestRateByIntervalRequest(string location, RequestRateByIntervalInput parame |
| | 46 | | { |
| 0 | 47 | | var message = _pipeline.CreateMessage(); |
| 0 | 48 | | var request = message.Request; |
| 0 | 49 | | request.Method = RequestMethod.Post; |
| 0 | 50 | | var uri = new RawRequestUriBuilder(); |
| 0 | 51 | | uri.Reset(endpoint); |
| 0 | 52 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 53 | | uri.AppendPath(subscriptionId, true); |
| 0 | 54 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 0 | 55 | | uri.AppendPath(location, true); |
| 0 | 56 | | uri.AppendPath("/logAnalytics/apiAccess/getRequestRateByInterval", false); |
| 0 | 57 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 58 | | request.Uri = uri; |
| 0 | 59 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 60 | | var content = new Utf8JsonRequestContent(); |
| 0 | 61 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 62 | | request.Content = content; |
| 0 | 63 | | 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 | | { |
| 0 | 72 | | if (location == null) |
| | 73 | | { |
| 0 | 74 | | throw new ArgumentNullException(nameof(location)); |
| | 75 | | } |
| 0 | 76 | | if (parameters == null) |
| | 77 | | { |
| 0 | 78 | | throw new ArgumentNullException(nameof(parameters)); |
| | 79 | | } |
| | 80 | |
|
| 0 | 81 | | using var message = CreateExportRequestRateByIntervalRequest(location, parameters); |
| 0 | 82 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 83 | | switch (message.Response.Status) |
| | 84 | | { |
| | 85 | | case 200: |
| | 86 | | case 202: |
| 0 | 87 | | return message.Response; |
| | 88 | | default: |
| 0 | 89 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 90 | | } |
| 0 | 91 | | } |
| | 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 | | { |
| 0 | 99 | | if (location == null) |
| | 100 | | { |
| 0 | 101 | | throw new ArgumentNullException(nameof(location)); |
| | 102 | | } |
| 0 | 103 | | if (parameters == null) |
| | 104 | | { |
| 0 | 105 | | throw new ArgumentNullException(nameof(parameters)); |
| | 106 | | } |
| | 107 | |
|
| 0 | 108 | | using var message = CreateExportRequestRateByIntervalRequest(location, parameters); |
| 0 | 109 | | _pipeline.Send(message, cancellationToken); |
| 0 | 110 | | switch (message.Response.Status) |
| | 111 | | { |
| | 112 | | case 200: |
| | 113 | | case 202: |
| 0 | 114 | | return message.Response; |
| | 115 | | default: |
| 0 | 116 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 117 | | } |
| 0 | 118 | | } |
| | 119 | |
|
| | 120 | | internal HttpMessage CreateExportThrottledRequestsRequest(string location, LogAnalyticsInputBase parameters) |
| | 121 | | { |
| 0 | 122 | | var message = _pipeline.CreateMessage(); |
| 0 | 123 | | var request = message.Request; |
| 0 | 124 | | request.Method = RequestMethod.Post; |
| 0 | 125 | | var uri = new RawRequestUriBuilder(); |
| 0 | 126 | | uri.Reset(endpoint); |
| 0 | 127 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 128 | | uri.AppendPath(subscriptionId, true); |
| 0 | 129 | | uri.AppendPath("/providers/Microsoft.Compute/locations/", false); |
| 0 | 130 | | uri.AppendPath(location, true); |
| 0 | 131 | | uri.AppendPath("/logAnalytics/apiAccess/getThrottledRequests", false); |
| 0 | 132 | | uri.AppendQuery("api-version", "2019-12-01", true); |
| 0 | 133 | | request.Uri = uri; |
| 0 | 134 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 135 | | var content = new Utf8JsonRequestContent(); |
| 0 | 136 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 137 | | request.Content = content; |
| 0 | 138 | | 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 | | { |
| 0 | 147 | | if (location == null) |
| | 148 | | { |
| 0 | 149 | | throw new ArgumentNullException(nameof(location)); |
| | 150 | | } |
| 0 | 151 | | if (parameters == null) |
| | 152 | | { |
| 0 | 153 | | throw new ArgumentNullException(nameof(parameters)); |
| | 154 | | } |
| | 155 | |
|
| 0 | 156 | | using var message = CreateExportThrottledRequestsRequest(location, parameters); |
| 0 | 157 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 158 | | switch (message.Response.Status) |
| | 159 | | { |
| | 160 | | case 200: |
| | 161 | | case 202: |
| 0 | 162 | | return message.Response; |
| | 163 | | default: |
| 0 | 164 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 165 | | } |
| 0 | 166 | | } |
| | 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 | | { |
| 0 | 174 | | if (location == null) |
| | 175 | | { |
| 0 | 176 | | throw new ArgumentNullException(nameof(location)); |
| | 177 | | } |
| 0 | 178 | | if (parameters == null) |
| | 179 | | { |
| 0 | 180 | | throw new ArgumentNullException(nameof(parameters)); |
| | 181 | | } |
| | 182 | |
|
| 0 | 183 | | using var message = CreateExportThrottledRequestsRequest(location, parameters); |
| 0 | 184 | | _pipeline.Send(message, cancellationToken); |
| 0 | 185 | | switch (message.Response.Status) |
| | 186 | | { |
| | 187 | | case 200: |
| | 188 | | case 202: |
| 0 | 189 | | return message.Response; |
| | 190 | | default: |
| 0 | 191 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 192 | | } |
| 0 | 193 | | } |
| | 194 | | } |
| | 195 | | } |