public override void Execute() { PSVpnGateway existingVpnGateway = null; if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnGatewayObject)) { existingVpnGateway = this.InputObject; this.ResourceGroupName = this.InputObject.ResourceGroupName; this.Name = this.InputObject.Name; } else { if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnGatewayResourceId)) { var parsedResourceId = new ResourceIdentifier(ResourceId); Name = parsedResourceId.ResourceName; ResourceGroupName = parsedResourceId.ResourceGroupName; } existingVpnGateway = this.GetVpnGateway(this.ResourceGroupName, this.Name); } if (existingVpnGateway == null) { throw new PSArgumentException(Properties.Resources.VpnGatewayNotFound); } VpnGatewayPacketCaptureStartParameters parameters = new VpnGatewayPacketCaptureStartParameters(); if (this.FilterData != null) { parameters.FilterData = FilterData; } base.Execute(); if (ShouldProcess(this.Name, String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name))) { WriteVerbose(String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name)); PSVpnGatewayPacketCaptureResult output = new PSVpnGatewayPacketCaptureResult() { Name = existingVpnGateway.Name, ResourceGroupName = existingVpnGateway.ResourceGroupName, Tag = existingVpnGateway.Tag, ResourceGuid = existingVpnGateway.ResourceGuid, Location = existingVpnGateway.Location, }; output.StartTime = DateTime.UtcNow; var result = this.VpnGatewayClient.StartPacketCapture(this.ResourceGroupName, this.Name, parameters); output.EndTime = DateTime.UtcNow; WriteObject(output); } }
public virtual ArmOperation <string> StartPacketCapture(WaitUntil waitUntil, VpnGatewayPacketCaptureStartParameters parameters = null, CancellationToken cancellationToken = default) { using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGateway.StartPacketCapture"); scope.Start(); try { var response = _vpnGatewayRestClient.StartPacketCapture(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken); var operation = new NetworkArmOperation <string>(new StringOperationSource(), _vpnGatewayClientDiagnostics, Pipeline, _vpnGatewayRestClient.CreateStartPacketCaptureRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual VpnGatewayStartPacketCaptureOperation StartPacketCapture(VpnGatewayPacketCaptureStartParameters parameters = null, bool waitForCompletion = true, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("VpnGateway.StartPacketCapture"); scope.Start(); try { var response = _restClient.StartPacketCapture(Id.ResourceGroupName, Id.Name, parameters, cancellationToken); var operation = new VpnGatewayStartPacketCaptureOperation(_clientDiagnostics, Pipeline, _restClient.CreateStartPacketCaptureRequest(Id.ResourceGroupName, Id.Name, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Starts packet capture on vpn gateway in the specified resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name of the VpnGateway. /// </param> /// <param name='gatewayName'> /// The name of the gateway. /// </param> /// <param name='parameters'> /// Vpn gateway packet capture parameters supplied to start packet capture on /// vpn gateway. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <string> BeginStartPacketCaptureAsync(this IVpnGatewaysOperations operations, string resourceGroupName, string gatewayName, VpnGatewayPacketCaptureStartParameters parameters = default(VpnGatewayPacketCaptureStartParameters), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginStartPacketCaptureWithHttpMessagesAsync(resourceGroupName, gatewayName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Starts packet capture on vpn gateway in the specified resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name of the VpnGateway. /// </param> /// <param name='gatewayName'> /// The name of the gateway. /// </param> /// <param name='parameters'> /// Vpn gateway packet capture parameters supplied to start packet capture on /// vpn gateway. /// </param> public static string BeginStartPacketCapture(this IVpnGatewaysOperations operations, string resourceGroupName, string gatewayName, VpnGatewayPacketCaptureStartParameters parameters = default(VpnGatewayPacketCaptureStartParameters)) { return(operations.BeginStartPacketCaptureAsync(resourceGroupName, gatewayName, parameters).GetAwaiter().GetResult()); }
public async virtual Task <VpnGatewayStartPacketCaptureOperation> StartPacketCaptureAsync(VpnGatewayPacketCaptureStartParameters parameters = null, bool waitForCompletion = true, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("VpnGateway.StartPacketCapture"); scope.Start(); try { var response = await _vpnGatewaysRestClient.StartPacketCaptureAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken).ConfigureAwait(false); var operation = new VpnGatewayStartPacketCaptureOperation(_clientDiagnostics, Pipeline, _vpnGatewaysRestClient.CreateStartPacketCaptureRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }