public async virtual Task <Response <Subscription> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _subscriptionClientDiagnostics.CreateScope("Subscription.Get"); scope.Start(); try { var response = await _subscriptionRestClient.GetAsync(Id.SubscriptionId, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _subscriptionClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new Subscription(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <Subscription> > GetAsync(string subscriptionId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); using var scope = _subscriptionClientDiagnostics.CreateScope("SubscriptionCollection.Get"); scope.Start(); try { var response = await _subscriptionRestClient.GetAsync(subscriptionId, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new Subscription(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Gets details for this subscription from the service. /// </summary> /// <param name="subscriptionGuid"> The Id of the subscription to get. </param> /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="CancellationToken.None" />. </param> /// <returns> A <see cref="Task"/> that on completion returns a response with the <see cref="Response{TOperations}"/> operation for this subscription. </returns> /// <exception cref="ArgumentException"> subscriptionGuid cannot be null or a whitespace. </exception> public virtual async Task <Response <Subscription> > GetAsync(string subscriptionGuid, CancellationToken cancellationToken = default) { using var scope = Diagnostics.CreateScope("SubscriptionContainer.Get"); scope.Start(); try { var response = await RestClient.GetAsync(subscriptionGuid, cancellationToken).ConfigureAwait(false); return(Response.FromValue(new Subscription(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }