public async virtual Task <Response <EventHub> > GetAsync(string eventHubName, CancellationToken cancellationToken = default) { if (eventHubName == null) { throw new ArgumentNullException(nameof(eventHubName)); } using var scope = _clientDiagnostics.CreateScope("EventHubCollection.Get"); scope.Start(); try { var response = await _eventHubsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, eventHubName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new EventHub(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <EventHub> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _eventHubClientDiagnostics.CreateScope("EventHub.Get"); scope.Start(); try { var response = await _eventHubRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new EventHub(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }