open-nomad/ui/app/adapters/evaluation.js
Phil Renaud e9219a1ae0
Allow wildcard for Evaluations API (#13530)
* Failing test and TODO for wildcard

* Alias the namespace query parameter for Evals

* eval: fix list when using ACLs and * namespace

Apply the same verification process as in job, allocs and scaling
policy list endpoints to handle the eval list when using an ACL token
with limited namespace support but querying using the `*` wildcard
namespace.

* changelog: add entry for #13530

* ui: set namespace when querying eval

Evals have a unique UUID as ID, but when querying them the Nomad API
still expects a namespace query param, otherwise it assumes `default`.

Co-authored-by: Luiz Aoqui <luiz@hashicorp.com>
2022-07-11 16:42:17 -04:00

23 lines
683 B
JavaScript

import ApplicationAdapter from './application';
import classic from 'ember-classic-decorator';
@classic
export default class EvaluationAdapter extends ApplicationAdapter {
handleResponse(_status, headers) {
const result = super.handleResponse(...arguments);
result.meta = { nextToken: headers['x-nomad-nexttoken'] };
return result;
}
urlForFindRecord(_id, _modelName, snapshot) {
const namespace = snapshot.attr('namespace') || 'default';
const baseURL = super.urlForFindRecord(...arguments);
const url = `${baseURL}?namespace=${namespace}`;
if (snapshot.adapterOptions?.related) {
return `${url}&related=true`;
}
return url;
}
}