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