28 lines
623 B
Go
28 lines
623 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"forge.cadoles.com/Cadoles/emissary/internal/datastore"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (c *Client) QueryAgentSpecs(ctx context.Context, agentID AgentID, funcs ...OptionFunc) ([]*datastore.SpecHeader, error) {
|
|
response := withResponse[struct {
|
|
Specs []*datastore.SpecHeader `json:"specs"`
|
|
}]()
|
|
|
|
path := fmt.Sprintf("/api/v1/agents/%d/specs", 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.Specs, nil
|
|
}
|