| | 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.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Network.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Network |
| | 18 | | { |
| | 19 | | internal partial class ConnectionMonitorsRestOperations |
| | 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 ConnectionMonitorsRestOperations. </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"> The subscription credentials which uniquely identify the Microsoft Azure subsc |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 0 | 32 | | public ConnectionMonitorsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subsc |
| | 33 | | { |
| 0 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 0 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 0 | 40 | | this.subscriptionId = subscriptionId; |
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string networkWatcherName, string con |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Put; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 57 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 58 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 59 | | uri.AppendPath("/connectionMonitors/", false); |
| 0 | 60 | | uri.AppendPath(connectionMonitorName, true); |
| 0 | 61 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 62 | | request.Uri = uri; |
| 0 | 63 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 64 | | var content = new Utf8JsonRequestContent(); |
| 0 | 65 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 66 | | request.Content = content; |
| 0 | 67 | | return message; |
| | 68 | | } |
| | 69 | |
|
| | 70 | | /// <summary> Create or update a connection monitor. </summary> |
| | 71 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 72 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 73 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 74 | | /// <param name="parameters"> Parameters that define the operation to create a connection monitor. </param> |
| | 75 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 76 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string networkWatcherName, string conn |
| | 77 | | { |
| 0 | 78 | | if (resourceGroupName == null) |
| | 79 | | { |
| 0 | 80 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 81 | | } |
| 0 | 82 | | if (networkWatcherName == null) |
| | 83 | | { |
| 0 | 84 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 85 | | } |
| 0 | 86 | | if (connectionMonitorName == null) |
| | 87 | | { |
| 0 | 88 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 89 | | } |
| 0 | 90 | | if (parameters == null) |
| | 91 | | { |
| 0 | 92 | | throw new ArgumentNullException(nameof(parameters)); |
| | 93 | | } |
| | 94 | |
|
| 0 | 95 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, connectionMonitorName |
| 0 | 96 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 97 | | switch (message.Response.Status) |
| | 98 | | { |
| | 99 | | case 200: |
| | 100 | | case 201: |
| 0 | 101 | | return message.Response; |
| | 102 | | default: |
| 0 | 103 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 104 | | } |
| 0 | 105 | | } |
| | 106 | |
|
| | 107 | | /// <summary> Create or update a connection monitor. </summary> |
| | 108 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 109 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 110 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 111 | | /// <param name="parameters"> Parameters that define the operation to create a connection monitor. </param> |
| | 112 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 113 | | public Response CreateOrUpdate(string resourceGroupName, string networkWatcherName, string connectionMonitorName |
| | 114 | | { |
| 0 | 115 | | if (resourceGroupName == null) |
| | 116 | | { |
| 0 | 117 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 118 | | } |
| 0 | 119 | | if (networkWatcherName == null) |
| | 120 | | { |
| 0 | 121 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 122 | | } |
| 0 | 123 | | if (connectionMonitorName == null) |
| | 124 | | { |
| 0 | 125 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 126 | | } |
| 0 | 127 | | if (parameters == null) |
| | 128 | | { |
| 0 | 129 | | throw new ArgumentNullException(nameof(parameters)); |
| | 130 | | } |
| | 131 | |
|
| 0 | 132 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, connectionMonitorName |
| 0 | 133 | | _pipeline.Send(message, cancellationToken); |
| 0 | 134 | | switch (message.Response.Status) |
| | 135 | | { |
| | 136 | | case 200: |
| | 137 | | case 201: |
| 0 | 138 | | return message.Response; |
| | 139 | | default: |
| 0 | 140 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 141 | | } |
| 0 | 142 | | } |
| | 143 | |
|
| | 144 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string networkWatcherName, string connectionMoni |
| | 145 | | { |
| 0 | 146 | | var message = _pipeline.CreateMessage(); |
| 0 | 147 | | var request = message.Request; |
| 0 | 148 | | request.Method = RequestMethod.Get; |
| 0 | 149 | | var uri = new RawRequestUriBuilder(); |
| 0 | 150 | | uri.Reset(endpoint); |
| 0 | 151 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 152 | | uri.AppendPath(subscriptionId, true); |
| 0 | 153 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 154 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 155 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 156 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 157 | | uri.AppendPath("/connectionMonitors/", false); |
| 0 | 158 | | uri.AppendPath(connectionMonitorName, true); |
| 0 | 159 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 160 | | request.Uri = uri; |
| 0 | 161 | | return message; |
| | 162 | | } |
| | 163 | |
|
| | 164 | | /// <summary> Gets a connection monitor by name. </summary> |
| | 165 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 166 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 167 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 168 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 169 | | public async Task<Response<ConnectionMonitorResult>> GetAsync(string resourceGroupName, string networkWatcherNam |
| | 170 | | { |
| 0 | 171 | | if (resourceGroupName == null) |
| | 172 | | { |
| 0 | 173 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 174 | | } |
| 0 | 175 | | if (networkWatcherName == null) |
| | 176 | | { |
| 0 | 177 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 178 | | } |
| 0 | 179 | | if (connectionMonitorName == null) |
| | 180 | | { |
| 0 | 181 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 182 | | } |
| | 183 | |
|
| 0 | 184 | | using var message = CreateGetRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 185 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 186 | | switch (message.Response.Status) |
| | 187 | | { |
| | 188 | | case 200: |
| | 189 | | { |
| 0 | 190 | | ConnectionMonitorResult value = default; |
| 0 | 191 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 192 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 193 | | { |
| 0 | 194 | | value = null; |
| | 195 | | } |
| | 196 | | else |
| | 197 | | { |
| 0 | 198 | | value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement); |
| | 199 | | } |
| 0 | 200 | | return Response.FromValue(value, message.Response); |
| | 201 | | } |
| | 202 | | default: |
| 0 | 203 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 204 | | } |
| 0 | 205 | | } |
| | 206 | |
|
| | 207 | | /// <summary> Gets a connection monitor by name. </summary> |
| | 208 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 209 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 210 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 211 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 212 | | public Response<ConnectionMonitorResult> Get(string resourceGroupName, string networkWatcherName, string connect |
| | 213 | | { |
| 0 | 214 | | if (resourceGroupName == null) |
| | 215 | | { |
| 0 | 216 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 217 | | } |
| 0 | 218 | | if (networkWatcherName == null) |
| | 219 | | { |
| 0 | 220 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 221 | | } |
| 0 | 222 | | if (connectionMonitorName == null) |
| | 223 | | { |
| 0 | 224 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 225 | | } |
| | 226 | |
|
| 0 | 227 | | using var message = CreateGetRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 228 | | _pipeline.Send(message, cancellationToken); |
| 0 | 229 | | switch (message.Response.Status) |
| | 230 | | { |
| | 231 | | case 200: |
| | 232 | | { |
| 0 | 233 | | ConnectionMonitorResult value = default; |
| 0 | 234 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 235 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 236 | | { |
| 0 | 237 | | value = null; |
| | 238 | | } |
| | 239 | | else |
| | 240 | | { |
| 0 | 241 | | value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement); |
| | 242 | | } |
| 0 | 243 | | return Response.FromValue(value, message.Response); |
| | 244 | | } |
| | 245 | | default: |
| 0 | 246 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 247 | | } |
| 0 | 248 | | } |
| | 249 | |
|
| | 250 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string networkWatcherName, string connectionM |
| | 251 | | { |
| 0 | 252 | | var message = _pipeline.CreateMessage(); |
| 0 | 253 | | var request = message.Request; |
| 0 | 254 | | request.Method = RequestMethod.Delete; |
| 0 | 255 | | var uri = new RawRequestUriBuilder(); |
| 0 | 256 | | uri.Reset(endpoint); |
| 0 | 257 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 258 | | uri.AppendPath(subscriptionId, true); |
| 0 | 259 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 260 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 261 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 262 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 263 | | uri.AppendPath("/connectionMonitors/", false); |
| 0 | 264 | | uri.AppendPath(connectionMonitorName, true); |
| 0 | 265 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 266 | | request.Uri = uri; |
| 0 | 267 | | return message; |
| | 268 | | } |
| | 269 | |
|
| | 270 | | /// <summary> Deletes the specified connection monitor. </summary> |
| | 271 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 272 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 273 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 274 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 275 | | public async Task<Response> DeleteAsync(string resourceGroupName, string networkWatcherName, string connectionMo |
| | 276 | | { |
| 0 | 277 | | if (resourceGroupName == null) |
| | 278 | | { |
| 0 | 279 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 280 | | } |
| 0 | 281 | | if (networkWatcherName == null) |
| | 282 | | { |
| 0 | 283 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 284 | | } |
| 0 | 285 | | if (connectionMonitorName == null) |
| | 286 | | { |
| 0 | 287 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 288 | | } |
| | 289 | |
|
| 0 | 290 | | using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 291 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 292 | | switch (message.Response.Status) |
| | 293 | | { |
| | 294 | | case 202: |
| | 295 | | case 204: |
| 0 | 296 | | return message.Response; |
| | 297 | | default: |
| 0 | 298 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 299 | | } |
| 0 | 300 | | } |
| | 301 | |
|
| | 302 | | /// <summary> Deletes the specified connection monitor. </summary> |
| | 303 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 304 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 305 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 306 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 307 | | public Response Delete(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancel |
| | 308 | | { |
| 0 | 309 | | if (resourceGroupName == null) |
| | 310 | | { |
| 0 | 311 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 312 | | } |
| 0 | 313 | | if (networkWatcherName == null) |
| | 314 | | { |
| 0 | 315 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 316 | | } |
| 0 | 317 | | if (connectionMonitorName == null) |
| | 318 | | { |
| 0 | 319 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 320 | | } |
| | 321 | |
|
| 0 | 322 | | using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 323 | | _pipeline.Send(message, cancellationToken); |
| 0 | 324 | | switch (message.Response.Status) |
| | 325 | | { |
| | 326 | | case 202: |
| | 327 | | case 204: |
| 0 | 328 | | return message.Response; |
| | 329 | | default: |
| 0 | 330 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 331 | | } |
| 0 | 332 | | } |
| | 333 | |
|
| | 334 | | internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string networkWatcherName, string connect |
| | 335 | | { |
| 0 | 336 | | var message = _pipeline.CreateMessage(); |
| 0 | 337 | | var request = message.Request; |
| 0 | 338 | | request.Method = RequestMethod.Patch; |
| 0 | 339 | | var uri = new RawRequestUriBuilder(); |
| 0 | 340 | | uri.Reset(endpoint); |
| 0 | 341 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 342 | | uri.AppendPath(subscriptionId, true); |
| 0 | 343 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 344 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 345 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 346 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 347 | | uri.AppendPath("/connectionMonitors/", false); |
| 0 | 348 | | uri.AppendPath(connectionMonitorName, true); |
| 0 | 349 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 350 | | request.Uri = uri; |
| 0 | 351 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 352 | | var content = new Utf8JsonRequestContent(); |
| 0 | 353 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 354 | | request.Content = content; |
| 0 | 355 | | return message; |
| | 356 | | } |
| | 357 | |
|
| | 358 | | /// <summary> Update tags of the specified connection monitor. </summary> |
| | 359 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 360 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 361 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 362 | | /// <param name="parameters"> Parameters supplied to update connection monitor tags. </param> |
| | 363 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 364 | | public async Task<Response<ConnectionMonitorResult>> UpdateTagsAsync(string resourceGroupName, string networkWat |
| | 365 | | { |
| 0 | 366 | | if (resourceGroupName == null) |
| | 367 | | { |
| 0 | 368 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 369 | | } |
| 0 | 370 | | if (networkWatcherName == null) |
| | 371 | | { |
| 0 | 372 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 373 | | } |
| 0 | 374 | | if (connectionMonitorName == null) |
| | 375 | | { |
| 0 | 376 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 377 | | } |
| 0 | 378 | | if (parameters == null) |
| | 379 | | { |
| 0 | 380 | | throw new ArgumentNullException(nameof(parameters)); |
| | 381 | | } |
| | 382 | |
|
| 0 | 383 | | using var message = CreateUpdateTagsRequest(resourceGroupName, networkWatcherName, connectionMonitorName, pa |
| 0 | 384 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 385 | | switch (message.Response.Status) |
| | 386 | | { |
| | 387 | | case 200: |
| | 388 | | { |
| 0 | 389 | | ConnectionMonitorResult value = default; |
| 0 | 390 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 391 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 392 | | { |
| 0 | 393 | | value = null; |
| | 394 | | } |
| | 395 | | else |
| | 396 | | { |
| 0 | 397 | | value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement); |
| | 398 | | } |
| 0 | 399 | | return Response.FromValue(value, message.Response); |
| | 400 | | } |
| | 401 | | default: |
| 0 | 402 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 403 | | } |
| 0 | 404 | | } |
| | 405 | |
|
| | 406 | | /// <summary> Update tags of the specified connection monitor. </summary> |
| | 407 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 408 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 409 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 410 | | /// <param name="parameters"> Parameters supplied to update connection monitor tags. </param> |
| | 411 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 412 | | public Response<ConnectionMonitorResult> UpdateTags(string resourceGroupName, string networkWatcherName, string |
| | 413 | | { |
| 0 | 414 | | if (resourceGroupName == null) |
| | 415 | | { |
| 0 | 416 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 417 | | } |
| 0 | 418 | | if (networkWatcherName == null) |
| | 419 | | { |
| 0 | 420 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 421 | | } |
| 0 | 422 | | if (connectionMonitorName == null) |
| | 423 | | { |
| 0 | 424 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 425 | | } |
| 0 | 426 | | if (parameters == null) |
| | 427 | | { |
| 0 | 428 | | throw new ArgumentNullException(nameof(parameters)); |
| | 429 | | } |
| | 430 | |
|
| 0 | 431 | | using var message = CreateUpdateTagsRequest(resourceGroupName, networkWatcherName, connectionMonitorName, pa |
| 0 | 432 | | _pipeline.Send(message, cancellationToken); |
| 0 | 433 | | switch (message.Response.Status) |
| | 434 | | { |
| | 435 | | case 200: |
| | 436 | | { |
| 0 | 437 | | ConnectionMonitorResult value = default; |
| 0 | 438 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 439 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 440 | | { |
| 0 | 441 | | value = null; |
| | 442 | | } |
| | 443 | | else |
| | 444 | | { |
| 0 | 445 | | value = ConnectionMonitorResult.DeserializeConnectionMonitorResult(document.RootElement); |
| | 446 | | } |
| 0 | 447 | | return Response.FromValue(value, message.Response); |
| | 448 | | } |
| | 449 | | default: |
| 0 | 450 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 451 | | } |
| 0 | 452 | | } |
| | 453 | |
|
| | 454 | | internal HttpMessage CreateStopRequest(string resourceGroupName, string networkWatcherName, string connectionMon |
| | 455 | | { |
| 0 | 456 | | var message = _pipeline.CreateMessage(); |
| 0 | 457 | | var request = message.Request; |
| 0 | 458 | | request.Method = RequestMethod.Post; |
| 0 | 459 | | var uri = new RawRequestUriBuilder(); |
| 0 | 460 | | uri.Reset(endpoint); |
| 0 | 461 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 462 | | uri.AppendPath(subscriptionId, true); |
| 0 | 463 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 464 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 465 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 466 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 467 | | uri.AppendPath("/connectionMonitors/", false); |
| 0 | 468 | | uri.AppendPath(connectionMonitorName, true); |
| 0 | 469 | | uri.AppendPath("/stop", false); |
| 0 | 470 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 471 | | request.Uri = uri; |
| 0 | 472 | | return message; |
| | 473 | | } |
| | 474 | |
|
| | 475 | | /// <summary> Stops the specified connection monitor. </summary> |
| | 476 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 477 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 478 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 479 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 480 | | public async Task<Response> StopAsync(string resourceGroupName, string networkWatcherName, string connectionMoni |
| | 481 | | { |
| 0 | 482 | | if (resourceGroupName == null) |
| | 483 | | { |
| 0 | 484 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 485 | | } |
| 0 | 486 | | if (networkWatcherName == null) |
| | 487 | | { |
| 0 | 488 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 489 | | } |
| 0 | 490 | | if (connectionMonitorName == null) |
| | 491 | | { |
| 0 | 492 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 493 | | } |
| | 494 | |
|
| 0 | 495 | | using var message = CreateStopRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 496 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 497 | | switch (message.Response.Status) |
| | 498 | | { |
| | 499 | | case 200: |
| | 500 | | case 202: |
| 0 | 501 | | return message.Response; |
| | 502 | | default: |
| 0 | 503 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 504 | | } |
| 0 | 505 | | } |
| | 506 | |
|
| | 507 | | /// <summary> Stops the specified connection monitor. </summary> |
| | 508 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 509 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 510 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 511 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 512 | | public Response Stop(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancella |
| | 513 | | { |
| 0 | 514 | | if (resourceGroupName == null) |
| | 515 | | { |
| 0 | 516 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 517 | | } |
| 0 | 518 | | if (networkWatcherName == null) |
| | 519 | | { |
| 0 | 520 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 521 | | } |
| 0 | 522 | | if (connectionMonitorName == null) |
| | 523 | | { |
| 0 | 524 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 525 | | } |
| | 526 | |
|
| 0 | 527 | | using var message = CreateStopRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 528 | | _pipeline.Send(message, cancellationToken); |
| 0 | 529 | | switch (message.Response.Status) |
| | 530 | | { |
| | 531 | | case 200: |
| | 532 | | case 202: |
| 0 | 533 | | return message.Response; |
| | 534 | | default: |
| 0 | 535 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 536 | | } |
| 0 | 537 | | } |
| | 538 | |
|
| | 539 | | internal HttpMessage CreateStartRequest(string resourceGroupName, string networkWatcherName, string connectionMo |
| | 540 | | { |
| 0 | 541 | | var message = _pipeline.CreateMessage(); |
| 0 | 542 | | var request = message.Request; |
| 0 | 543 | | request.Method = RequestMethod.Post; |
| 0 | 544 | | var uri = new RawRequestUriBuilder(); |
| 0 | 545 | | uri.Reset(endpoint); |
| 0 | 546 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 547 | | uri.AppendPath(subscriptionId, true); |
| 0 | 548 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 549 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 550 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 551 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 552 | | uri.AppendPath("/connectionMonitors/", false); |
| 0 | 553 | | uri.AppendPath(connectionMonitorName, true); |
| 0 | 554 | | uri.AppendPath("/start", false); |
| 0 | 555 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 556 | | request.Uri = uri; |
| 0 | 557 | | return message; |
| | 558 | | } |
| | 559 | |
|
| | 560 | | /// <summary> Starts the specified connection monitor. </summary> |
| | 561 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 562 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 563 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 564 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 565 | | public async Task<Response> StartAsync(string resourceGroupName, string networkWatcherName, string connectionMon |
| | 566 | | { |
| 0 | 567 | | if (resourceGroupName == null) |
| | 568 | | { |
| 0 | 569 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 570 | | } |
| 0 | 571 | | if (networkWatcherName == null) |
| | 572 | | { |
| 0 | 573 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 574 | | } |
| 0 | 575 | | if (connectionMonitorName == null) |
| | 576 | | { |
| 0 | 577 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 578 | | } |
| | 579 | |
|
| 0 | 580 | | using var message = CreateStartRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 581 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 582 | | switch (message.Response.Status) |
| | 583 | | { |
| | 584 | | case 200: |
| | 585 | | case 202: |
| 0 | 586 | | return message.Response; |
| | 587 | | default: |
| 0 | 588 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 589 | | } |
| 0 | 590 | | } |
| | 591 | |
|
| | 592 | | /// <summary> Starts the specified connection monitor. </summary> |
| | 593 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 594 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 595 | | /// <param name="connectionMonitorName"> The name of the connection monitor. </param> |
| | 596 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 597 | | public Response Start(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancell |
| | 598 | | { |
| 0 | 599 | | if (resourceGroupName == null) |
| | 600 | | { |
| 0 | 601 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 602 | | } |
| 0 | 603 | | if (networkWatcherName == null) |
| | 604 | | { |
| 0 | 605 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 606 | | } |
| 0 | 607 | | if (connectionMonitorName == null) |
| | 608 | | { |
| 0 | 609 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 610 | | } |
| | 611 | |
|
| 0 | 612 | | using var message = CreateStartRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 613 | | _pipeline.Send(message, cancellationToken); |
| 0 | 614 | | switch (message.Response.Status) |
| | 615 | | { |
| | 616 | | case 200: |
| | 617 | | case 202: |
| 0 | 618 | | return message.Response; |
| | 619 | | default: |
| 0 | 620 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 621 | | } |
| 0 | 622 | | } |
| | 623 | |
|
| | 624 | | internal HttpMessage CreateQueryRequest(string resourceGroupName, string networkWatcherName, string connectionMo |
| | 625 | | { |
| 0 | 626 | | var message = _pipeline.CreateMessage(); |
| 0 | 627 | | var request = message.Request; |
| 0 | 628 | | request.Method = RequestMethod.Post; |
| 0 | 629 | | var uri = new RawRequestUriBuilder(); |
| 0 | 630 | | uri.Reset(endpoint); |
| 0 | 631 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 632 | | uri.AppendPath(subscriptionId, true); |
| 0 | 633 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 634 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 635 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 636 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 637 | | uri.AppendPath("/connectionMonitors/", false); |
| 0 | 638 | | uri.AppendPath(connectionMonitorName, true); |
| 0 | 639 | | uri.AppendPath("/query", false); |
| 0 | 640 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 641 | | request.Uri = uri; |
| 0 | 642 | | return message; |
| | 643 | | } |
| | 644 | |
|
| | 645 | | /// <summary> Query a snapshot of the most recent connection states. </summary> |
| | 646 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 647 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 648 | | /// <param name="connectionMonitorName"> The name given to the connection monitor. </param> |
| | 649 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 650 | | public async Task<Response> QueryAsync(string resourceGroupName, string networkWatcherName, string connectionMon |
| | 651 | | { |
| 0 | 652 | | if (resourceGroupName == null) |
| | 653 | | { |
| 0 | 654 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 655 | | } |
| 0 | 656 | | if (networkWatcherName == null) |
| | 657 | | { |
| 0 | 658 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 659 | | } |
| 0 | 660 | | if (connectionMonitorName == null) |
| | 661 | | { |
| 0 | 662 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 663 | | } |
| | 664 | |
|
| 0 | 665 | | using var message = CreateQueryRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 666 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 667 | | switch (message.Response.Status) |
| | 668 | | { |
| | 669 | | case 200: |
| | 670 | | case 202: |
| 0 | 671 | | return message.Response; |
| | 672 | | default: |
| 0 | 673 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 674 | | } |
| 0 | 675 | | } |
| | 676 | |
|
| | 677 | | /// <summary> Query a snapshot of the most recent connection states. </summary> |
| | 678 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 679 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 680 | | /// <param name="connectionMonitorName"> The name given to the connection monitor. </param> |
| | 681 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 682 | | public Response Query(string resourceGroupName, string networkWatcherName, string connectionMonitorName, Cancell |
| | 683 | | { |
| 0 | 684 | | if (resourceGroupName == null) |
| | 685 | | { |
| 0 | 686 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 687 | | } |
| 0 | 688 | | if (networkWatcherName == null) |
| | 689 | | { |
| 0 | 690 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 691 | | } |
| 0 | 692 | | if (connectionMonitorName == null) |
| | 693 | | { |
| 0 | 694 | | throw new ArgumentNullException(nameof(connectionMonitorName)); |
| | 695 | | } |
| | 696 | |
|
| 0 | 697 | | using var message = CreateQueryRequest(resourceGroupName, networkWatcherName, connectionMonitorName); |
| 0 | 698 | | _pipeline.Send(message, cancellationToken); |
| 0 | 699 | | switch (message.Response.Status) |
| | 700 | | { |
| | 701 | | case 200: |
| | 702 | | case 202: |
| 0 | 703 | | return message.Response; |
| | 704 | | default: |
| 0 | 705 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 706 | | } |
| 0 | 707 | | } |
| | 708 | |
|
| | 709 | | internal HttpMessage CreateListRequest(string resourceGroupName, string networkWatcherName) |
| | 710 | | { |
| 0 | 711 | | var message = _pipeline.CreateMessage(); |
| 0 | 712 | | var request = message.Request; |
| 0 | 713 | | request.Method = RequestMethod.Get; |
| 0 | 714 | | var uri = new RawRequestUriBuilder(); |
| 0 | 715 | | uri.Reset(endpoint); |
| 0 | 716 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 717 | | uri.AppendPath(subscriptionId, true); |
| 0 | 718 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 719 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 720 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 721 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 722 | | uri.AppendPath("/connectionMonitors", false); |
| 0 | 723 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 724 | | request.Uri = uri; |
| 0 | 725 | | return message; |
| | 726 | | } |
| | 727 | |
|
| | 728 | | /// <summary> Lists all connection monitors for the specified Network Watcher. </summary> |
| | 729 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 730 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 731 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 732 | | public async Task<Response<ConnectionMonitorListResult>> ListAsync(string resourceGroupName, string networkWatch |
| | 733 | | { |
| 0 | 734 | | if (resourceGroupName == null) |
| | 735 | | { |
| 0 | 736 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 737 | | } |
| 0 | 738 | | if (networkWatcherName == null) |
| | 739 | | { |
| 0 | 740 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 741 | | } |
| | 742 | |
|
| 0 | 743 | | using var message = CreateListRequest(resourceGroupName, networkWatcherName); |
| 0 | 744 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 745 | | switch (message.Response.Status) |
| | 746 | | { |
| | 747 | | case 200: |
| | 748 | | { |
| 0 | 749 | | ConnectionMonitorListResult value = default; |
| 0 | 750 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 751 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 752 | | { |
| 0 | 753 | | value = null; |
| | 754 | | } |
| | 755 | | else |
| | 756 | | { |
| 0 | 757 | | value = ConnectionMonitorListResult.DeserializeConnectionMonitorListResult(document.RootElem |
| | 758 | | } |
| 0 | 759 | | return Response.FromValue(value, message.Response); |
| | 760 | | } |
| | 761 | | default: |
| 0 | 762 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 763 | | } |
| 0 | 764 | | } |
| | 765 | |
|
| | 766 | | /// <summary> Lists all connection monitors for the specified Network Watcher. </summary> |
| | 767 | | /// <param name="resourceGroupName"> The name of the resource group containing Network Watcher. </param> |
| | 768 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 769 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 770 | | public Response<ConnectionMonitorListResult> List(string resourceGroupName, string networkWatcherName, Cancellat |
| | 771 | | { |
| 0 | 772 | | if (resourceGroupName == null) |
| | 773 | | { |
| 0 | 774 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 775 | | } |
| 0 | 776 | | if (networkWatcherName == null) |
| | 777 | | { |
| 0 | 778 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 779 | | } |
| | 780 | |
|
| 0 | 781 | | using var message = CreateListRequest(resourceGroupName, networkWatcherName); |
| 0 | 782 | | _pipeline.Send(message, cancellationToken); |
| 0 | 783 | | switch (message.Response.Status) |
| | 784 | | { |
| | 785 | | case 200: |
| | 786 | | { |
| 0 | 787 | | ConnectionMonitorListResult value = default; |
| 0 | 788 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 789 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 790 | | { |
| 0 | 791 | | value = null; |
| | 792 | | } |
| | 793 | | else |
| | 794 | | { |
| 0 | 795 | | value = ConnectionMonitorListResult.DeserializeConnectionMonitorListResult(document.RootElem |
| | 796 | | } |
| 0 | 797 | | return Response.FromValue(value, message.Response); |
| | 798 | | } |
| | 799 | | default: |
| 0 | 800 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 801 | | } |
| 0 | 802 | | } |
| | 803 | | } |
| | 804 | | } |