public virtual Response <NetworkWatcher> Get(string networkWatcherName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(networkWatcherName, nameof(networkWatcherName)); using var scope = _networkWatcherClientDiagnostics.CreateScope("NetworkWatcherCollection.Get"); scope.Start(); try { var response = _networkWatcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, networkWatcherName, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new NetworkWatcher(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <NetworkWatcher> Get(string networkWatcherName, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("NetworkWatcherCollection.Get"); scope.Start(); try { if (networkWatcherName == null) { throw new ArgumentNullException(nameof(networkWatcherName)); } var response = _restClient.Get(Id.ResourceGroupName, networkWatcherName, cancellationToken: cancellationToken); if (response.Value == null) { throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new NetworkWatcher(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }