vault/ui/app/adapters/pki/issuer.js
claire bontempo ccaed88947
UI: pki cross-sign issuers (#18695)
* make cross-sign component

* remove type from obj-list-input

* finish skeleton of component

* handle change on init

* finish cross-sign form

* add cancel transition

* update pki/issuer adapter to accept backend passed from adapterOptions

* first draft of cross-signing issuers component

* refactor to accommodate listing signed certs

* changes to config adapter and model, likely will need to revert and manually add to pki/action

* add args to infotooltip, move header to cross-sign route

* use pki/action model

* move header to route file

* finish displaying signed certificates

* finish styling

* add issuer id to cross-sign breadcrumbs

* add parsed cert data to requests

* add status count

* add error banner back
2023-01-25 19:37:20 +00:00

56 lines
1.5 KiB
JavaScript

import ApplicationAdapter from '../application';
import { encodePath } from 'vault/utils/path-encoding-helpers';
export default class PkiIssuerAdapter extends ApplicationAdapter {
namespace = 'v1';
_getBackend(snapshot) {
const { record, adapterOptions } = snapshot;
return adapterOptions?.mount || record.backend;
}
optionsForQuery(id) {
const data = {};
if (!id) {
data['list'] = true;
}
return { data };
}
urlForQuery(backend, id) {
const baseUrl = `${this.buildURL()}/${encodePath(backend)}`;
if (id) {
return `${baseUrl}/issuer/${encodePath(id)}`;
} else {
return `${baseUrl}/issuers`;
}
}
createRecord(store, type, snapshot) {
let url = this.urlForQuery(this._getBackend(snapshot));
if (snapshot.adapterOptions.import) {
url = `${url}/import/bundle`;
}
return this.ajax(url, 'POST', { data: this.serialize(snapshot) }).then((resp) => {
return resp;
});
}
updateRecord(store, type, snapshot) {
const { issuerId } = snapshot.record;
const backend = this._getBackend(snapshot);
const data = this.serialize(snapshot);
const url = this.urlForQuery(backend, issuerId);
return this.ajax(url, 'POST', { data });
}
query(store, type, query) {
return this.ajax(this.urlForQuery(query.backend), 'GET', this.optionsForQuery());
}
queryRecord(store, type, query) {
const { backend, id } = query;
return this.ajax(this.urlForQuery(backend, id), 'GET', this.optionsForQuery(id));
}
}