open-vault/ui/app/adapters/lease.js
Chelsea Shaw dd49b3bea3
UI: Use correct endpoint for force revoke prefix (#16930)
* Use correct endpoint for force revoke prefix

* Add changelog
2022-08-30 09:33:01 -07:00

59 lines
1.4 KiB
JavaScript

import ApplicationAdapter from './application';
import { encodePath } from 'vault/utils/path-encoding-helpers';
export default ApplicationAdapter.extend({
revokePrefix(prefix) {
let url = this.buildURL() + '/leases/revoke-prefix/' + encodePath(prefix);
url = url.replace(/\/$/, '');
return this.ajax(url, 'PUT');
},
forceRevokePrefix(prefix) {
let url = this.buildURL() + '/leases/revoke-force/' + encodePath(prefix);
url = url.replace(/\/$/, '');
return this.ajax(url, 'PUT');
},
renew(lease_id, increment) {
let url = this.buildURL() + '/leases/renew';
return this.ajax(url, 'PUT', {
data: {
lease_id,
increment,
},
});
},
deleteRecord(store, type, snapshot) {
const lease_id = snapshot.id;
return this.ajax(this.buildURL() + '/leases/revoke', 'PUT', {
data: {
lease_id,
},
});
},
queryRecord(store, type, query) {
const { lease_id } = query;
return this.ajax(this.buildURL() + '/leases/lookup', 'PUT', {
data: {
lease_id,
},
});
},
query(store, type, query) {
const prefix = query.prefix || '';
return this.ajax(this.buildURL() + '/leases/lookup/' + encodePath(prefix), 'GET', {
data: {
list: true,
},
}).then((resp) => {
if (prefix) {
resp.prefix = prefix;
}
return resp;
});
},
});