public virtual Response <Image> Get(string expand = null, CancellationToken cancellationToken = default) { using var scope = _imageClientDiagnostics.CreateScope("Image.Get"); scope.Start(); try { var response = _imageRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken); if (response.Value == null) { throw _imageClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new Image(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <Image> Get(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 = _restClient.Get(Id.ResourceGroupName, imageName, expand, cancellationToken: cancellationToken); if (response.Value == null) { throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new Image(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }