public virtual Response <GuestAgent> Get(string name, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(name, nameof(name)); using var scope = _guestAgentClientDiagnostics.CreateScope("GuestAgentCollection.Get"); scope.Start(); try { var response = _guestAgentRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, name, cancellationToken); if (response.Value == null) { throw _guestAgentClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new GuestAgent(ArmClient, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <GuestAgentResource> Get(CancellationToken cancellationToken = default) { using var scope = _guestAgentClientDiagnostics.CreateScope("GuestAgentResource.Get"); scope.Start(); try { var response = _guestAgentRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new GuestAgentResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }