emissary/pkg/client/get_agent.go
William Petit 42d49eb090
All checks were successful
arcad/emissary/pipeline/head This commit looks good
feat: move client to public package
2023-06-25 11:46:33 -06:00

27 lines
519 B
Go

package client
import (
"context"
"fmt"
"github.com/pkg/errors"
)
func (c *Client) GetAgent(ctx context.Context, agentID AgentID, funcs ...OptionFunc) (*Agent, error) {
response := withResponse[struct {
Agent *Agent `json:"agent"`
}]()
path := fmt.Sprintf("/api/v1/agents/%d", agentID)
if err := c.apiGet(ctx, path, &response, funcs...); err != nil {
return nil, errors.WithStack(err)
}
if response.Error != nil {
return nil, errors.WithStack(response.Error)
}
return response.Data.Agent, nil
}