Kenia 5e7ef183ea
ui: Use of header default ACL policy (#11192)
* Use of header default ACL policy

* Update test for dc serializer
2021-09-30 13:01:48 -04:00

32 lines
741 B
JavaScript

import { inject as service } from '@ember/service';
import Serializer from './application';
export default class DcSerializer extends Serializer {
@service('env') env;
primaryKey = 'Name';
respondForQuery(respond, query) {
return respond(function(headers, body) {
return {
body,
headers,
};
});
}
normalizePayload(payload, id, requestType) {
switch (requestType) {
case 'query':
return payload.body.map(item => {
return {
Local: this.env.var('CONSUL_DATACENTER_LOCAL') === item,
[this.primaryKey]: item,
DefaultACLPolicy: payload.headers['x-consul-default-acl-policy'],
};
});
}
return payload;
}
}