fleet/server/service/client_teams.go
Tomas Touceda 9863b0f4bb
Issue 1361 fleetctl teams (#1405)
* WIP

* Add get user_roles and apply for a user_roles spec to fleetctl

* Uncomment other tests

* Update test to check output

* Update test with the new struct

* Mock token so that it doesn't pick up the one in the local machine

* Address review comments

* Fix printJSON and printYaml

* Fix merge conflict error

* WIP

* wip

* wip

* Finish implementation

* Address review comments

* Fix flaky test
2021-07-19 16:48:49 -03:00

26 lines
723 B
Go

package service
import (
"github.com/fleetdm/fleet/v4/server/fleet"
)
// ListTeams retrieves the list of teams.
func (c *Client) ListTeams() ([]fleet.Team, error) {
verb, path := "GET", "/api/v1/fleet/teams"
var responseBody listTeamsResponse
err := c.authenticatedRequest(nil, verb, path, &responseBody)
if err != nil {
return nil, err
}
return responseBody.Teams, nil
}
// ApplyTeams sends the list of Teams to be applied to the
// Fleet instance.
func (c *Client) ApplyTeams(specs []*fleet.TeamSpec) error {
req := applyTeamSpecsRequest{Specs: specs}
verb, path := "POST", "/api/v1/fleet/spec/teams"
var responseBody applyTeamSpecsResponse
return c.authenticatedRequest(req, verb, path, &responseBody)
}