You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
1014 B

import { getBackendSrv } from 'app/core/services/backend_srv';
import { ApiKey, ThunkResult } from 'app/types';
import { apiKeysLoaded, setSearchQuery } from './reducers';
export function addApiKey(
apiKey: ApiKey,
openModal: (key: string) => void,
includeExpired: boolean
): ThunkResult<void> {
return async (dispatch) => {
const result = await getBackendSrv().post('/api/auth/keys', apiKey);
dispatch(setSearchQuery(''));
dispatch(loadApiKeys(includeExpired));
openModal(result.key);
};
}
export function loadApiKeys(includeExpired: boolean): ThunkResult<void> {
return async (dispatch) => {
const response = await getBackendSrv().get('/api/auth/keys?includeExpired=' + includeExpired);
dispatch(apiKeysLoaded(response));
};
}
export function deleteApiKey(id: number, includeExpired: boolean): ThunkResult<void> {
return async (dispatch) => {
getBackendSrv()
.delete(`/api/auth/keys/${id}`)
.then(() => dispatch(loadApiKeys(includeExpired)));
};
}