public virtual Response <DedicatedHost> Get(InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { using var scope = _dedicatedHostClientDiagnostics.CreateScope("DedicatedHost.Get"); scope.Start(); try { var response = _dedicatedHostRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, expand, cancellationToken); if (response.Value == null) { throw _dedicatedHostClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new DedicatedHost(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <DedicatedHostResource> Get(string hostName, InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(hostName, nameof(hostName)); using var scope = _dedicatedHostClientDiagnostics.CreateScope("DedicatedHostCollection.Get"); scope.Start(); try { var response = _dedicatedHostRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, hostName, expand, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new DedicatedHostResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <DedicatedHost> Get(string hostName, InstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("DedicatedHostContainer.Get"); scope.Start(); try { if (hostName == null) { throw new ArgumentNullException(nameof(hostName)); } var response = _restClient.Get(Id.ResourceGroupName, Id.Name, hostName, expand, cancellationToken: cancellationToken); if (response.Value == null) { throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new DedicatedHost(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }