fleet/frontend/kolide/index.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

import Base from './base';
import endpoints from './endpoints';
class Kolide extends Base {
forgotPassword ({ email }) {
const { FORGOT_PASSWORD } = endpoints;
const forgotPasswordEndpoint = this.baseURL + FORGOT_PASSWORD;
return this.post(forgotPasswordEndpoint, JSON.stringify({ email }));
}
getConfig = () => {
const { CONFIG } = endpoints;
return this.authenticatedGet(this.endpoint(CONFIG))
.then(response => { return response.org_info; });
}
getUsers = () => {
const { USERS } = endpoints;
return this.authenticatedGet(this.endpoint(USERS))
.then(response => { return response.users; });
}
loginUser ({ username, password }) {
const { LOGIN } = endpoints;
const loginEndpoint = this.baseURL + LOGIN;
return this.post(loginEndpoint, JSON.stringify({ username, password }));
}
logout () {
const { LOGOUT } = endpoints;
const logoutEndpoint = this.baseURL + LOGOUT;
return this.authenticatedPost(logoutEndpoint);
}
me () {
const { ME } = endpoints;
const meEndpoint = this.baseURL + ME;
return this.authenticatedGet(meEndpoint);
}
resetPassword (formData) {
const { RESET_PASSWORD } = endpoints;
const resetPasswordEndpoint = this.baseURL + RESET_PASSWORD;
return this.post(resetPasswordEndpoint, JSON.stringify(formData));
}
updateUser = (user, formData) => {
const { USERS } = endpoints;
const updateUserEndpoint = `${this.baseURL}${USERS}/${user.id}`;
return this.authenticatedPatch(updateUserEndpoint, JSON.stringify(formData));
}
}
export default new Kolide();