public async virtual Task <Response <JobAgent> > GetAsync(string jobAgentName, CancellationToken cancellationToken = default) { if (jobAgentName == null) { throw new ArgumentNullException(nameof(jobAgentName)); } using var scope = _clientDiagnostics.CreateScope("JobAgentCollection.Get"); scope.Start(); try { var response = await _jobAgentsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, jobAgentName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new JobAgent(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <JobAgentResource> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _jobAgentClientDiagnostics.CreateScope("JobAgentResource.Get"); scope.Start(); try { var response = await _jobAgentRestClient.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 JobAgentResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }