emissary/pkg/client/claim_agent.go

28 lines
562 B
Go
Raw Permalink Normal View History

2024-02-26 18:20:40 +01:00
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
}