fleet/server/service/client_certificate_authorities.go
Aaron Levy 466f91a96c
Correcting client to omit request body for GET and DELETE requests (#32881)
Fixes #31700

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] 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.
2025-09-11 16:18:17 -05:00

23 lines
1.1 KiB
Go

package service
import "github.com/fleetdm/fleet/v4/server/fleet"
// GetCertificateAuthoritiesSpec fetches the certificate authorities stored on the server
func (c *Client) GetCertificateAuthoritiesSpec(includeSecrets bool) (*fleet.GroupedCertificateAuthorities, error) {
verb, path := "GET", "/api/latest/fleet/spec/certificate_authorities"
var responseBody getCertificateAuthoritiesSpecResponse
query := ""
if includeSecrets {
query = "include_secrets=true"
}
err := c.authenticatedRequestWithQuery(nil, verb, path, &responseBody, query)
return responseBody.CertificateAuthorities, err
}
// ApplyCertificateAuthoritiesSpec applies the certificate authorities.
func (c *Client) ApplyCertificateAuthoritiesSpec(groupedCAs fleet.GroupedCertificateAuthorities, opts fleet.ApplySpecOptions) error {
req := batchApplyCertificateAuthoritiesRequest{CertificateAuthorities: groupedCAs, DryRun: opts.DryRun}
verb, path := "POST", "/api/latest/fleet/spec/certificate_authorities"
var responseBody batchApplyCertificateAuthoritiesResponse
return c.authenticatedRequestWithQuery(req, verb, path, &responseBody, opts.RawQuery())
}