public async virtual Task <Response <VpnGateway> > GetAsync(string gatewayName, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("VpnGatewayContainer.Get"); scope.Start(); try { if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } var response = await _restClient.GetAsync(Id.ResourceGroupName, gatewayName, cancellationToken : cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new VpnGateway(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <VpnGateway> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGateway.Get"); scope.Start(); try { var response = await _vpnGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _vpnGatewayClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new VpnGateway(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <VpnGatewayResource> > GetAsync(string gatewayName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.Get"); scope.Start(); try { var response = await _vpnGatewayRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new VpnGatewayResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }