public async virtual Task <Response <GalleryImage> > GetAsync(string galleryImageName, CancellationToken cancellationToken = default) { if (galleryImageName == null) { throw new ArgumentNullException(nameof(galleryImageName)); } using var scope = _clientDiagnostics.CreateScope("GalleryImageCollection.Get"); scope.Start(); try { var response = await _galleryImagesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, galleryImageName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new GalleryImage(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <GalleryImage> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("GalleryImage.Get"); scope.Start(); try { var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new GalleryImage(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }