28 lines
562 B
Go
28 lines
562 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (c *Client) ClaimAgent(ctx context.Context, agentThumbprint string, funcs ...OptionFunc) (*Agent, error) {
|
|
response := withResponse[struct {
|
|
Agent *Agent `json:"agent"`
|
|
}]()
|
|
|
|
payload := map[string]any{
|
|
"thumbprint": agentThumbprint,
|
|
}
|
|
|
|
if err := c.apiPost(ctx, "/api/v1/agents/claim", payload, &response, funcs...); err != nil {
|
|
return nil, errors.WithStack(err)
|
|
}
|
|
|
|
if response.Error != nil {
|
|
return nil, errors.WithStack(response.Error)
|
|
}
|
|
|
|
return response.Data.Agent, nil
|
|
}
|