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