fleet/frontend/services/entities/mdm.ts
Gabriel Hernandez 575c0af92a
Revert "add windows bitlocker to mdm controls page (#13953)" (#13979)
revert windows bitlocker UI work
2023-09-18 18:25:49 +01:00

182 lines
5.0 KiB
TypeScript

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { FileVaultProfileStatus } from "interfaces/mdm";
import { APP_CONTEXT_NO_TEAM_ID } from "interfaces/team";
import sendRequest from "services";
import endpoints from "utilities/endpoints";
import { buildQueryStringFromParams } from "utilities/url";
export type IFileVaultSummaryResponse = Record<FileVaultProfileStatus, number>;
export interface IEulaMetadataResponse {
name: string;
token: string;
created_at: string;
}
export default {
downloadDeviceUserEnrollmentProfile: (token: string) => {
const { DEVICE_USER_MDM_ENROLLMENT_PROFILE } = endpoints;
return sendRequest("GET", DEVICE_USER_MDM_ENROLLMENT_PROFILE(token));
},
resetEncryptionKey: (token: string) => {
const { DEVICE_USER_RESET_ENCRYPTION_KEY } = endpoints;
return sendRequest("POST", DEVICE_USER_RESET_ENCRYPTION_KEY(token));
},
unenrollHostFromMdm: (hostId: number, timeout?: number) => {
const { HOST_MDM_UNENROLL } = endpoints;
return sendRequest(
"PATCH",
HOST_MDM_UNENROLL(hostId),
undefined,
undefined,
timeout
);
},
requestCSR: (email: string, organization: string) => {
const { MDM_REQUEST_CSR } = endpoints;
return sendRequest("POST", MDM_REQUEST_CSR, {
email_address: email,
organization,
});
},
getProfiles: (teamId = APP_CONTEXT_NO_TEAM_ID) => {
const path = `${endpoints.MDM_PROFILES}?${buildQueryStringFromParams({
team_id: teamId,
})}`;
return sendRequest("GET", path);
},
uploadProfile: (file: File, teamId?: number) => {
const { MDM_PROFILES } = endpoints;
const formData = new FormData();
formData.append("profile", file);
if (teamId) {
formData.append("team_id", teamId.toString());
}
return sendRequest("POST", MDM_PROFILES, formData);
},
downloadProfile: (profileId: number) => {
const { MDM_PROFILE } = endpoints;
return sendRequest("GET", MDM_PROFILE(profileId));
},
deleteProfile: (profileId: number) => {
const { MDM_PROFILE } = endpoints;
return sendRequest("DELETE", MDM_PROFILE(profileId));
},
getAggregateProfileStatuses: (teamId = APP_CONTEXT_NO_TEAM_ID) => {
const path = `${
endpoints.MDM_PROFILES_AGGREGATE_STATUSES
}?${buildQueryStringFromParams({ team_id: teamId })}`;
return sendRequest("GET", path);
},
getDiskEncryptionAggregate: (teamId?: number) => {
let { MDM_APPLE_DISK_ENCRYPTION_AGGREGATE: path } = endpoints;
if (teamId) {
path = `${path}?${buildQueryStringFromParams({ team_id: teamId })}`;
}
return sendRequest("GET", path);
},
updateAppleMdmSettings: (enableDiskEncryption: boolean, teamId?: number) => {
const {
MDM_UPDATE_APPLE_SETTINGS: teamsEndpoint,
CONFIG: noTeamsEndpoint,
} = endpoints;
if (teamId === 0) {
return sendRequest("PATCH", noTeamsEndpoint, {
mdm: {
macos_settings: { enable_disk_encryption: enableDiskEncryption },
},
});
}
return sendRequest("PATCH", teamsEndpoint, {
enable_disk_encryption: enableDiskEncryption,
team_id: teamId,
});
},
initiateMDMAppleSSO: () => {
const { MDM_APPLE_SSO } = endpoints;
return sendRequest("POST", MDM_APPLE_SSO, {});
},
getBootstrapPackageMetadata: (teamId: number) => {
const { MDM_BOOTSTRAP_PACKAGE_METADATA } = endpoints;
return sendRequest("GET", MDM_BOOTSTRAP_PACKAGE_METADATA(teamId));
},
uploadBootstrapPackage: (file: File, teamId?: number) => {
const { MDM_BOOTSTRAP_PACKAGE } = endpoints;
const formData = new FormData();
formData.append("package", file);
if (teamId) {
formData.append("team_id", teamId.toString());
}
return sendRequest("POST", MDM_BOOTSTRAP_PACKAGE, formData);
},
deleteBootstrapPackage: (teamId: number) => {
const { MDM_BOOTSTRAP_PACKAGE } = endpoints;
return sendRequest("DELETE", `${MDM_BOOTSTRAP_PACKAGE}/${teamId}`);
},
getBootstrapPackageAggregate: (teamId?: number) => {
let { MDM_BOOTSTRAP_PACKAGE_SUMMARY: path } = endpoints;
if (teamId) {
path = `${path}?${buildQueryStringFromParams({ team_id: teamId })}`;
}
return sendRequest("GET", path);
},
getEULAMetadata: () => {
const { MDM_EULA_METADATA } = endpoints;
return sendRequest("GET", MDM_EULA_METADATA);
},
uploadEULA: (file: File) => {
const { MDM_EULA_UPLOAD } = endpoints;
const formData = new FormData();
formData.append("eula", file);
return sendRequest("POST", MDM_EULA_UPLOAD, formData);
},
deleteEULA: (token: string) => {
const { MDM_EULA } = endpoints;
return sendRequest("DELETE", MDM_EULA(token));
},
downloadEULA: (token: string) => {
const { MDM_EULA } = endpoints;
return sendRequest("GET", MDM_EULA(token));
},
updateEndUserAuthentication: (teamId: number, isEnabled: boolean) => {
const { MDM_SETUP } = endpoints;
return sendRequest("PATCH", MDM_SETUP, {
team_id: teamId,
enable_end_user_authentication: isEnabled,
});
},
};