public async virtual Task <Response <ScalingPlan> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _scalingPlanClientDiagnostics.CreateScope("ScalingPlan.Get"); scope.Start(); try { var response = await _scalingPlanRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _scalingPlanClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new ScalingPlan(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <ScalingPlanResource> > GetAsync(string scalingPlanName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(scalingPlanName, nameof(scalingPlanName)); using var scope = _scalingPlanClientDiagnostics.CreateScope("ScalingPlanCollection.Get"); scope.Start(); try { var response = await _scalingPlanRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, scalingPlanName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ScalingPlanResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }