| | 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 NetworkWatchersRestOperations |
| | 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 NetworkWatchersRestOperations. </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 |
| 40 | 32 | | public NetworkWatchersRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip |
| | 33 | | { |
| 40 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 40 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 40 | 40 | | this.subscriptionId = subscriptionId; |
| 40 | 41 | | this.endpoint = endpoint; |
| 40 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 40 | 43 | | _pipeline = pipeline; |
| 40 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string networkWatcherName, NetworkWat |
| | 47 | | { |
| 4 | 48 | | var message = _pipeline.CreateMessage(); |
| 4 | 49 | | var request = message.Request; |
| 4 | 50 | | request.Method = RequestMethod.Put; |
| 4 | 51 | | var uri = new RawRequestUriBuilder(); |
| 4 | 52 | | uri.Reset(endpoint); |
| 4 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 54 | | uri.AppendPath(subscriptionId, true); |
| 4 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 57 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 4 | 58 | | uri.AppendPath(networkWatcherName, true); |
| 4 | 59 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 60 | | request.Uri = uri; |
| 4 | 61 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 62 | | var content = new Utf8JsonRequestContent(); |
| 4 | 63 | | content.JsonWriter.WriteObjectValue(parameters); |
| 4 | 64 | | request.Content = content; |
| 4 | 65 | | return message; |
| | 66 | | } |
| | 67 | |
|
| | 68 | | /// <summary> Creates or updates a network watcher in the specified resource group. </summary> |
| | 69 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 70 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 71 | | /// <param name="parameters"> Parameters that define the network watcher resource. </param> |
| | 72 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 73 | | public async Task<Response<NetworkWatcher>> CreateOrUpdateAsync(string resourceGroupName, string networkWatcherN |
| | 74 | | { |
| 2 | 75 | | if (resourceGroupName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 78 | | } |
| 2 | 79 | | if (networkWatcherName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 82 | | } |
| 2 | 83 | | if (parameters == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(parameters)); |
| | 86 | | } |
| | 87 | |
|
| 2 | 88 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, parameters); |
| 2 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | case 201: |
| | 94 | | { |
| 2 | 95 | | NetworkWatcher value = default; |
| 2 | 96 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 97 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 98 | | { |
| 0 | 99 | | value = null; |
| | 100 | | } |
| | 101 | | else |
| | 102 | | { |
| 2 | 103 | | value = NetworkWatcher.DeserializeNetworkWatcher(document.RootElement); |
| | 104 | | } |
| 2 | 105 | | return Response.FromValue(value, message.Response); |
| | 106 | | } |
| | 107 | | default: |
| 0 | 108 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 109 | | } |
| 2 | 110 | | } |
| | 111 | |
|
| | 112 | | /// <summary> Creates or updates a network watcher in the specified resource group. </summary> |
| | 113 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 114 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 115 | | /// <param name="parameters"> Parameters that define the network watcher resource. </param> |
| | 116 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 117 | | public Response<NetworkWatcher> CreateOrUpdate(string resourceGroupName, string networkWatcherName, NetworkWatch |
| | 118 | | { |
| 2 | 119 | | if (resourceGroupName == null) |
| | 120 | | { |
| 0 | 121 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 122 | | } |
| 2 | 123 | | if (networkWatcherName == null) |
| | 124 | | { |
| 0 | 125 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 126 | | } |
| 2 | 127 | | if (parameters == null) |
| | 128 | | { |
| 0 | 129 | | throw new ArgumentNullException(nameof(parameters)); |
| | 130 | | } |
| | 131 | |
|
| 2 | 132 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, networkWatcherName, parameters); |
| 2 | 133 | | _pipeline.Send(message, cancellationToken); |
| 2 | 134 | | switch (message.Response.Status) |
| | 135 | | { |
| | 136 | | case 200: |
| | 137 | | case 201: |
| | 138 | | { |
| 2 | 139 | | NetworkWatcher value = default; |
| 2 | 140 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 141 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 142 | | { |
| 0 | 143 | | value = null; |
| | 144 | | } |
| | 145 | | else |
| | 146 | | { |
| 2 | 147 | | value = NetworkWatcher.DeserializeNetworkWatcher(document.RootElement); |
| | 148 | | } |
| 2 | 149 | | return Response.FromValue(value, message.Response); |
| | 150 | | } |
| | 151 | | default: |
| 0 | 152 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 153 | | } |
| 2 | 154 | | } |
| | 155 | |
|
| | 156 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string networkWatcherName) |
| | 157 | | { |
| 4 | 158 | | var message = _pipeline.CreateMessage(); |
| 4 | 159 | | var request = message.Request; |
| 4 | 160 | | request.Method = RequestMethod.Get; |
| 4 | 161 | | var uri = new RawRequestUriBuilder(); |
| 4 | 162 | | uri.Reset(endpoint); |
| 4 | 163 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 164 | | uri.AppendPath(subscriptionId, true); |
| 4 | 165 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 166 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 167 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 4 | 168 | | uri.AppendPath(networkWatcherName, true); |
| 4 | 169 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 170 | | request.Uri = uri; |
| 4 | 171 | | return message; |
| | 172 | | } |
| | 173 | |
|
| | 174 | | /// <summary> Gets the specified network watcher by resource group. </summary> |
| | 175 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 176 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 177 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 178 | | public async Task<Response<NetworkWatcher>> GetAsync(string resourceGroupName, string networkWatcherName, Cancel |
| | 179 | | { |
| 2 | 180 | | if (resourceGroupName == null) |
| | 181 | | { |
| 0 | 182 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 183 | | } |
| 2 | 184 | | if (networkWatcherName == null) |
| | 185 | | { |
| 0 | 186 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 187 | | } |
| | 188 | |
|
| 2 | 189 | | using var message = CreateGetRequest(resourceGroupName, networkWatcherName); |
| 2 | 190 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 191 | | switch (message.Response.Status) |
| | 192 | | { |
| | 193 | | case 200: |
| | 194 | | { |
| 2 | 195 | | NetworkWatcher value = default; |
| 2 | 196 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 197 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 198 | | { |
| 0 | 199 | | value = null; |
| | 200 | | } |
| | 201 | | else |
| | 202 | | { |
| 2 | 203 | | value = NetworkWatcher.DeserializeNetworkWatcher(document.RootElement); |
| | 204 | | } |
| 2 | 205 | | return Response.FromValue(value, message.Response); |
| | 206 | | } |
| | 207 | | default: |
| 0 | 208 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 209 | | } |
| 2 | 210 | | } |
| | 211 | |
|
| | 212 | | /// <summary> Gets the specified network watcher by resource group. </summary> |
| | 213 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 214 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 215 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 216 | | public Response<NetworkWatcher> Get(string resourceGroupName, string networkWatcherName, CancellationToken cance |
| | 217 | | { |
| 2 | 218 | | if (resourceGroupName == null) |
| | 219 | | { |
| 0 | 220 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 221 | | } |
| 2 | 222 | | if (networkWatcherName == null) |
| | 223 | | { |
| 0 | 224 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 225 | | } |
| | 226 | |
|
| 2 | 227 | | using var message = CreateGetRequest(resourceGroupName, networkWatcherName); |
| 2 | 228 | | _pipeline.Send(message, cancellationToken); |
| 2 | 229 | | switch (message.Response.Status) |
| | 230 | | { |
| | 231 | | case 200: |
| | 232 | | { |
| 2 | 233 | | NetworkWatcher value = default; |
| 2 | 234 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 235 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 236 | | { |
| 0 | 237 | | value = null; |
| | 238 | | } |
| | 239 | | else |
| | 240 | | { |
| 2 | 241 | | value = NetworkWatcher.DeserializeNetworkWatcher(document.RootElement); |
| | 242 | | } |
| 2 | 243 | | return Response.FromValue(value, message.Response); |
| | 244 | | } |
| | 245 | | default: |
| 0 | 246 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 247 | | } |
| 2 | 248 | | } |
| | 249 | |
|
| | 250 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string networkWatcherName) |
| | 251 | | { |
| 8 | 252 | | var message = _pipeline.CreateMessage(); |
| 8 | 253 | | var request = message.Request; |
| 8 | 254 | | request.Method = RequestMethod.Delete; |
| 8 | 255 | | var uri = new RawRequestUriBuilder(); |
| 8 | 256 | | uri.Reset(endpoint); |
| 8 | 257 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 258 | | uri.AppendPath(subscriptionId, true); |
| 8 | 259 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 260 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 261 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 8 | 262 | | uri.AppendPath(networkWatcherName, true); |
| 8 | 263 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 264 | | request.Uri = uri; |
| 8 | 265 | | return message; |
| | 266 | | } |
| | 267 | |
|
| | 268 | | /// <summary> Deletes the specified network watcher resource. </summary> |
| | 269 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 270 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 271 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 272 | | public async Task<Response> DeleteAsync(string resourceGroupName, string networkWatcherName, CancellationToken c |
| | 273 | | { |
| 2 | 274 | | if (resourceGroupName == null) |
| | 275 | | { |
| 0 | 276 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 277 | | } |
| 2 | 278 | | if (networkWatcherName == null) |
| | 279 | | { |
| 0 | 280 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 281 | | } |
| | 282 | |
|
| 2 | 283 | | using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName); |
| 2 | 284 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 285 | | switch (message.Response.Status) |
| | 286 | | { |
| | 287 | | case 202: |
| | 288 | | case 204: |
| 2 | 289 | | return message.Response; |
| | 290 | | default: |
| 0 | 291 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 292 | | } |
| 2 | 293 | | } |
| | 294 | |
|
| | 295 | | /// <summary> Deletes the specified network watcher resource. </summary> |
| | 296 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 297 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 298 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 299 | | public Response Delete(string resourceGroupName, string networkWatcherName, CancellationToken cancellationToken |
| | 300 | | { |
| 2 | 301 | | if (resourceGroupName == null) |
| | 302 | | { |
| 0 | 303 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 304 | | } |
| 2 | 305 | | if (networkWatcherName == null) |
| | 306 | | { |
| 0 | 307 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 308 | | } |
| | 309 | |
|
| 2 | 310 | | using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName); |
| 2 | 311 | | _pipeline.Send(message, cancellationToken); |
| 2 | 312 | | switch (message.Response.Status) |
| | 313 | | { |
| | 314 | | case 202: |
| | 315 | | case 204: |
| 2 | 316 | | return message.Response; |
| | 317 | | default: |
| 0 | 318 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 319 | | } |
| 2 | 320 | | } |
| | 321 | |
|
| | 322 | | internal HttpMessage CreateUpdateTagsRequest(string resourceGroupName, string networkWatcherName, TagsObject par |
| | 323 | | { |
| 0 | 324 | | var message = _pipeline.CreateMessage(); |
| 0 | 325 | | var request = message.Request; |
| 0 | 326 | | request.Method = RequestMethod.Patch; |
| 0 | 327 | | var uri = new RawRequestUriBuilder(); |
| 0 | 328 | | uri.Reset(endpoint); |
| 0 | 329 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 330 | | uri.AppendPath(subscriptionId, true); |
| 0 | 331 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 332 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 333 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 334 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 335 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 336 | | request.Uri = uri; |
| 0 | 337 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 338 | | var content = new Utf8JsonRequestContent(); |
| 0 | 339 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 340 | | request.Content = content; |
| 0 | 341 | | return message; |
| | 342 | | } |
| | 343 | |
|
| | 344 | | /// <summary> Updates a network watcher tags. </summary> |
| | 345 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 346 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 347 | | /// <param name="parameters"> Parameters supplied to update network watcher tags. </param> |
| | 348 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 349 | | public async Task<Response<NetworkWatcher>> UpdateTagsAsync(string resourceGroupName, string networkWatcherName, |
| | 350 | | { |
| 0 | 351 | | if (resourceGroupName == null) |
| | 352 | | { |
| 0 | 353 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 354 | | } |
| 0 | 355 | | if (networkWatcherName == null) |
| | 356 | | { |
| 0 | 357 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 358 | | } |
| 0 | 359 | | if (parameters == null) |
| | 360 | | { |
| 0 | 361 | | throw new ArgumentNullException(nameof(parameters)); |
| | 362 | | } |
| | 363 | |
|
| 0 | 364 | | using var message = CreateUpdateTagsRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 365 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 366 | | switch (message.Response.Status) |
| | 367 | | { |
| | 368 | | case 200: |
| | 369 | | { |
| 0 | 370 | | NetworkWatcher value = default; |
| 0 | 371 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 372 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 373 | | { |
| 0 | 374 | | value = null; |
| | 375 | | } |
| | 376 | | else |
| | 377 | | { |
| 0 | 378 | | value = NetworkWatcher.DeserializeNetworkWatcher(document.RootElement); |
| | 379 | | } |
| 0 | 380 | | return Response.FromValue(value, message.Response); |
| | 381 | | } |
| | 382 | | default: |
| 0 | 383 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 384 | | } |
| 0 | 385 | | } |
| | 386 | |
|
| | 387 | | /// <summary> Updates a network watcher tags. </summary> |
| | 388 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 389 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 390 | | /// <param name="parameters"> Parameters supplied to update network watcher tags. </param> |
| | 391 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 392 | | public Response<NetworkWatcher> UpdateTags(string resourceGroupName, string networkWatcherName, TagsObject param |
| | 393 | | { |
| 0 | 394 | | if (resourceGroupName == null) |
| | 395 | | { |
| 0 | 396 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 397 | | } |
| 0 | 398 | | if (networkWatcherName == null) |
| | 399 | | { |
| 0 | 400 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 401 | | } |
| 0 | 402 | | if (parameters == null) |
| | 403 | | { |
| 0 | 404 | | throw new ArgumentNullException(nameof(parameters)); |
| | 405 | | } |
| | 406 | |
|
| 0 | 407 | | using var message = CreateUpdateTagsRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 408 | | _pipeline.Send(message, cancellationToken); |
| 0 | 409 | | switch (message.Response.Status) |
| | 410 | | { |
| | 411 | | case 200: |
| | 412 | | { |
| 0 | 413 | | NetworkWatcher value = default; |
| 0 | 414 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 415 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 416 | | { |
| 0 | 417 | | value = null; |
| | 418 | | } |
| | 419 | | else |
| | 420 | | { |
| 0 | 421 | | value = NetworkWatcher.DeserializeNetworkWatcher(document.RootElement); |
| | 422 | | } |
| 0 | 423 | | return Response.FromValue(value, message.Response); |
| | 424 | | } |
| | 425 | | default: |
| 0 | 426 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 427 | | } |
| 0 | 428 | | } |
| | 429 | |
|
| | 430 | | internal HttpMessage CreateListRequest(string resourceGroupName) |
| | 431 | | { |
| 4 | 432 | | var message = _pipeline.CreateMessage(); |
| 4 | 433 | | var request = message.Request; |
| 4 | 434 | | request.Method = RequestMethod.Get; |
| 4 | 435 | | var uri = new RawRequestUriBuilder(); |
| 4 | 436 | | uri.Reset(endpoint); |
| 4 | 437 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 438 | | uri.AppendPath(subscriptionId, true); |
| 4 | 439 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 440 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 441 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers", false); |
| 4 | 442 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 443 | | request.Uri = uri; |
| 4 | 444 | | return message; |
| | 445 | | } |
| | 446 | |
|
| | 447 | | /// <summary> Gets all network watchers by resource group. </summary> |
| | 448 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 449 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 450 | | public async Task<Response<NetworkWatcherListResult>> ListAsync(string resourceGroupName, CancellationToken canc |
| | 451 | | { |
| 2 | 452 | | if (resourceGroupName == null) |
| | 453 | | { |
| 0 | 454 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 455 | | } |
| | 456 | |
|
| 2 | 457 | | using var message = CreateListRequest(resourceGroupName); |
| 2 | 458 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 459 | | switch (message.Response.Status) |
| | 460 | | { |
| | 461 | | case 200: |
| | 462 | | { |
| 2 | 463 | | NetworkWatcherListResult value = default; |
| 2 | 464 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 465 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 466 | | { |
| 0 | 467 | | value = null; |
| | 468 | | } |
| | 469 | | else |
| | 470 | | { |
| 2 | 471 | | value = NetworkWatcherListResult.DeserializeNetworkWatcherListResult(document.RootElement); |
| | 472 | | } |
| 2 | 473 | | return Response.FromValue(value, message.Response); |
| | 474 | | } |
| | 475 | | default: |
| 0 | 476 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 477 | | } |
| 2 | 478 | | } |
| | 479 | |
|
| | 480 | | /// <summary> Gets all network watchers by resource group. </summary> |
| | 481 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 482 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 483 | | public Response<NetworkWatcherListResult> List(string resourceGroupName, CancellationToken cancellationToken = d |
| | 484 | | { |
| 2 | 485 | | if (resourceGroupName == null) |
| | 486 | | { |
| 0 | 487 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 488 | | } |
| | 489 | |
|
| 2 | 490 | | using var message = CreateListRequest(resourceGroupName); |
| 2 | 491 | | _pipeline.Send(message, cancellationToken); |
| 2 | 492 | | switch (message.Response.Status) |
| | 493 | | { |
| | 494 | | case 200: |
| | 495 | | { |
| 2 | 496 | | NetworkWatcherListResult value = default; |
| 2 | 497 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 498 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 499 | | { |
| 0 | 500 | | value = null; |
| | 501 | | } |
| | 502 | | else |
| | 503 | | { |
| 2 | 504 | | value = NetworkWatcherListResult.DeserializeNetworkWatcherListResult(document.RootElement); |
| | 505 | | } |
| 2 | 506 | | return Response.FromValue(value, message.Response); |
| | 507 | | } |
| | 508 | | default: |
| 0 | 509 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 510 | | } |
| 2 | 511 | | } |
| | 512 | |
|
| | 513 | | internal HttpMessage CreateListAllRequest() |
| | 514 | | { |
| 8 | 515 | | var message = _pipeline.CreateMessage(); |
| 8 | 516 | | var request = message.Request; |
| 8 | 517 | | request.Method = RequestMethod.Get; |
| 8 | 518 | | var uri = new RawRequestUriBuilder(); |
| 8 | 519 | | uri.Reset(endpoint); |
| 8 | 520 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 521 | | uri.AppendPath(subscriptionId, true); |
| 8 | 522 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers", false); |
| 8 | 523 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 524 | | request.Uri = uri; |
| 8 | 525 | | return message; |
| | 526 | | } |
| | 527 | |
|
| | 528 | | /// <summary> Gets all network watchers by subscription. </summary> |
| | 529 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 530 | | public async Task<Response<NetworkWatcherListResult>> ListAllAsync(CancellationToken cancellationToken = default |
| | 531 | | { |
| 4 | 532 | | using var message = CreateListAllRequest(); |
| 4 | 533 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 534 | | switch (message.Response.Status) |
| | 535 | | { |
| | 536 | | case 200: |
| | 537 | | { |
| 4 | 538 | | NetworkWatcherListResult value = default; |
| 4 | 539 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 540 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 541 | | { |
| 0 | 542 | | value = null; |
| | 543 | | } |
| | 544 | | else |
| | 545 | | { |
| 4 | 546 | | value = NetworkWatcherListResult.DeserializeNetworkWatcherListResult(document.RootElement); |
| | 547 | | } |
| 4 | 548 | | return Response.FromValue(value, message.Response); |
| | 549 | | } |
| | 550 | | default: |
| 0 | 551 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 552 | | } |
| 4 | 553 | | } |
| | 554 | |
|
| | 555 | | /// <summary> Gets all network watchers by subscription. </summary> |
| | 556 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 557 | | public Response<NetworkWatcherListResult> ListAll(CancellationToken cancellationToken = default) |
| | 558 | | { |
| 4 | 559 | | using var message = CreateListAllRequest(); |
| 4 | 560 | | _pipeline.Send(message, cancellationToken); |
| 4 | 561 | | switch (message.Response.Status) |
| | 562 | | { |
| | 563 | | case 200: |
| | 564 | | { |
| 4 | 565 | | NetworkWatcherListResult value = default; |
| 4 | 566 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 567 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 568 | | { |
| 0 | 569 | | value = null; |
| | 570 | | } |
| | 571 | | else |
| | 572 | | { |
| 4 | 573 | | value = NetworkWatcherListResult.DeserializeNetworkWatcherListResult(document.RootElement); |
| | 574 | | } |
| 4 | 575 | | return Response.FromValue(value, message.Response); |
| | 576 | | } |
| | 577 | | default: |
| 0 | 578 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 579 | | } |
| 4 | 580 | | } |
| | 581 | |
|
| | 582 | | internal HttpMessage CreateGetTopologyRequest(string resourceGroupName, string networkWatcherName, TopologyParam |
| | 583 | | { |
| 4 | 584 | | var message = _pipeline.CreateMessage(); |
| 4 | 585 | | var request = message.Request; |
| 4 | 586 | | request.Method = RequestMethod.Post; |
| 4 | 587 | | var uri = new RawRequestUriBuilder(); |
| 4 | 588 | | uri.Reset(endpoint); |
| 4 | 589 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 590 | | uri.AppendPath(subscriptionId, true); |
| 4 | 591 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 592 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 593 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 4 | 594 | | uri.AppendPath(networkWatcherName, true); |
| 4 | 595 | | uri.AppendPath("/topology", false); |
| 4 | 596 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 597 | | request.Uri = uri; |
| 4 | 598 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 599 | | var content = new Utf8JsonRequestContent(); |
| 4 | 600 | | content.JsonWriter.WriteObjectValue(parameters); |
| 4 | 601 | | request.Content = content; |
| 4 | 602 | | return message; |
| | 603 | | } |
| | 604 | |
|
| | 605 | | /// <summary> Gets the current network topology by resource group. </summary> |
| | 606 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 607 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 608 | | /// <param name="parameters"> Parameters that define the representation of topology. </param> |
| | 609 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 610 | | public async Task<Response<Topology>> GetTopologyAsync(string resourceGroupName, string networkWatcherName, Topo |
| | 611 | | { |
| 2 | 612 | | if (resourceGroupName == null) |
| | 613 | | { |
| 0 | 614 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 615 | | } |
| 2 | 616 | | if (networkWatcherName == null) |
| | 617 | | { |
| 0 | 618 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 619 | | } |
| 2 | 620 | | if (parameters == null) |
| | 621 | | { |
| 0 | 622 | | throw new ArgumentNullException(nameof(parameters)); |
| | 623 | | } |
| | 624 | |
|
| 2 | 625 | | using var message = CreateGetTopologyRequest(resourceGroupName, networkWatcherName, parameters); |
| 2 | 626 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 627 | | switch (message.Response.Status) |
| | 628 | | { |
| | 629 | | case 200: |
| | 630 | | { |
| 2 | 631 | | Topology value = default; |
| 2 | 632 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 633 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 634 | | { |
| 0 | 635 | | value = null; |
| | 636 | | } |
| | 637 | | else |
| | 638 | | { |
| 2 | 639 | | value = Topology.DeserializeTopology(document.RootElement); |
| | 640 | | } |
| 2 | 641 | | return Response.FromValue(value, message.Response); |
| | 642 | | } |
| | 643 | | default: |
| 0 | 644 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 645 | | } |
| 2 | 646 | | } |
| | 647 | |
|
| | 648 | | /// <summary> Gets the current network topology by resource group. </summary> |
| | 649 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 650 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 651 | | /// <param name="parameters"> Parameters that define the representation of topology. </param> |
| | 652 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 653 | | public Response<Topology> GetTopology(string resourceGroupName, string networkWatcherName, TopologyParameters pa |
| | 654 | | { |
| 2 | 655 | | if (resourceGroupName == null) |
| | 656 | | { |
| 0 | 657 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 658 | | } |
| 2 | 659 | | if (networkWatcherName == null) |
| | 660 | | { |
| 0 | 661 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 662 | | } |
| 2 | 663 | | if (parameters == null) |
| | 664 | | { |
| 0 | 665 | | throw new ArgumentNullException(nameof(parameters)); |
| | 666 | | } |
| | 667 | |
|
| 2 | 668 | | using var message = CreateGetTopologyRequest(resourceGroupName, networkWatcherName, parameters); |
| 2 | 669 | | _pipeline.Send(message, cancellationToken); |
| 2 | 670 | | switch (message.Response.Status) |
| | 671 | | { |
| | 672 | | case 200: |
| | 673 | | { |
| 2 | 674 | | Topology value = default; |
| 2 | 675 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 676 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 677 | | { |
| 0 | 678 | | value = null; |
| | 679 | | } |
| | 680 | | else |
| | 681 | | { |
| 2 | 682 | | value = Topology.DeserializeTopology(document.RootElement); |
| | 683 | | } |
| 2 | 684 | | return Response.FromValue(value, message.Response); |
| | 685 | | } |
| | 686 | | default: |
| 0 | 687 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 688 | | } |
| 2 | 689 | | } |
| | 690 | |
|
| | 691 | | internal HttpMessage CreateVerifyIPFlowRequest(string resourceGroupName, string networkWatcherName, Verification |
| | 692 | | { |
| 0 | 693 | | var message = _pipeline.CreateMessage(); |
| 0 | 694 | | var request = message.Request; |
| 0 | 695 | | request.Method = RequestMethod.Post; |
| 0 | 696 | | var uri = new RawRequestUriBuilder(); |
| 0 | 697 | | uri.Reset(endpoint); |
| 0 | 698 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 699 | | uri.AppendPath(subscriptionId, true); |
| 0 | 700 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 701 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 702 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 703 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 704 | | uri.AppendPath("/ipFlowVerify", false); |
| 0 | 705 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 706 | | request.Uri = uri; |
| 0 | 707 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 708 | | var content = new Utf8JsonRequestContent(); |
| 0 | 709 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 710 | | request.Content = content; |
| 0 | 711 | | return message; |
| | 712 | | } |
| | 713 | |
|
| | 714 | | /// <summary> Verify IP flow from the specified VM to a location given the currently configured NSG rules. </sum |
| | 715 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 716 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 717 | | /// <param name="parameters"> Parameters that define the IP flow to be verified. </param> |
| | 718 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 719 | | public async Task<Response> VerifyIPFlowAsync(string resourceGroupName, string networkWatcherName, VerificationI |
| | 720 | | { |
| 0 | 721 | | if (resourceGroupName == null) |
| | 722 | | { |
| 0 | 723 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 724 | | } |
| 0 | 725 | | if (networkWatcherName == null) |
| | 726 | | { |
| 0 | 727 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 728 | | } |
| 0 | 729 | | if (parameters == null) |
| | 730 | | { |
| 0 | 731 | | throw new ArgumentNullException(nameof(parameters)); |
| | 732 | | } |
| | 733 | |
|
| 0 | 734 | | using var message = CreateVerifyIPFlowRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 735 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 736 | | switch (message.Response.Status) |
| | 737 | | { |
| | 738 | | case 200: |
| | 739 | | case 202: |
| 0 | 740 | | return message.Response; |
| | 741 | | default: |
| 0 | 742 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 743 | | } |
| 0 | 744 | | } |
| | 745 | |
|
| | 746 | | /// <summary> Verify IP flow from the specified VM to a location given the currently configured NSG rules. </sum |
| | 747 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 748 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 749 | | /// <param name="parameters"> Parameters that define the IP flow to be verified. </param> |
| | 750 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 751 | | public Response VerifyIPFlow(string resourceGroupName, string networkWatcherName, VerificationIPFlowParameters p |
| | 752 | | { |
| 0 | 753 | | if (resourceGroupName == null) |
| | 754 | | { |
| 0 | 755 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 756 | | } |
| 0 | 757 | | if (networkWatcherName == null) |
| | 758 | | { |
| 0 | 759 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 760 | | } |
| 0 | 761 | | if (parameters == null) |
| | 762 | | { |
| 0 | 763 | | throw new ArgumentNullException(nameof(parameters)); |
| | 764 | | } |
| | 765 | |
|
| 0 | 766 | | using var message = CreateVerifyIPFlowRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 767 | | _pipeline.Send(message, cancellationToken); |
| 0 | 768 | | switch (message.Response.Status) |
| | 769 | | { |
| | 770 | | case 200: |
| | 771 | | case 202: |
| 0 | 772 | | return message.Response; |
| | 773 | | default: |
| 0 | 774 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 775 | | } |
| 0 | 776 | | } |
| | 777 | |
|
| | 778 | | internal HttpMessage CreateGetNextHopRequest(string resourceGroupName, string networkWatcherName, NextHopParamet |
| | 779 | | { |
| 16 | 780 | | var message = _pipeline.CreateMessage(); |
| 16 | 781 | | var request = message.Request; |
| 16 | 782 | | request.Method = RequestMethod.Post; |
| 16 | 783 | | var uri = new RawRequestUriBuilder(); |
| 16 | 784 | | uri.Reset(endpoint); |
| 16 | 785 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 786 | | uri.AppendPath(subscriptionId, true); |
| 16 | 787 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 788 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 789 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 16 | 790 | | uri.AppendPath(networkWatcherName, true); |
| 16 | 791 | | uri.AppendPath("/nextHop", false); |
| 16 | 792 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 16 | 793 | | request.Uri = uri; |
| 16 | 794 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 795 | | var content = new Utf8JsonRequestContent(); |
| 16 | 796 | | content.JsonWriter.WriteObjectValue(parameters); |
| 16 | 797 | | request.Content = content; |
| 16 | 798 | | return message; |
| | 799 | | } |
| | 800 | |
|
| | 801 | | /// <summary> Gets the next hop from the specified VM. </summary> |
| | 802 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 803 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 804 | | /// <param name="parameters"> Parameters that define the source and destination endpoint. </param> |
| | 805 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 806 | | public async Task<Response> GetNextHopAsync(string resourceGroupName, string networkWatcherName, NextHopParamete |
| | 807 | | { |
| 4 | 808 | | if (resourceGroupName == null) |
| | 809 | | { |
| 0 | 810 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 811 | | } |
| 4 | 812 | | if (networkWatcherName == null) |
| | 813 | | { |
| 0 | 814 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 815 | | } |
| 4 | 816 | | if (parameters == null) |
| | 817 | | { |
| 0 | 818 | | throw new ArgumentNullException(nameof(parameters)); |
| | 819 | | } |
| | 820 | |
|
| 4 | 821 | | using var message = CreateGetNextHopRequest(resourceGroupName, networkWatcherName, parameters); |
| 4 | 822 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 823 | | switch (message.Response.Status) |
| | 824 | | { |
| | 825 | | case 200: |
| | 826 | | case 202: |
| 4 | 827 | | return message.Response; |
| | 828 | | default: |
| 0 | 829 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 830 | | } |
| 4 | 831 | | } |
| | 832 | |
|
| | 833 | | /// <summary> Gets the next hop from the specified VM. </summary> |
| | 834 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 835 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 836 | | /// <param name="parameters"> Parameters that define the source and destination endpoint. </param> |
| | 837 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 838 | | public Response GetNextHop(string resourceGroupName, string networkWatcherName, NextHopParameters parameters, Ca |
| | 839 | | { |
| 4 | 840 | | if (resourceGroupName == null) |
| | 841 | | { |
| 0 | 842 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 843 | | } |
| 4 | 844 | | if (networkWatcherName == null) |
| | 845 | | { |
| 0 | 846 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 847 | | } |
| 4 | 848 | | if (parameters == null) |
| | 849 | | { |
| 0 | 850 | | throw new ArgumentNullException(nameof(parameters)); |
| | 851 | | } |
| | 852 | |
|
| 4 | 853 | | using var message = CreateGetNextHopRequest(resourceGroupName, networkWatcherName, parameters); |
| 4 | 854 | | _pipeline.Send(message, cancellationToken); |
| 4 | 855 | | switch (message.Response.Status) |
| | 856 | | { |
| | 857 | | case 200: |
| | 858 | | case 202: |
| 4 | 859 | | return message.Response; |
| | 860 | | default: |
| 0 | 861 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 862 | | } |
| 4 | 863 | | } |
| | 864 | |
|
| | 865 | | internal HttpMessage CreateGetVMSecurityRulesRequest(string resourceGroupName, string networkWatcherName, Securi |
| | 866 | | { |
| 0 | 867 | | var message = _pipeline.CreateMessage(); |
| 0 | 868 | | var request = message.Request; |
| 0 | 869 | | request.Method = RequestMethod.Post; |
| 0 | 870 | | var uri = new RawRequestUriBuilder(); |
| 0 | 871 | | uri.Reset(endpoint); |
| 0 | 872 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 873 | | uri.AppendPath(subscriptionId, true); |
| 0 | 874 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 875 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 876 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 877 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 878 | | uri.AppendPath("/securityGroupView", false); |
| 0 | 879 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 880 | | request.Uri = uri; |
| 0 | 881 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 882 | | var content = new Utf8JsonRequestContent(); |
| 0 | 883 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 884 | | request.Content = content; |
| 0 | 885 | | return message; |
| | 886 | | } |
| | 887 | |
|
| | 888 | | /// <summary> Gets the configured and effective security group rules on the specified VM. </summary> |
| | 889 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 890 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 891 | | /// <param name="parameters"> Parameters that define the VM to check security groups for. </param> |
| | 892 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 893 | | public async Task<Response> GetVMSecurityRulesAsync(string resourceGroupName, string networkWatcherName, Securit |
| | 894 | | { |
| 0 | 895 | | if (resourceGroupName == null) |
| | 896 | | { |
| 0 | 897 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 898 | | } |
| 0 | 899 | | if (networkWatcherName == null) |
| | 900 | | { |
| 0 | 901 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 902 | | } |
| 0 | 903 | | if (parameters == null) |
| | 904 | | { |
| 0 | 905 | | throw new ArgumentNullException(nameof(parameters)); |
| | 906 | | } |
| | 907 | |
|
| 0 | 908 | | using var message = CreateGetVMSecurityRulesRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 909 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 910 | | switch (message.Response.Status) |
| | 911 | | { |
| | 912 | | case 200: |
| | 913 | | case 202: |
| 0 | 914 | | return message.Response; |
| | 915 | | default: |
| 0 | 916 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 917 | | } |
| 0 | 918 | | } |
| | 919 | |
|
| | 920 | | /// <summary> Gets the configured and effective security group rules on the specified VM. </summary> |
| | 921 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 922 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 923 | | /// <param name="parameters"> Parameters that define the VM to check security groups for. </param> |
| | 924 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 925 | | public Response GetVMSecurityRules(string resourceGroupName, string networkWatcherName, SecurityGroupViewParamet |
| | 926 | | { |
| 0 | 927 | | if (resourceGroupName == null) |
| | 928 | | { |
| 0 | 929 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 930 | | } |
| 0 | 931 | | if (networkWatcherName == null) |
| | 932 | | { |
| 0 | 933 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 934 | | } |
| 0 | 935 | | if (parameters == null) |
| | 936 | | { |
| 0 | 937 | | throw new ArgumentNullException(nameof(parameters)); |
| | 938 | | } |
| | 939 | |
|
| 0 | 940 | | using var message = CreateGetVMSecurityRulesRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 941 | | _pipeline.Send(message, cancellationToken); |
| 0 | 942 | | switch (message.Response.Status) |
| | 943 | | { |
| | 944 | | case 200: |
| | 945 | | case 202: |
| 0 | 946 | | return message.Response; |
| | 947 | | default: |
| 0 | 948 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 949 | | } |
| 0 | 950 | | } |
| | 951 | |
|
| | 952 | | internal HttpMessage CreateGetTroubleshootingRequest(string resourceGroupName, string networkWatcherName, Troubl |
| | 953 | | { |
| 0 | 954 | | var message = _pipeline.CreateMessage(); |
| 0 | 955 | | var request = message.Request; |
| 0 | 956 | | request.Method = RequestMethod.Post; |
| 0 | 957 | | var uri = new RawRequestUriBuilder(); |
| 0 | 958 | | uri.Reset(endpoint); |
| 0 | 959 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 960 | | uri.AppendPath(subscriptionId, true); |
| 0 | 961 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 962 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 963 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 964 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 965 | | uri.AppendPath("/troubleshoot", false); |
| 0 | 966 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 967 | | request.Uri = uri; |
| 0 | 968 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 969 | | var content = new Utf8JsonRequestContent(); |
| 0 | 970 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 971 | | request.Content = content; |
| 0 | 972 | | return message; |
| | 973 | | } |
| | 974 | |
|
| | 975 | | /// <summary> Initiate troubleshooting on a specified resource. </summary> |
| | 976 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 977 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 978 | | /// <param name="parameters"> Parameters that define the resource to troubleshoot. </param> |
| | 979 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 980 | | public async Task<Response> GetTroubleshootingAsync(string resourceGroupName, string networkWatcherName, Trouble |
| | 981 | | { |
| 0 | 982 | | if (resourceGroupName == null) |
| | 983 | | { |
| 0 | 984 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 985 | | } |
| 0 | 986 | | if (networkWatcherName == null) |
| | 987 | | { |
| 0 | 988 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 989 | | } |
| 0 | 990 | | if (parameters == null) |
| | 991 | | { |
| 0 | 992 | | throw new ArgumentNullException(nameof(parameters)); |
| | 993 | | } |
| | 994 | |
|
| 0 | 995 | | using var message = CreateGetTroubleshootingRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 996 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 997 | | switch (message.Response.Status) |
| | 998 | | { |
| | 999 | | case 200: |
| | 1000 | | case 202: |
| 0 | 1001 | | return message.Response; |
| | 1002 | | default: |
| 0 | 1003 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1004 | | } |
| 0 | 1005 | | } |
| | 1006 | |
|
| | 1007 | | /// <summary> Initiate troubleshooting on a specified resource. </summary> |
| | 1008 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1009 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1010 | | /// <param name="parameters"> Parameters that define the resource to troubleshoot. </param> |
| | 1011 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1012 | | public Response GetTroubleshooting(string resourceGroupName, string networkWatcherName, TroubleshootingParameter |
| | 1013 | | { |
| 0 | 1014 | | if (resourceGroupName == null) |
| | 1015 | | { |
| 0 | 1016 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1017 | | } |
| 0 | 1018 | | if (networkWatcherName == null) |
| | 1019 | | { |
| 0 | 1020 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1021 | | } |
| 0 | 1022 | | if (parameters == null) |
| | 1023 | | { |
| 0 | 1024 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1025 | | } |
| | 1026 | |
|
| 0 | 1027 | | using var message = CreateGetTroubleshootingRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 1028 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1029 | | switch (message.Response.Status) |
| | 1030 | | { |
| | 1031 | | case 200: |
| | 1032 | | case 202: |
| 0 | 1033 | | return message.Response; |
| | 1034 | | default: |
| 0 | 1035 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1036 | | } |
| 0 | 1037 | | } |
| | 1038 | |
|
| | 1039 | | internal HttpMessage CreateGetTroubleshootingResultRequest(string resourceGroupName, string networkWatcherName, |
| | 1040 | | { |
| 0 | 1041 | | var message = _pipeline.CreateMessage(); |
| 0 | 1042 | | var request = message.Request; |
| 0 | 1043 | | request.Method = RequestMethod.Post; |
| 0 | 1044 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1045 | | uri.Reset(endpoint); |
| 0 | 1046 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1047 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1048 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1049 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1050 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 1051 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 1052 | | uri.AppendPath("/queryTroubleshootResult", false); |
| 0 | 1053 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 1054 | | request.Uri = uri; |
| 0 | 1055 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1056 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1057 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1058 | | request.Content = content; |
| 0 | 1059 | | return message; |
| | 1060 | | } |
| | 1061 | |
|
| | 1062 | | /// <summary> Get the last completed troubleshooting result on a specified resource. </summary> |
| | 1063 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1064 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1065 | | /// <param name="parameters"> Parameters that define the resource to query the troubleshooting result. </param> |
| | 1066 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1067 | | public async Task<Response> GetTroubleshootingResultAsync(string resourceGroupName, string networkWatcherName, Q |
| | 1068 | | { |
| 0 | 1069 | | if (resourceGroupName == null) |
| | 1070 | | { |
| 0 | 1071 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1072 | | } |
| 0 | 1073 | | if (networkWatcherName == null) |
| | 1074 | | { |
| 0 | 1075 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1076 | | } |
| 0 | 1077 | | if (parameters == null) |
| | 1078 | | { |
| 0 | 1079 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1080 | | } |
| | 1081 | |
|
| 0 | 1082 | | using var message = CreateGetTroubleshootingResultRequest(resourceGroupName, networkWatcherName, parameters) |
| 0 | 1083 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1084 | | switch (message.Response.Status) |
| | 1085 | | { |
| | 1086 | | case 200: |
| | 1087 | | case 202: |
| 0 | 1088 | | return message.Response; |
| | 1089 | | default: |
| 0 | 1090 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1091 | | } |
| 0 | 1092 | | } |
| | 1093 | |
|
| | 1094 | | /// <summary> Get the last completed troubleshooting result on a specified resource. </summary> |
| | 1095 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1096 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1097 | | /// <param name="parameters"> Parameters that define the resource to query the troubleshooting result. </param> |
| | 1098 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1099 | | public Response GetTroubleshootingResult(string resourceGroupName, string networkWatcherName, QueryTroubleshooti |
| | 1100 | | { |
| 0 | 1101 | | if (resourceGroupName == null) |
| | 1102 | | { |
| 0 | 1103 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1104 | | } |
| 0 | 1105 | | if (networkWatcherName == null) |
| | 1106 | | { |
| 0 | 1107 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1108 | | } |
| 0 | 1109 | | if (parameters == null) |
| | 1110 | | { |
| 0 | 1111 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1112 | | } |
| | 1113 | |
|
| 0 | 1114 | | using var message = CreateGetTroubleshootingResultRequest(resourceGroupName, networkWatcherName, parameters) |
| 0 | 1115 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1116 | | switch (message.Response.Status) |
| | 1117 | | { |
| | 1118 | | case 200: |
| | 1119 | | case 202: |
| 0 | 1120 | | return message.Response; |
| | 1121 | | default: |
| 0 | 1122 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1123 | | } |
| 0 | 1124 | | } |
| | 1125 | |
|
| | 1126 | | internal HttpMessage CreateSetFlowLogConfigurationRequest(string resourceGroupName, string networkWatcherName, F |
| | 1127 | | { |
| 0 | 1128 | | var message = _pipeline.CreateMessage(); |
| 0 | 1129 | | var request = message.Request; |
| 0 | 1130 | | request.Method = RequestMethod.Post; |
| 0 | 1131 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1132 | | uri.Reset(endpoint); |
| 0 | 1133 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1134 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1135 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1136 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1137 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 1138 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 1139 | | uri.AppendPath("/configureFlowLog", false); |
| 0 | 1140 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 1141 | | request.Uri = uri; |
| 0 | 1142 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1143 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1144 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1145 | | request.Content = content; |
| 0 | 1146 | | return message; |
| | 1147 | | } |
| | 1148 | |
|
| | 1149 | | /// <summary> Configures flow log and traffic analytics (optional) on a specified resource. </summary> |
| | 1150 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1151 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1152 | | /// <param name="parameters"> Parameters that define the configuration of flow log. </param> |
| | 1153 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1154 | | public async Task<Response> SetFlowLogConfigurationAsync(string resourceGroupName, string networkWatcherName, Fl |
| | 1155 | | { |
| 0 | 1156 | | if (resourceGroupName == null) |
| | 1157 | | { |
| 0 | 1158 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1159 | | } |
| 0 | 1160 | | if (networkWatcherName == null) |
| | 1161 | | { |
| 0 | 1162 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1163 | | } |
| 0 | 1164 | | if (parameters == null) |
| | 1165 | | { |
| 0 | 1166 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1167 | | } |
| | 1168 | |
|
| 0 | 1169 | | using var message = CreateSetFlowLogConfigurationRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 1170 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1171 | | switch (message.Response.Status) |
| | 1172 | | { |
| | 1173 | | case 200: |
| | 1174 | | case 202: |
| 0 | 1175 | | return message.Response; |
| | 1176 | | default: |
| 0 | 1177 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1178 | | } |
| 0 | 1179 | | } |
| | 1180 | |
|
| | 1181 | | /// <summary> Configures flow log and traffic analytics (optional) on a specified resource. </summary> |
| | 1182 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1183 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1184 | | /// <param name="parameters"> Parameters that define the configuration of flow log. </param> |
| | 1185 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1186 | | public Response SetFlowLogConfiguration(string resourceGroupName, string networkWatcherName, FlowLogInformation |
| | 1187 | | { |
| 0 | 1188 | | if (resourceGroupName == null) |
| | 1189 | | { |
| 0 | 1190 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1191 | | } |
| 0 | 1192 | | if (networkWatcherName == null) |
| | 1193 | | { |
| 0 | 1194 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1195 | | } |
| 0 | 1196 | | if (parameters == null) |
| | 1197 | | { |
| 0 | 1198 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1199 | | } |
| | 1200 | |
|
| 0 | 1201 | | using var message = CreateSetFlowLogConfigurationRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 1202 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1203 | | switch (message.Response.Status) |
| | 1204 | | { |
| | 1205 | | case 200: |
| | 1206 | | case 202: |
| 0 | 1207 | | return message.Response; |
| | 1208 | | default: |
| 0 | 1209 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1210 | | } |
| 0 | 1211 | | } |
| | 1212 | |
|
| | 1213 | | internal HttpMessage CreateGetFlowLogStatusRequest(string resourceGroupName, string networkWatcherName, FlowLogS |
| | 1214 | | { |
| 0 | 1215 | | var message = _pipeline.CreateMessage(); |
| 0 | 1216 | | var request = message.Request; |
| 0 | 1217 | | request.Method = RequestMethod.Post; |
| 0 | 1218 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1219 | | uri.Reset(endpoint); |
| 0 | 1220 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1221 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1222 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1223 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1224 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 1225 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 1226 | | uri.AppendPath("/queryFlowLogStatus", false); |
| 0 | 1227 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 1228 | | request.Uri = uri; |
| 0 | 1229 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1230 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1231 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1232 | | request.Content = content; |
| 0 | 1233 | | return message; |
| | 1234 | | } |
| | 1235 | |
|
| | 1236 | | /// <summary> Queries status of flow log and traffic analytics (optional) on a specified resource. </summary> |
| | 1237 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1238 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1239 | | /// <param name="parameters"> Parameters that define a resource to query flow log and traffic analytics (optiona |
| | 1240 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1241 | | public async Task<Response> GetFlowLogStatusAsync(string resourceGroupName, string networkWatcherName, FlowLogSt |
| | 1242 | | { |
| 0 | 1243 | | if (resourceGroupName == null) |
| | 1244 | | { |
| 0 | 1245 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1246 | | } |
| 0 | 1247 | | if (networkWatcherName == null) |
| | 1248 | | { |
| 0 | 1249 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1250 | | } |
| 0 | 1251 | | if (parameters == null) |
| | 1252 | | { |
| 0 | 1253 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1254 | | } |
| | 1255 | |
|
| 0 | 1256 | | using var message = CreateGetFlowLogStatusRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 1257 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1258 | | switch (message.Response.Status) |
| | 1259 | | { |
| | 1260 | | case 200: |
| | 1261 | | case 202: |
| 0 | 1262 | | return message.Response; |
| | 1263 | | default: |
| 0 | 1264 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1265 | | } |
| 0 | 1266 | | } |
| | 1267 | |
|
| | 1268 | | /// <summary> Queries status of flow log and traffic analytics (optional) on a specified resource. </summary> |
| | 1269 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1270 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1271 | | /// <param name="parameters"> Parameters that define a resource to query flow log and traffic analytics (optiona |
| | 1272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1273 | | public Response GetFlowLogStatus(string resourceGroupName, string networkWatcherName, FlowLogStatusParameters pa |
| | 1274 | | { |
| 0 | 1275 | | if (resourceGroupName == null) |
| | 1276 | | { |
| 0 | 1277 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1278 | | } |
| 0 | 1279 | | if (networkWatcherName == null) |
| | 1280 | | { |
| 0 | 1281 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1282 | | } |
| 0 | 1283 | | if (parameters == null) |
| | 1284 | | { |
| 0 | 1285 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1286 | | } |
| | 1287 | |
|
| 0 | 1288 | | using var message = CreateGetFlowLogStatusRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 1289 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1290 | | switch (message.Response.Status) |
| | 1291 | | { |
| | 1292 | | case 200: |
| | 1293 | | case 202: |
| 0 | 1294 | | return message.Response; |
| | 1295 | | default: |
| 0 | 1296 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1297 | | } |
| 0 | 1298 | | } |
| | 1299 | |
|
| | 1300 | | internal HttpMessage CreateCheckConnectivityRequest(string resourceGroupName, string networkWatcherName, Connect |
| | 1301 | | { |
| 8 | 1302 | | var message = _pipeline.CreateMessage(); |
| 8 | 1303 | | var request = message.Request; |
| 8 | 1304 | | request.Method = RequestMethod.Post; |
| 8 | 1305 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1306 | | uri.Reset(endpoint); |
| 8 | 1307 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 1308 | | uri.AppendPath(subscriptionId, true); |
| 8 | 1309 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 1310 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 1311 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 8 | 1312 | | uri.AppendPath(networkWatcherName, true); |
| 8 | 1313 | | uri.AppendPath("/connectivityCheck", false); |
| 8 | 1314 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 1315 | | request.Uri = uri; |
| 8 | 1316 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 1317 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1318 | | content.JsonWriter.WriteObjectValue(parameters); |
| 8 | 1319 | | request.Content = content; |
| 8 | 1320 | | return message; |
| | 1321 | | } |
| | 1322 | |
|
| | 1323 | | /// <summary> Verifies the possibility of establishing a direct TCP connection from a virtual machine to a given |
| | 1324 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1325 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1326 | | /// <param name="parameters"> Parameters that determine how the connectivity check will be performed. </param> |
| | 1327 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1328 | | public async Task<Response> CheckConnectivityAsync(string resourceGroupName, string networkWatcherName, Connecti |
| | 1329 | | { |
| 2 | 1330 | | if (resourceGroupName == null) |
| | 1331 | | { |
| 0 | 1332 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1333 | | } |
| 2 | 1334 | | if (networkWatcherName == null) |
| | 1335 | | { |
| 0 | 1336 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1337 | | } |
| 2 | 1338 | | if (parameters == null) |
| | 1339 | | { |
| 0 | 1340 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1341 | | } |
| | 1342 | |
|
| 2 | 1343 | | using var message = CreateCheckConnectivityRequest(resourceGroupName, networkWatcherName, parameters); |
| 2 | 1344 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1345 | | switch (message.Response.Status) |
| | 1346 | | { |
| | 1347 | | case 200: |
| | 1348 | | case 202: |
| 2 | 1349 | | return message.Response; |
| | 1350 | | default: |
| 0 | 1351 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1352 | | } |
| 2 | 1353 | | } |
| | 1354 | |
|
| | 1355 | | /// <summary> Verifies the possibility of establishing a direct TCP connection from a virtual machine to a given |
| | 1356 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1357 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1358 | | /// <param name="parameters"> Parameters that determine how the connectivity check will be performed. </param> |
| | 1359 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1360 | | public Response CheckConnectivity(string resourceGroupName, string networkWatcherName, ConnectivityParameters pa |
| | 1361 | | { |
| 2 | 1362 | | if (resourceGroupName == null) |
| | 1363 | | { |
| 0 | 1364 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1365 | | } |
| 2 | 1366 | | if (networkWatcherName == null) |
| | 1367 | | { |
| 0 | 1368 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1369 | | } |
| 2 | 1370 | | if (parameters == null) |
| | 1371 | | { |
| 0 | 1372 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1373 | | } |
| | 1374 | |
|
| 2 | 1375 | | using var message = CreateCheckConnectivityRequest(resourceGroupName, networkWatcherName, parameters); |
| 2 | 1376 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1377 | | switch (message.Response.Status) |
| | 1378 | | { |
| | 1379 | | case 200: |
| | 1380 | | case 202: |
| 2 | 1381 | | return message.Response; |
| | 1382 | | default: |
| 0 | 1383 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1384 | | } |
| 2 | 1385 | | } |
| | 1386 | |
|
| | 1387 | | internal HttpMessage CreateGetAzureReachabilityReportRequest(string resourceGroupName, string networkWatcherName |
| | 1388 | | { |
| 0 | 1389 | | var message = _pipeline.CreateMessage(); |
| 0 | 1390 | | var request = message.Request; |
| 0 | 1391 | | request.Method = RequestMethod.Post; |
| 0 | 1392 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1393 | | uri.Reset(endpoint); |
| 0 | 1394 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1395 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1396 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1397 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1398 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 1399 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 1400 | | uri.AppendPath("/azureReachabilityReport", false); |
| 0 | 1401 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 1402 | | request.Uri = uri; |
| 0 | 1403 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1404 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1405 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1406 | | request.Content = content; |
| 0 | 1407 | | return message; |
| | 1408 | | } |
| | 1409 | |
|
| | 1410 | | /// <summary> NOTE: This feature is currently in preview and still being tested for stability. Gets the relative |
| | 1411 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1412 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1413 | | /// <param name="parameters"> Parameters that determine Azure reachability report configuration. </param> |
| | 1414 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1415 | | public async Task<Response> GetAzureReachabilityReportAsync(string resourceGroupName, string networkWatcherName, |
| | 1416 | | { |
| 0 | 1417 | | if (resourceGroupName == null) |
| | 1418 | | { |
| 0 | 1419 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1420 | | } |
| 0 | 1421 | | if (networkWatcherName == null) |
| | 1422 | | { |
| 0 | 1423 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1424 | | } |
| 0 | 1425 | | if (parameters == null) |
| | 1426 | | { |
| 0 | 1427 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1428 | | } |
| | 1429 | |
|
| 0 | 1430 | | using var message = CreateGetAzureReachabilityReportRequest(resourceGroupName, networkWatcherName, parameter |
| 0 | 1431 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1432 | | switch (message.Response.Status) |
| | 1433 | | { |
| | 1434 | | case 200: |
| | 1435 | | case 202: |
| 0 | 1436 | | return message.Response; |
| | 1437 | | default: |
| 0 | 1438 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1439 | | } |
| 0 | 1440 | | } |
| | 1441 | |
|
| | 1442 | | /// <summary> NOTE: This feature is currently in preview and still being tested for stability. Gets the relative |
| | 1443 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1444 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1445 | | /// <param name="parameters"> Parameters that determine Azure reachability report configuration. </param> |
| | 1446 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1447 | | public Response GetAzureReachabilityReport(string resourceGroupName, string networkWatcherName, AzureReachabilit |
| | 1448 | | { |
| 0 | 1449 | | if (resourceGroupName == null) |
| | 1450 | | { |
| 0 | 1451 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1452 | | } |
| 0 | 1453 | | if (networkWatcherName == null) |
| | 1454 | | { |
| 0 | 1455 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1456 | | } |
| 0 | 1457 | | if (parameters == null) |
| | 1458 | | { |
| 0 | 1459 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1460 | | } |
| | 1461 | |
|
| 0 | 1462 | | using var message = CreateGetAzureReachabilityReportRequest(resourceGroupName, networkWatcherName, parameter |
| 0 | 1463 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1464 | | switch (message.Response.Status) |
| | 1465 | | { |
| | 1466 | | case 200: |
| | 1467 | | case 202: |
| 0 | 1468 | | return message.Response; |
| | 1469 | | default: |
| 0 | 1470 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1471 | | } |
| 0 | 1472 | | } |
| | 1473 | |
|
| | 1474 | | internal HttpMessage CreateListAvailableProvidersRequest(string resourceGroupName, string networkWatcherName, Av |
| | 1475 | | { |
| 0 | 1476 | | var message = _pipeline.CreateMessage(); |
| 0 | 1477 | | var request = message.Request; |
| 0 | 1478 | | request.Method = RequestMethod.Post; |
| 0 | 1479 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1480 | | uri.Reset(endpoint); |
| 0 | 1481 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1482 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1483 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1484 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1485 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 1486 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 1487 | | uri.AppendPath("/availableProvidersList", false); |
| 0 | 1488 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 1489 | | request.Uri = uri; |
| 0 | 1490 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1491 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1492 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1493 | | request.Content = content; |
| 0 | 1494 | | return message; |
| | 1495 | | } |
| | 1496 | |
|
| | 1497 | | /// <summary> NOTE: This feature is currently in preview and still being tested for stability. Lists all availab |
| | 1498 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1499 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1500 | | /// <param name="parameters"> Parameters that scope the list of available providers. </param> |
| | 1501 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1502 | | public async Task<Response> ListAvailableProvidersAsync(string resourceGroupName, string networkWatcherName, Ava |
| | 1503 | | { |
| 0 | 1504 | | if (resourceGroupName == null) |
| | 1505 | | { |
| 0 | 1506 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1507 | | } |
| 0 | 1508 | | if (networkWatcherName == null) |
| | 1509 | | { |
| 0 | 1510 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1511 | | } |
| 0 | 1512 | | if (parameters == null) |
| | 1513 | | { |
| 0 | 1514 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1515 | | } |
| | 1516 | |
|
| 0 | 1517 | | using var message = CreateListAvailableProvidersRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 1518 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1519 | | switch (message.Response.Status) |
| | 1520 | | { |
| | 1521 | | case 200: |
| | 1522 | | case 202: |
| 0 | 1523 | | return message.Response; |
| | 1524 | | default: |
| 0 | 1525 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1526 | | } |
| 0 | 1527 | | } |
| | 1528 | |
|
| | 1529 | | /// <summary> NOTE: This feature is currently in preview and still being tested for stability. Lists all availab |
| | 1530 | | /// <param name="resourceGroupName"> The name of the network watcher resource group. </param> |
| | 1531 | | /// <param name="networkWatcherName"> The name of the network watcher resource. </param> |
| | 1532 | | /// <param name="parameters"> Parameters that scope the list of available providers. </param> |
| | 1533 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1534 | | public Response ListAvailableProviders(string resourceGroupName, string networkWatcherName, AvailableProvidersLi |
| | 1535 | | { |
| 0 | 1536 | | if (resourceGroupName == null) |
| | 1537 | | { |
| 0 | 1538 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1539 | | } |
| 0 | 1540 | | if (networkWatcherName == null) |
| | 1541 | | { |
| 0 | 1542 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1543 | | } |
| 0 | 1544 | | if (parameters == null) |
| | 1545 | | { |
| 0 | 1546 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1547 | | } |
| | 1548 | |
|
| 0 | 1549 | | using var message = CreateListAvailableProvidersRequest(resourceGroupName, networkWatcherName, parameters); |
| 0 | 1550 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1551 | | switch (message.Response.Status) |
| | 1552 | | { |
| | 1553 | | case 200: |
| | 1554 | | case 202: |
| 0 | 1555 | | return message.Response; |
| | 1556 | | default: |
| 0 | 1557 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1558 | | } |
| 0 | 1559 | | } |
| | 1560 | |
|
| | 1561 | | internal HttpMessage CreateGetNetworkConfigurationDiagnosticRequest(string resourceGroupName, string networkWatc |
| | 1562 | | { |
| 0 | 1563 | | var message = _pipeline.CreateMessage(); |
| 0 | 1564 | | var request = message.Request; |
| 0 | 1565 | | request.Method = RequestMethod.Post; |
| 0 | 1566 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1567 | | uri.Reset(endpoint); |
| 0 | 1568 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1569 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1570 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1571 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1572 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 0 | 1573 | | uri.AppendPath(networkWatcherName, true); |
| 0 | 1574 | | uri.AppendPath("/networkConfigurationDiagnostic", false); |
| 0 | 1575 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 1576 | | request.Uri = uri; |
| 0 | 1577 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1578 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1579 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1580 | | request.Content = content; |
| 0 | 1581 | | return message; |
| | 1582 | | } |
| | 1583 | |
|
| | 1584 | | /// <summary> Gets Network Configuration Diagnostic data to help customers understand and debug network behavior |
| | 1585 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1586 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 1587 | | /// <param name="parameters"> Parameters to get network configuration diagnostic. </param> |
| | 1588 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1589 | | public async Task<Response> GetNetworkConfigurationDiagnosticAsync(string resourceGroupName, string networkWatch |
| | 1590 | | { |
| 0 | 1591 | | if (resourceGroupName == null) |
| | 1592 | | { |
| 0 | 1593 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1594 | | } |
| 0 | 1595 | | if (networkWatcherName == null) |
| | 1596 | | { |
| 0 | 1597 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1598 | | } |
| 0 | 1599 | | if (parameters == null) |
| | 1600 | | { |
| 0 | 1601 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1602 | | } |
| | 1603 | |
|
| 0 | 1604 | | using var message = CreateGetNetworkConfigurationDiagnosticRequest(resourceGroupName, networkWatcherName, pa |
| 0 | 1605 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1606 | | switch (message.Response.Status) |
| | 1607 | | { |
| | 1608 | | case 200: |
| | 1609 | | case 202: |
| 0 | 1610 | | return message.Response; |
| | 1611 | | default: |
| 0 | 1612 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1613 | | } |
| 0 | 1614 | | } |
| | 1615 | |
|
| | 1616 | | /// <summary> Gets Network Configuration Diagnostic data to help customers understand and debug network behavior |
| | 1617 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 1618 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 1619 | | /// <param name="parameters"> Parameters to get network configuration diagnostic. </param> |
| | 1620 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1621 | | public Response GetNetworkConfigurationDiagnostic(string resourceGroupName, string networkWatcherName, NetworkCo |
| | 1622 | | { |
| 0 | 1623 | | if (resourceGroupName == null) |
| | 1624 | | { |
| 0 | 1625 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1626 | | } |
| 0 | 1627 | | if (networkWatcherName == null) |
| | 1628 | | { |
| 0 | 1629 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 1630 | | } |
| 0 | 1631 | | if (parameters == null) |
| | 1632 | | { |
| 0 | 1633 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1634 | | } |
| | 1635 | |
|
| 0 | 1636 | | using var message = CreateGetNetworkConfigurationDiagnosticRequest(resourceGroupName, networkWatcherName, pa |
| 0 | 1637 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1638 | | switch (message.Response.Status) |
| | 1639 | | { |
| | 1640 | | case 200: |
| | 1641 | | case 202: |
| 0 | 1642 | | return message.Response; |
| | 1643 | | default: |
| 0 | 1644 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1645 | | } |
| 0 | 1646 | | } |
| | 1647 | | } |
| | 1648 | | } |