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