open-vault/ui/app/adapters/lease.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-04-03 14:16:57 +00:00
import ApplicationAdapter from './application';
export default ApplicationAdapter.extend({
revokePrefix(prefix) {
let url = this.buildURL() + '/leases/revoke-prefix/' + prefix;
url = url.replace(/\/$/, '');
return this.ajax(url, 'PUT');
},
forceRevokePrefix(prefix) {
let url = this.buildURL() + '/leases/revoke-prefix/' + prefix;
url = url.replace(/\/$/, '');
return this.ajax(url, 'PUT');
},
renew(lease_id, interval) {
let url = this.buildURL() + '/leases/renew';
return this.ajax(url, 'PUT', {
data: {
lease_id,
interval,
},
});
},
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/' + prefix, 'GET', {
data: {
list: true,
},
}).then(resp => {
if (prefix) {
resp.prefix = prefix;
}
return resp;
});
},
});