[ML] Fixing update datafeed endpoint (#119515) (#119614)

* [ML] Fixing update datafeed endpoint

* adding comments

* using internal user

* updating comment

Co-authored-by: James Gowdy <jgowdy@elastic.co>
This commit is contained in:
Kibana Machine 2021-11-24 10:36:06 -05:00 committed by GitHub
parent e2e9f73567
commit 10bd0ea8c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -471,7 +471,24 @@ export function getMlClient(
},
async updateDatafeed(...p: Parameters<MlClient['updateDatafeed']>) {
await datafeedIdsCheck(p);
return mlClient.updateDatafeed(...p);
// Temporary workaround for the incorrect updateDatafeed function in the esclient
if (p.length === 0 || p[0] === undefined) {
// Temporary generic error message. This should never be triggered
// but is added for type correctness below
throw new Error('Incorrect arguments supplied');
}
const { datafeed_id: id, body } = p[0];
return client.asInternalUser.transport.request({
method: 'POST',
path: `/_ml/datafeeds/${id}/_update`,
body,
});
// this should be reinstated once https://github.com/elastic/elasticsearch-js/issues/1601
// is fixed
// return mlClient.updateDatafeed(...p);
},
async updateFilter(...p: Parameters<MlClient['updateFilter']>) {
return mlClient.updateFilter(...p);