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