mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
// ApplyPacks sends the list of Packs to be applied (upserted) to the
|
|
// Fleet instance.
|
|
func (c *Client) ApplyPacks(specs []*fleet.PackSpec) error {
|
|
req := applyPackSpecsRequest{Specs: specs}
|
|
verb, path := "POST", "/api/latest/fleet/spec/packs"
|
|
var responseBody applyPackSpecsResponse
|
|
return c.authenticatedRequest(req, verb, path, &responseBody)
|
|
}
|
|
|
|
// GetPack retrieves information about a pack
|
|
func (c *Client) GetPack(name string) (*fleet.PackSpec, error) {
|
|
verb, path := "GET", "/api/latest/fleet/spec/packs/"+url.PathEscape(name)
|
|
var responseBody getPackSpecResponse
|
|
err := c.authenticatedRequest(nil, verb, path, &responseBody)
|
|
return responseBody.Spec, err
|
|
}
|
|
|
|
// GetPacks retrieves the list of all Packs.
|
|
func (c *Client) GetPacks() ([]*fleet.PackSpec, error) {
|
|
verb, path := "GET", "/api/latest/fleet/spec/packs"
|
|
var responseBody getPackSpecsResponse
|
|
err := c.authenticatedRequest(nil, verb, path, &responseBody)
|
|
return responseBody.Specs, err
|
|
}
|
|
|
|
// DeletePack deletes the pack with the matching name.
|
|
func (c *Client) DeletePack(name string) error {
|
|
verb, path := "DELETE", "/api/latest/fleet/packs/"+url.PathEscape(name)
|
|
var responseBody deletePackResponse
|
|
return c.authenticatedRequest(nil, verb, path, &responseBody)
|
|
}
|