public virtual Response <VpnGateway> Get(CancellationToken cancellationToken = default) { using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGateway.Get"); scope.Start(); try { var response = _vpnGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); if (response.Value == null) { throw _vpnGatewayClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new VpnGateway(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <VpnGatewayResource> Get(string gatewayName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.Get"); scope.Start(); try { var response = _vpnGatewayRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, cancellationToken); 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; } }
public virtual Response <VpnGateway> Get(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 = _restClient.Get(Id.ResourceGroupName, gatewayName, cancellationToken: cancellationToken); if (response.Value == null) { throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new VpnGateway(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }