35 lines
754 B
Go
35 lines
754 B
Go
|
package client
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"forge.cadoles.com/Cadoles/emissary/internal/datastore"
|
||
|
"forge.cadoles.com/Cadoles/emissary/internal/spec"
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
func (c *Client) DeleteAgentSpec(ctx context.Context, agentID datastore.AgentID, name spec.Name, funcs ...OptionFunc) (spec.Name, error) {
|
||
|
payload := struct {
|
||
|
Name spec.Name `json:"name"`
|
||
|
}{
|
||
|
Name: name,
|
||
|
}
|
||
|
|
||
|
response := withResponse[struct {
|
||
|
Name spec.Name `json:"name"`
|
||
|
}]()
|
||
|
|
||
|
path := fmt.Sprintf("/api/v1/agents/%d/specs", agentID)
|
||
|
|
||
|
if err := c.apiDelete(ctx, path, payload, &response, funcs...); err != nil {
|
||
|
return "", errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
if response.Error != nil {
|
||
|
return "", errors.WithStack(response.Error)
|
||
|
}
|
||
|
|
||
|
return response.Data.Name, nil
|
||
|
}
|