| | 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 PacketCapturesRestOperations |
| | 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 PacketCapturesRestOperations. </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 |
| 36 | 32 | | public PacketCapturesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript |
| | 33 | | { |
| 36 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 36 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 36 | 40 | | this.subscriptionId = subscriptionId; |
| 36 | 41 | | this.endpoint = endpoint; |
| 36 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 36 | 43 | | _pipeline = pipeline; |
| 36 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateCreateRequest(string resourceGroupName, string networkWatcherName, string packetCaptu |
| | 47 | | { |
| 16 | 48 | | var message = _pipeline.CreateMessage(); |
| 16 | 49 | | var request = message.Request; |
| 16 | 50 | | request.Method = RequestMethod.Put; |
| 16 | 51 | | var uri = new RawRequestUriBuilder(); |
| 16 | 52 | | uri.Reset(endpoint); |
| 16 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 54 | | uri.AppendPath(subscriptionId, true); |
| 16 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 57 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 16 | 58 | | uri.AppendPath(networkWatcherName, true); |
| 16 | 59 | | uri.AppendPath("/packetCaptures/", false); |
| 16 | 60 | | uri.AppendPath(packetCaptureName, true); |
| 16 | 61 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 16 | 62 | | request.Uri = uri; |
| 16 | 63 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 64 | | var content = new Utf8JsonRequestContent(); |
| 16 | 65 | | content.JsonWriter.WriteObjectValue(parameters); |
| 16 | 66 | | request.Content = content; |
| 16 | 67 | | return message; |
| | 68 | | } |
| | 69 | |
|
| | 70 | | /// <summary> Create and start a packet capture on the specified VM. </summary> |
| | 71 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 72 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 73 | | /// <param name="packetCaptureName"> The name of the packet capture session. </param> |
| | 74 | | /// <param name="parameters"> Parameters that define the create packet capture operation. </param> |
| | 75 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 76 | | public async Task<Response> CreateAsync(string resourceGroupName, string networkWatcherName, string packetCaptur |
| | 77 | | { |
| 4 | 78 | | if (resourceGroupName == null) |
| | 79 | | { |
| 0 | 80 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 81 | | } |
| 4 | 82 | | if (networkWatcherName == null) |
| | 83 | | { |
| 0 | 84 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 85 | | } |
| 4 | 86 | | if (packetCaptureName == null) |
| | 87 | | { |
| 0 | 88 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 89 | | } |
| 4 | 90 | | if (parameters == null) |
| | 91 | | { |
| 0 | 92 | | throw new ArgumentNullException(nameof(parameters)); |
| | 93 | | } |
| | 94 | |
|
| 4 | 95 | | using var message = CreateCreateRequest(resourceGroupName, networkWatcherName, packetCaptureName, parameters |
| 4 | 96 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 97 | | switch (message.Response.Status) |
| | 98 | | { |
| | 99 | | case 201: |
| 4 | 100 | | return message.Response; |
| | 101 | | default: |
| 0 | 102 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 103 | | } |
| 4 | 104 | | } |
| | 105 | |
|
| | 106 | | /// <summary> Create and start a packet capture on the specified VM. </summary> |
| | 107 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 108 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 109 | | /// <param name="packetCaptureName"> The name of the packet capture session. </param> |
| | 110 | | /// <param name="parameters"> Parameters that define the create packet capture operation. </param> |
| | 111 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 112 | | public Response Create(string resourceGroupName, string networkWatcherName, string packetCaptureName, PacketCapt |
| | 113 | | { |
| 4 | 114 | | if (resourceGroupName == null) |
| | 115 | | { |
| 0 | 116 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 117 | | } |
| 4 | 118 | | if (networkWatcherName == null) |
| | 119 | | { |
| 0 | 120 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 121 | | } |
| 4 | 122 | | if (packetCaptureName == null) |
| | 123 | | { |
| 0 | 124 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 125 | | } |
| 4 | 126 | | if (parameters == null) |
| | 127 | | { |
| 0 | 128 | | throw new ArgumentNullException(nameof(parameters)); |
| | 129 | | } |
| | 130 | |
|
| 4 | 131 | | using var message = CreateCreateRequest(resourceGroupName, networkWatcherName, packetCaptureName, parameters |
| 4 | 132 | | _pipeline.Send(message, cancellationToken); |
| 4 | 133 | | switch (message.Response.Status) |
| | 134 | | { |
| | 135 | | case 201: |
| 4 | 136 | | return message.Response; |
| | 137 | | default: |
| 0 | 138 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 139 | | } |
| 4 | 140 | | } |
| | 141 | |
|
| | 142 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string networkWatcherName, string packetCaptureN |
| | 143 | | { |
| 4 | 144 | | var message = _pipeline.CreateMessage(); |
| 4 | 145 | | var request = message.Request; |
| 4 | 146 | | request.Method = RequestMethod.Get; |
| 4 | 147 | | var uri = new RawRequestUriBuilder(); |
| 4 | 148 | | uri.Reset(endpoint); |
| 4 | 149 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 150 | | uri.AppendPath(subscriptionId, true); |
| 4 | 151 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 152 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 153 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 4 | 154 | | uri.AppendPath(networkWatcherName, true); |
| 4 | 155 | | uri.AppendPath("/packetCaptures/", false); |
| 4 | 156 | | uri.AppendPath(packetCaptureName, true); |
| 4 | 157 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 158 | | request.Uri = uri; |
| 4 | 159 | | return message; |
| | 160 | | } |
| | 161 | |
|
| | 162 | | /// <summary> Gets a packet capture session by name. </summary> |
| | 163 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 164 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 165 | | /// <param name="packetCaptureName"> The name of the packet capture session. </param> |
| | 166 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 167 | | public async Task<Response<PacketCaptureResult>> GetAsync(string resourceGroupName, string networkWatcherName, s |
| | 168 | | { |
| 2 | 169 | | if (resourceGroupName == null) |
| | 170 | | { |
| 0 | 171 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 172 | | } |
| 2 | 173 | | if (networkWatcherName == null) |
| | 174 | | { |
| 0 | 175 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 176 | | } |
| 2 | 177 | | if (packetCaptureName == null) |
| | 178 | | { |
| 0 | 179 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 180 | | } |
| | 181 | |
|
| 2 | 182 | | using var message = CreateGetRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 2 | 183 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 184 | | switch (message.Response.Status) |
| | 185 | | { |
| | 186 | | case 200: |
| | 187 | | { |
| 2 | 188 | | PacketCaptureResult value = default; |
| 2 | 189 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 190 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 191 | | { |
| 0 | 192 | | value = null; |
| | 193 | | } |
| | 194 | | else |
| | 195 | | { |
| 2 | 196 | | value = PacketCaptureResult.DeserializePacketCaptureResult(document.RootElement); |
| | 197 | | } |
| 2 | 198 | | return Response.FromValue(value, message.Response); |
| | 199 | | } |
| | 200 | | default: |
| 0 | 201 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 202 | | } |
| 2 | 203 | | } |
| | 204 | |
|
| | 205 | | /// <summary> Gets a packet capture session by name. </summary> |
| | 206 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 207 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 208 | | /// <param name="packetCaptureName"> The name of the packet capture session. </param> |
| | 209 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 210 | | public Response<PacketCaptureResult> Get(string resourceGroupName, string networkWatcherName, string packetCaptu |
| | 211 | | { |
| 2 | 212 | | if (resourceGroupName == null) |
| | 213 | | { |
| 0 | 214 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 215 | | } |
| 2 | 216 | | if (networkWatcherName == null) |
| | 217 | | { |
| 0 | 218 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 219 | | } |
| 2 | 220 | | if (packetCaptureName == null) |
| | 221 | | { |
| 0 | 222 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 223 | | } |
| | 224 | |
|
| 2 | 225 | | using var message = CreateGetRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 2 | 226 | | _pipeline.Send(message, cancellationToken); |
| 2 | 227 | | switch (message.Response.Status) |
| | 228 | | { |
| | 229 | | case 200: |
| | 230 | | { |
| 2 | 231 | | PacketCaptureResult value = default; |
| 2 | 232 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 233 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 234 | | { |
| 0 | 235 | | value = null; |
| | 236 | | } |
| | 237 | | else |
| | 238 | | { |
| 2 | 239 | | value = PacketCaptureResult.DeserializePacketCaptureResult(document.RootElement); |
| | 240 | | } |
| 2 | 241 | | return Response.FromValue(value, message.Response); |
| | 242 | | } |
| | 243 | | default: |
| 0 | 244 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 245 | | } |
| 2 | 246 | | } |
| | 247 | |
|
| | 248 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string networkWatcherName, string packetCaptu |
| | 249 | | { |
| 8 | 250 | | var message = _pipeline.CreateMessage(); |
| 8 | 251 | | var request = message.Request; |
| 8 | 252 | | request.Method = RequestMethod.Delete; |
| 8 | 253 | | var uri = new RawRequestUriBuilder(); |
| 8 | 254 | | uri.Reset(endpoint); |
| 8 | 255 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 256 | | uri.AppendPath(subscriptionId, true); |
| 8 | 257 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 258 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 259 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 8 | 260 | | uri.AppendPath(networkWatcherName, true); |
| 8 | 261 | | uri.AppendPath("/packetCaptures/", false); |
| 8 | 262 | | uri.AppendPath(packetCaptureName, 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 packet capture session. </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="packetCaptureName"> The name of the packet capture session. </param> |
| | 272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 273 | | public async Task<Response> DeleteAsync(string resourceGroupName, string networkWatcherName, string packetCaptur |
| | 274 | | { |
| 2 | 275 | | if (resourceGroupName == null) |
| | 276 | | { |
| 0 | 277 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 278 | | } |
| 2 | 279 | | if (networkWatcherName == null) |
| | 280 | | { |
| 0 | 281 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 282 | | } |
| 2 | 283 | | if (packetCaptureName == null) |
| | 284 | | { |
| 0 | 285 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 286 | | } |
| | 287 | |
|
| 2 | 288 | | using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 2 | 289 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 290 | | switch (message.Response.Status) |
| | 291 | | { |
| | 292 | | case 202: |
| | 293 | | case 204: |
| 2 | 294 | | return message.Response; |
| | 295 | | default: |
| 0 | 296 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 297 | | } |
| 2 | 298 | | } |
| | 299 | |
|
| | 300 | | /// <summary> Deletes the specified packet capture session. </summary> |
| | 301 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 302 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 303 | | /// <param name="packetCaptureName"> The name of the packet capture session. </param> |
| | 304 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 305 | | public Response Delete(string resourceGroupName, string networkWatcherName, string packetCaptureName, Cancellati |
| | 306 | | { |
| 2 | 307 | | if (resourceGroupName == null) |
| | 308 | | { |
| 0 | 309 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 310 | | } |
| 2 | 311 | | if (networkWatcherName == null) |
| | 312 | | { |
| 0 | 313 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 314 | | } |
| 2 | 315 | | if (packetCaptureName == null) |
| | 316 | | { |
| 0 | 317 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 318 | | } |
| | 319 | |
|
| 2 | 320 | | using var message = CreateDeleteRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 2 | 321 | | _pipeline.Send(message, cancellationToken); |
| 2 | 322 | | switch (message.Response.Status) |
| | 323 | | { |
| | 324 | | case 202: |
| | 325 | | case 204: |
| 2 | 326 | | return message.Response; |
| | 327 | | default: |
| 0 | 328 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 329 | | } |
| 2 | 330 | | } |
| | 331 | |
|
| | 332 | | internal HttpMessage CreateStopRequest(string resourceGroupName, string networkWatcherName, string packetCapture |
| | 333 | | { |
| 8 | 334 | | var message = _pipeline.CreateMessage(); |
| 8 | 335 | | var request = message.Request; |
| 8 | 336 | | request.Method = RequestMethod.Post; |
| 8 | 337 | | var uri = new RawRequestUriBuilder(); |
| 8 | 338 | | uri.Reset(endpoint); |
| 8 | 339 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 340 | | uri.AppendPath(subscriptionId, true); |
| 8 | 341 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 342 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 343 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 8 | 344 | | uri.AppendPath(networkWatcherName, true); |
| 8 | 345 | | uri.AppendPath("/packetCaptures/", false); |
| 8 | 346 | | uri.AppendPath(packetCaptureName, true); |
| 8 | 347 | | uri.AppendPath("/stop", false); |
| 8 | 348 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 349 | | request.Uri = uri; |
| 8 | 350 | | return message; |
| | 351 | | } |
| | 352 | |
|
| | 353 | | /// <summary> Stops a specified packet capture session. </summary> |
| | 354 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 355 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 356 | | /// <param name="packetCaptureName"> The name of the packet capture session. </param> |
| | 357 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 358 | | public async Task<Response> StopAsync(string resourceGroupName, string networkWatcherName, string packetCaptureN |
| | 359 | | { |
| 2 | 360 | | if (resourceGroupName == null) |
| | 361 | | { |
| 0 | 362 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 363 | | } |
| 2 | 364 | | if (networkWatcherName == null) |
| | 365 | | { |
| 0 | 366 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 367 | | } |
| 2 | 368 | | if (packetCaptureName == null) |
| | 369 | | { |
| 0 | 370 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 371 | | } |
| | 372 | |
|
| 2 | 373 | | using var message = CreateStopRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 2 | 374 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 375 | | switch (message.Response.Status) |
| | 376 | | { |
| | 377 | | case 200: |
| | 378 | | case 202: |
| 2 | 379 | | return message.Response; |
| | 380 | | default: |
| 0 | 381 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 382 | | } |
| 2 | 383 | | } |
| | 384 | |
|
| | 385 | | /// <summary> Stops a specified packet capture session. </summary> |
| | 386 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 387 | | /// <param name="networkWatcherName"> The name of the network watcher. </param> |
| | 388 | | /// <param name="packetCaptureName"> The name of the packet capture session. </param> |
| | 389 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 390 | | public Response Stop(string resourceGroupName, string networkWatcherName, string packetCaptureName, Cancellation |
| | 391 | | { |
| 2 | 392 | | if (resourceGroupName == null) |
| | 393 | | { |
| 0 | 394 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 395 | | } |
| 2 | 396 | | if (networkWatcherName == null) |
| | 397 | | { |
| 0 | 398 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 399 | | } |
| 2 | 400 | | if (packetCaptureName == null) |
| | 401 | | { |
| 0 | 402 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 403 | | } |
| | 404 | |
|
| 2 | 405 | | using var message = CreateStopRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 2 | 406 | | _pipeline.Send(message, cancellationToken); |
| 2 | 407 | | switch (message.Response.Status) |
| | 408 | | { |
| | 409 | | case 200: |
| | 410 | | case 202: |
| 2 | 411 | | return message.Response; |
| | 412 | | default: |
| 0 | 413 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 414 | | } |
| 2 | 415 | | } |
| | 416 | |
|
| | 417 | | internal HttpMessage CreateGetStatusRequest(string resourceGroupName, string networkWatcherName, string packetCa |
| | 418 | | { |
| 16 | 419 | | var message = _pipeline.CreateMessage(); |
| 16 | 420 | | var request = message.Request; |
| 16 | 421 | | request.Method = RequestMethod.Post; |
| 16 | 422 | | var uri = new RawRequestUriBuilder(); |
| 16 | 423 | | uri.Reset(endpoint); |
| 16 | 424 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 425 | | uri.AppendPath(subscriptionId, true); |
| 16 | 426 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 427 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 428 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 16 | 429 | | uri.AppendPath(networkWatcherName, true); |
| 16 | 430 | | uri.AppendPath("/packetCaptures/", false); |
| 16 | 431 | | uri.AppendPath(packetCaptureName, true); |
| 16 | 432 | | uri.AppendPath("/queryStatus", false); |
| 16 | 433 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 16 | 434 | | request.Uri = uri; |
| 16 | 435 | | return message; |
| | 436 | | } |
| | 437 | |
|
| | 438 | | /// <summary> Query the status of a running packet capture session. </summary> |
| | 439 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 440 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 441 | | /// <param name="packetCaptureName"> The name given to the packet capture session. </param> |
| | 442 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 443 | | public async Task<Response> GetStatusAsync(string resourceGroupName, string networkWatcherName, string packetCap |
| | 444 | | { |
| 4 | 445 | | if (resourceGroupName == null) |
| | 446 | | { |
| 0 | 447 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 448 | | } |
| 4 | 449 | | if (networkWatcherName == null) |
| | 450 | | { |
| 0 | 451 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 452 | | } |
| 4 | 453 | | if (packetCaptureName == null) |
| | 454 | | { |
| 0 | 455 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 456 | | } |
| | 457 | |
|
| 4 | 458 | | using var message = CreateGetStatusRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 4 | 459 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 460 | | switch (message.Response.Status) |
| | 461 | | { |
| | 462 | | case 200: |
| | 463 | | case 202: |
| 4 | 464 | | return message.Response; |
| | 465 | | default: |
| 0 | 466 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 467 | | } |
| 4 | 468 | | } |
| | 469 | |
|
| | 470 | | /// <summary> Query the status of a running packet capture session. </summary> |
| | 471 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 472 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 473 | | /// <param name="packetCaptureName"> The name given to the packet capture session. </param> |
| | 474 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 475 | | public Response GetStatus(string resourceGroupName, string networkWatcherName, string packetCaptureName, Cancell |
| | 476 | | { |
| 4 | 477 | | if (resourceGroupName == null) |
| | 478 | | { |
| 0 | 479 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 480 | | } |
| 4 | 481 | | if (networkWatcherName == null) |
| | 482 | | { |
| 0 | 483 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 484 | | } |
| 4 | 485 | | if (packetCaptureName == null) |
| | 486 | | { |
| 0 | 487 | | throw new ArgumentNullException(nameof(packetCaptureName)); |
| | 488 | | } |
| | 489 | |
|
| 4 | 490 | | using var message = CreateGetStatusRequest(resourceGroupName, networkWatcherName, packetCaptureName); |
| 4 | 491 | | _pipeline.Send(message, cancellationToken); |
| 4 | 492 | | switch (message.Response.Status) |
| | 493 | | { |
| | 494 | | case 200: |
| | 495 | | case 202: |
| 4 | 496 | | return message.Response; |
| | 497 | | default: |
| 0 | 498 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 499 | | } |
| 4 | 500 | | } |
| | 501 | |
|
| | 502 | | internal HttpMessage CreateListRequest(string resourceGroupName, string networkWatcherName) |
| | 503 | | { |
| 4 | 504 | | var message = _pipeline.CreateMessage(); |
| 4 | 505 | | var request = message.Request; |
| 4 | 506 | | request.Method = RequestMethod.Get; |
| 4 | 507 | | var uri = new RawRequestUriBuilder(); |
| 4 | 508 | | uri.Reset(endpoint); |
| 4 | 509 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 510 | | uri.AppendPath(subscriptionId, true); |
| 4 | 511 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 512 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 513 | | uri.AppendPath("/providers/Microsoft.Network/networkWatchers/", false); |
| 4 | 514 | | uri.AppendPath(networkWatcherName, true); |
| 4 | 515 | | uri.AppendPath("/packetCaptures", false); |
| 4 | 516 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 4 | 517 | | request.Uri = uri; |
| 4 | 518 | | return message; |
| | 519 | | } |
| | 520 | |
|
| | 521 | | /// <summary> Lists all packet capture sessions within the specified resource group. </summary> |
| | 522 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 523 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 524 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 525 | | public async Task<Response<PacketCaptureListResult>> ListAsync(string resourceGroupName, string networkWatcherNa |
| | 526 | | { |
| 2 | 527 | | if (resourceGroupName == null) |
| | 528 | | { |
| 0 | 529 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 530 | | } |
| 2 | 531 | | if (networkWatcherName == null) |
| | 532 | | { |
| 0 | 533 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 534 | | } |
| | 535 | |
|
| 2 | 536 | | using var message = CreateListRequest(resourceGroupName, networkWatcherName); |
| 2 | 537 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 538 | | switch (message.Response.Status) |
| | 539 | | { |
| | 540 | | case 200: |
| | 541 | | { |
| 2 | 542 | | PacketCaptureListResult value = default; |
| 2 | 543 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 544 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 545 | | { |
| 0 | 546 | | value = null; |
| | 547 | | } |
| | 548 | | else |
| | 549 | | { |
| 2 | 550 | | value = PacketCaptureListResult.DeserializePacketCaptureListResult(document.RootElement); |
| | 551 | | } |
| 2 | 552 | | return Response.FromValue(value, message.Response); |
| | 553 | | } |
| | 554 | | default: |
| 0 | 555 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 556 | | } |
| 2 | 557 | | } |
| | 558 | |
|
| | 559 | | /// <summary> Lists all packet capture sessions within the specified resource group. </summary> |
| | 560 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 561 | | /// <param name="networkWatcherName"> The name of the Network Watcher resource. </param> |
| | 562 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 563 | | public Response<PacketCaptureListResult> List(string resourceGroupName, string networkWatcherName, CancellationT |
| | 564 | | { |
| 2 | 565 | | if (resourceGroupName == null) |
| | 566 | | { |
| 0 | 567 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 568 | | } |
| 2 | 569 | | if (networkWatcherName == null) |
| | 570 | | { |
| 0 | 571 | | throw new ArgumentNullException(nameof(networkWatcherName)); |
| | 572 | | } |
| | 573 | |
|
| 2 | 574 | | using var message = CreateListRequest(resourceGroupName, networkWatcherName); |
| 2 | 575 | | _pipeline.Send(message, cancellationToken); |
| 2 | 576 | | switch (message.Response.Status) |
| | 577 | | { |
| | 578 | | case 200: |
| | 579 | | { |
| 2 | 580 | | PacketCaptureListResult value = default; |
| 2 | 581 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 582 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 583 | | { |
| 0 | 584 | | value = null; |
| | 585 | | } |
| | 586 | | else |
| | 587 | | { |
| 2 | 588 | | value = PacketCaptureListResult.DeserializePacketCaptureListResult(document.RootElement); |
| | 589 | | } |
| 2 | 590 | | return Response.FromValue(value, message.Response); |
| | 591 | | } |
| | 592 | | default: |
| 0 | 593 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 594 | | } |
| 2 | 595 | | } |
| | 596 | | } |
| | 597 | | } |