mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-20 06:01:10 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
76 lines
1.9 KiB
JavaScript
76 lines
1.9 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import BaseAdapter from './base';
|
|
import { decamelize } from '@ember/string';
|
|
import { getProperties } from '@ember/object';
|
|
|
|
export default BaseAdapter.extend({
|
|
createRecord(store, type, snapshot) {
|
|
const name = snapshot.id || snapshot.attr('name');
|
|
const url = this._url(
|
|
type.modelName,
|
|
{
|
|
backend: snapshot.record.backend,
|
|
scope: snapshot.record.scope,
|
|
},
|
|
name
|
|
);
|
|
return this.ajax(url, 'POST', { data: this.serialize(snapshot) }).then(() => {
|
|
return {
|
|
id: name,
|
|
name,
|
|
backend: snapshot.record.backend,
|
|
scope: snapshot.record.scope,
|
|
};
|
|
});
|
|
},
|
|
|
|
deleteRecord(store, type, snapshot) {
|
|
const name = snapshot.id || snapshot.attr('name');
|
|
const url = this._url(
|
|
type.modelName,
|
|
{
|
|
backend: snapshot.record.backend,
|
|
scope: snapshot.record.scope,
|
|
},
|
|
name
|
|
);
|
|
return this.ajax(url, 'DELETE');
|
|
},
|
|
|
|
serialize(snapshot) {
|
|
// the endpoint here won't allow sending `operation_all` and `operation_none` at the same time or with
|
|
// other operation_ values, so we manually check for them and send an abbreviated object
|
|
const json = snapshot.serialize();
|
|
const keys = snapshot.record.nonOperationFields.map(decamelize);
|
|
const nonOperationFields = getProperties(json, keys);
|
|
for (const field in nonOperationFields) {
|
|
if (nonOperationFields[field] == null) {
|
|
delete nonOperationFields[field];
|
|
}
|
|
}
|
|
if (json.operation_all) {
|
|
return {
|
|
operation_all: true,
|
|
...nonOperationFields,
|
|
};
|
|
}
|
|
if (json.operation_none) {
|
|
return {
|
|
operation_none: true,
|
|
...nonOperationFields,
|
|
};
|
|
}
|
|
delete json.operation_none;
|
|
delete json.operation_all;
|
|
return json;
|
|
},
|
|
|
|
updateRecord() {
|
|
return this.createRecord(...arguments);
|
|
},
|
|
});
|