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 #41391 # Details This PR updates front-end API calls to use new URLs and API params, so that the front end doesn't cause deprecation warnings to appear on the server. # 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, should not be user-visible ## Testing - [X] Added/updated automated tests - [ ] QA'd all new/changed functionality manually The biggest risk here is not that we missed a spot that still causes a deprecation warning, but that we might inadvertently make a change that breaks the front end, for instance by sending `fleet_id` to a function that drops it silently and thus sends no ID to the server. Fortunately we use TypeScript in virtually every place affected by these changes, so the code would not compile if there were mismatches between the API expectation and what we're sending. Still, spot checking as many places as possible both for deprecation-warning leaks and loss of functionality is important. ## Summary by CodeRabbit * **Refactor** * Updated API nomenclature across the application to use "fleets" instead of "teams" and "reports" instead of "queries" in endpoint paths and request/response payloads. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import sendRequest from "services";
|
|
|
|
import endpoints from "utilities/endpoints";
|
|
import { buildQueryStringFromParams } from "utilities/url";
|
|
|
|
// TODO - move disk encryption types like this to dedicated file
|
|
import { DiskEncryptionStatus } from "interfaces/mdm";
|
|
import { APP_CONTEXT_NO_TEAM_ID } from "interfaces/team";
|
|
|
|
export interface IDiskEncryptionStatusAggregate {
|
|
macos: number;
|
|
windows: number;
|
|
linux: number;
|
|
}
|
|
|
|
export type IDiskEncryptionSummaryResponse = Record<
|
|
DiskEncryptionStatus,
|
|
IDiskEncryptionStatusAggregate
|
|
>;
|
|
|
|
const diskEncryptionService = {
|
|
getDiskEncryptionSummary: (teamId?: number) => {
|
|
let { DISK_ENCRYPTION: path } = endpoints;
|
|
|
|
if (teamId) {
|
|
path = `${path}?${buildQueryStringFromParams({ fleet_id: teamId })}`;
|
|
}
|
|
return sendRequest("GET", path);
|
|
},
|
|
updateDiskEncryption: (
|
|
enableDiskEncryption: boolean,
|
|
requireBitLockerPIN: boolean,
|
|
teamId?: number
|
|
) => {
|
|
// TODO - use same endpoint for both once issue with new endpoint for no team is resolved
|
|
const {
|
|
UPDATE_DISK_ENCRYPTION: teamsEndpoint,
|
|
CONFIG: noTeamsEndpoint,
|
|
} = endpoints;
|
|
if (teamId === 0) {
|
|
return sendRequest("PATCH", noTeamsEndpoint, {
|
|
mdm: {
|
|
enable_disk_encryption: enableDiskEncryption,
|
|
windows_require_bitlocker_pin: requireBitLockerPIN,
|
|
},
|
|
});
|
|
}
|
|
return sendRequest("POST", teamsEndpoint, {
|
|
enable_disk_encryption: enableDiskEncryption,
|
|
windows_require_bitlocker_pin: requireBitLockerPIN,
|
|
// TODO - it would be good to be able to use an API_CONTEXT_NO_TEAM_ID here, but that is
|
|
// currently set to 0, which should actually be undefined since the server expects teamId ==
|
|
// nil for no teams, not 0.
|
|
fleet_id: teamId === APP_CONTEXT_NO_TEAM_ID ? undefined : teamId,
|
|
});
|
|
},
|
|
triggerLinuxDiskEncryptionKeyEscrow: (token: string) => {
|
|
const { DEVICE_TRIGGER_LINUX_DISK_ENCRYPTION_KEY_ESCROW } = endpoints;
|
|
return sendRequest(
|
|
"POST",
|
|
DEVICE_TRIGGER_LINUX_DISK_ENCRYPTION_KEY_ESCROW(token)
|
|
);
|
|
},
|
|
};
|
|
|
|
export default diskEncryptionService;
|