public async virtual Task <Response <IpAllocation> > GetAsync(string ipAllocationName, string expand = null, CancellationToken cancellationToken = default) { if (ipAllocationName == null) { throw new ArgumentNullException(nameof(ipAllocationName)); } using var scope = _clientDiagnostics.CreateScope("IpAllocationCollection.Get"); scope.Start(); try { var response = await _ipAllocationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new IpAllocation(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <IPAllocationResource> > GetAsync(string expand = null, CancellationToken cancellationToken = default) { using var scope = _ipAllocationIpAllocationsClientDiagnostics.CreateScope("IPAllocationResource.Get"); scope.Start(); try { var response = await _ipAllocationIpAllocationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new IPAllocationResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }