fleet/server/service/client_android_certificates.go
Konstantin Sykulev 0961c263cf
Added subject name to certificate template list endpoint response (#37028)
**Related issue:** Resolves #36970

# Checklist for submitter

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

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] If paths of existing endpoints are modified without backwards
compatibility, checked the frontend/CLI for any necessary changes

## Testing

- [x] Added/updated automated tests
- [x] Where appropriate, [automated tests simulate multiple hosts and
test for host
isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing)
(updates to one hosts's records do not affect another)
- [x] QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

- [x] Confirmed that the fix is not expected to adversely impact load
test results
- [x] Alerted the release DRI if additional load testing is needed
2025-12-11 05:38:59 -06:00

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 := "team_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)
}