public virtual VpnConnectionStopPacketCaptureOperation StopPacketCapture(VpnConnectionPacketCaptureStopParameters parameters = null, bool waitForCompletion = true, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("VpnConnection.StopPacketCapture"); scope.Start(); try { var response = _vpnConnectionsRestClient.StopPacketCapture(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters, cancellationToken); var operation = new VpnConnectionStopPacketCaptureOperation(_clientDiagnostics, Pipeline, _vpnConnectionsRestClient.CreateStopPacketCaptureRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual ArmOperation <string> StopPacketCapture(WaitUntil waitUntil, VpnConnectionPacketCaptureStopParameters parameters = null, CancellationToken cancellationToken = default) { using var scope = _vpnConnectionClientDiagnostics.CreateScope("VpnConnection.StopPacketCapture"); scope.Start(); try { var response = _vpnConnectionRestClient.StopPacketCapture(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters, cancellationToken); var operation = new NetworkArmOperation <string>(new StringOperationSource(), _vpnConnectionClientDiagnostics, Pipeline, _vpnConnectionRestClient.CreateStopPacketCaptureRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Stops packet capture on Vpn connection in the specified resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='gatewayName'> /// The name of the gateway. /// </param> /// <param name='vpnConnectionName'> /// The name of the vpn connection. /// </param> /// <param name='parameters'> /// Vpn Connection packet capture parameters supplied to stop packet capture on /// gateway connection. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <string> BeginStopPacketCaptureAsync(this IVpnConnectionsOperations operations, string resourceGroupName, string gatewayName, string vpnConnectionName, VpnConnectionPacketCaptureStopParameters parameters = default(VpnConnectionPacketCaptureStopParameters), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginStopPacketCaptureWithHttpMessagesAsync(resourceGroupName, gatewayName, vpnConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Stops packet capture on Vpn connection in the specified resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='gatewayName'> /// The name of the gateway. /// </param> /// <param name='vpnConnectionName'> /// The name of the vpn connection. /// </param> /// <param name='parameters'> /// Vpn Connection packet capture parameters supplied to stop packet capture on /// gateway connection. /// </param> public static string BeginStopPacketCapture(this IVpnConnectionsOperations operations, string resourceGroupName, string gatewayName, string vpnConnectionName, VpnConnectionPacketCaptureStopParameters parameters = default(VpnConnectionPacketCaptureStopParameters)) { return(operations.BeginStopPacketCaptureAsync(resourceGroupName, gatewayName, vpnConnectionName, parameters).GetAwaiter().GetResult()); }
public override void Execute() { if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnConnectionName, StringComparison.OrdinalIgnoreCase)) { this.ResourceGroupName = this.ResourceGroupName; this.ParentResourceName = this.ParentResourceName; this.Name = this.Name; } else if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnConnectionObject, StringComparison.OrdinalIgnoreCase)) { this.ResourceId = this.InputObject.Id; if (string.IsNullOrWhiteSpace(this.ResourceId)) { throw new PSArgumentException(Properties.Resources.VpnConnectionNotFound); } var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); this.Name = parsedResourceId.ResourceName; } //// Get the vpngateway object - this will throw not found if the object is not found PSVpnGateway parentGateway = this.GetVpnGateway(this.ResourceGroupName, this.ParentResourceName); if (parentGateway == null || parentGateway.Connections == null || !parentGateway.Connections.Any(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase))) { throw new PSArgumentException(Properties.Resources.VpnConnectionNotFound); } VpnConnectionPacketCaptureStopParameters parameters = new VpnConnectionPacketCaptureStopParameters(); if (this.SasUrl != null) { parameters.SasUrl = SasUrl; } if (this.LinkConnectionName != null) { parameters.LinkConnectionNames = LinkConnectionName.Split(',').Select(x => x.Trim()).ToList(); } var existingConnection = parentGateway.Connections.FirstOrDefault(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)); 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)); PSVpnConnectionPacketCaptureResult output = new PSVpnConnectionPacketCaptureResult() { Name = existingConnection.Name, ResourceGroupName = parentGateway.ResourceGroupName, Tag = parentGateway.Tag, ResourceGuid = existingConnection.Id, Location = parentGateway.Location, LinkConnectionName = this.LinkConnectionName }; output.StartTime = DateTime.UtcNow; var result = this.VpnConnectionClient.StopPacketCapture(this.ResourceGroupName, ParentResourceName, this.Name, parameters); output.EndTime = DateTime.UtcNow; WriteObject(output); } }