public async virtual Task <Response <Image> > GetAsync(string imageName, string expand = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ImageCollection.Get"); scope.Start(); try { if (imageName == null) { throw new ArgumentNullException(nameof(imageName)); } var response = await _restClient.GetAsync(Id.ResourceGroupName, imageName, expand, cancellationToken : cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new Image(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <Image> > GetAsync(string expand = null, CancellationToken cancellationToken = default) { using var scope = _imageClientDiagnostics.CreateScope("Image.Get"); scope.Start(); try { var response = await _imageRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _imageClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new Image(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <ImageResource> > GetAsync(string imageName, string expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); using var scope = _imageClientDiagnostics.CreateScope("ImageCollection.Get"); scope.Start(); try { var response = await _imageRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, imageName, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ImageResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }