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