mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #41385 # Details This PR updates `fleetctl` to use the new API urls and params when communicating with Fleet server. This avoids deprecation warnings showing up on the server that users won't be able to fix. Most of the changes are straightforward `team_id` -> `fleet_id`. A couple of code changes have been pointed out. The most interesting is in icon URLs, which can be persisted in the database (so we'll need to do a migration in Fleet 5 if we want to drop support for `team_id`. Similarly the FMA download urls are briefly persisted in the db for the purpose of sending MDM commands. If we drop team_id support in Fleet 5 there could be a brief window where there are unprocessed commands in the db still with `team_id` in them, so we'll probably want to migrate those as well. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. n/a - all internal ## Testing - [X] Added/updated automated tests - [X] QA'd all new/changed functionality manually - [X] ran `fleetctl gitops` on main and saw a bunch of deprecation warnings, ran it on this branch and the warnings were gone 💨 - [X] same with `fleetctl generate-gitops` - [X] ran `fleetctl get` commands and verified that the new URLs and params were used - [X] ran `fleetctl apply` commands and verified that the new URLs and params were used
33 lines
1.4 KiB
Go
33 lines
1.4 KiB
Go
package service
|
|
|
|
import (
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
// GetCertificateTemplates retrieves the list of Certificate Templates for a team.
|
|
func (c *Client) GetCertificateTemplates(teamID string) ([]*fleet.CertificateTemplateResponseSummary, error) {
|
|
verb, path := "GET", "/api/latest/fleet/certificates"
|
|
var responseBody listCertificateTemplatesResponse
|
|
query := "fleet_id=" + teamID
|
|
err := c.authenticatedRequestWithQuery(nil, verb, path, &responseBody, query)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return responseBody.Certificates, nil
|
|
}
|
|
|
|
// ApplyCertificateSpecs sends a list of certificate specs to the fleet instance to be added/updated.
|
|
func (c *Client) ApplyCertificateSpecs(specs []*fleet.CertificateRequestSpec) error {
|
|
req := applyCertificateTemplateSpecsRequest{Specs: specs}
|
|
verb, path := "POST", "/api/latest/fleet/spec/certificates"
|
|
var responseBody applyCertificateTemplateSpecsResponse
|
|
return c.authenticatedRequest(req, verb, path, &responseBody)
|
|
}
|
|
|
|
// DeleteCertificateTemplates sends a list of certificate template IDs to be deleted.
|
|
func (c *Client) DeleteCertificateTemplates(certificateTemplateIDs []uint, teamID uint) error {
|
|
verb, path := "DELETE", "/api/latest/fleet/spec/certificates"
|
|
req := deleteCertificateTemplateSpecsRequest{IDs: certificateTemplateIDs, TeamID: teamID}
|
|
var responseBody deleteCertificateTemplateSpecsResponse
|
|
return c.authenticatedRequest(req, verb, path, &responseBody)
|
|
}
|