emissary/pkg/client/delete_agent_spec.go

36 lines
775 B
Go
Raw Permalink Normal View History

2023-03-13 10:44:58 +01:00
package client
import (
"context"
"fmt"
"github.com/pkg/errors"
)
func (c *Client) DeleteAgentSpec(ctx context.Context, agentID AgentID, name string, version string, funcs ...OptionFunc) (string, string, error) {
2023-03-13 10:44:58 +01:00
payload := struct {
Name string `json:"name"`
Version string `json:"version"`
2023-03-13 10:44:58 +01:00
}{
Name: name,
Version: version,
2023-03-13 10:44:58 +01:00
}
response := withResponse[struct {
Name string `json:"name"`
Version string `json:"version"`
2023-03-13 10:44:58 +01:00
}]()
path := fmt.Sprintf("/api/v1/agents/%d/specs", agentID)
if err := c.apiDelete(ctx, path, payload, &response, funcs...); err != nil {
return "", "", errors.WithStack(err)
2023-03-13 10:44:58 +01:00
}
if response.Error != nil {
return "", "", errors.WithStack(response.Error)
2023-03-13 10:44:58 +01:00
}
return response.Data.Name, response.Data.Version, nil
2023-03-13 10:44:58 +01:00
}