emissary/pkg/client/query_agent_specs.go

28 lines
623 B
Go
Raw Normal View History

2023-02-02 10:55:24 +01:00
package client
import (
"context"
"fmt"
"forge.cadoles.com/Cadoles/emissary/internal/datastore"
2023-02-02 10:55:24 +01:00
"github.com/pkg/errors"
)
func (c *Client) QueryAgentSpecs(ctx context.Context, agentID AgentID, funcs ...OptionFunc) ([]*datastore.SpecHeader, error) {
2023-02-02 10:55:24 +01:00
response := withResponse[struct {
Specs []*datastore.SpecHeader `json:"specs"`
2023-02-02 10:55:24 +01:00
}]()
path := fmt.Sprintf("/api/v1/agents/%d/specs", agentID)
if err := c.apiGet(ctx, path, &response, funcs...); err != nil {
2023-02-02 10:55:24 +01:00
return nil, errors.WithStack(err)
}
if response.Error != nil {
return nil, errors.WithStack(response.Error)
}
return response.Data.Specs, nil
2023-02-02 10:55:24 +01:00
}