2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2018-04-03 14:16:57 +00:00
|
|
|
import ApplicationAdapter from './application';
|
2019-03-01 16:08:30 +00:00
|
|
|
import { encodePath } from 'vault/utils/path-encoding-helpers';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
export default ApplicationAdapter.extend({
|
|
|
|
revokePrefix(prefix) {
|
2019-03-01 16:08:30 +00:00
|
|
|
let url = this.buildURL() + '/leases/revoke-prefix/' + encodePath(prefix);
|
2018-04-03 14:16:57 +00:00
|
|
|
url = url.replace(/\/$/, '');
|
|
|
|
return this.ajax(url, 'PUT');
|
|
|
|
},
|
|
|
|
|
|
|
|
forceRevokePrefix(prefix) {
|
2022-08-30 16:33:01 +00:00
|
|
|
let url = this.buildURL() + '/leases/revoke-force/' + encodePath(prefix);
|
2018-04-03 14:16:57 +00:00
|
|
|
url = url.replace(/\/$/, '');
|
|
|
|
return this.ajax(url, 'PUT');
|
|
|
|
},
|
|
|
|
|
2021-04-02 20:23:56 +00:00
|
|
|
renew(lease_id, increment) {
|
2022-11-09 23:15:31 +00:00
|
|
|
const url = this.buildURL() + '/leases/renew';
|
2018-04-03 14:16:57 +00:00
|
|
|
return this.ajax(url, 'PUT', {
|
|
|
|
data: {
|
|
|
|
lease_id,
|
2021-04-02 20:23:56 +00:00
|
|
|
increment,
|
2018-04-03 14:16:57 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
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 || '';
|
2019-03-01 16:08:30 +00:00
|
|
|
return this.ajax(this.buildURL() + '/leases/lookup/' + encodePath(prefix), 'GET', {
|
2018-04-03 14:16:57 +00:00
|
|
|
data: {
|
|
|
|
list: true,
|
|
|
|
},
|
2021-12-17 03:44:29 +00:00
|
|
|
}).then((resp) => {
|
2018-04-03 14:16:57 +00:00
|
|
|
if (prefix) {
|
|
|
|
resp.prefix = prefix;
|
|
|
|
}
|
|
|
|
return resp;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|