-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
229 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
'use strict' | ||
|
||
/* eslint camelcase: 0 */ | ||
/* eslint no-unused-vars: 0 */ | ||
|
||
function buildCatMlJobs (opts) { | ||
// eslint-disable-next-line no-unused-vars | ||
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts | ||
|
||
const acceptedQuerystring = [ | ||
'allow_no_jobs', | ||
'bytes', | ||
'format', | ||
'h', | ||
'help', | ||
's', | ||
'time', | ||
'v' | ||
] | ||
|
||
const snakeCase = { | ||
allowNoJobs: 'allow_no_jobs' | ||
|
||
} | ||
|
||
/** | ||
* Perform a cat.ml.jobs request | ||
* http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html | ||
*/ | ||
return function catMlJobs (params, options, callback) { | ||
options = options || {} | ||
if (typeof options === 'function') { | ||
callback = options | ||
options = {} | ||
} | ||
if (typeof params === 'function' || params == null) { | ||
callback = params | ||
params = {} | ||
options = {} | ||
} | ||
|
||
// validate headers object | ||
if (options.headers != null && typeof options.headers !== 'object') { | ||
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) | ||
return handleError(err, callback) | ||
} | ||
|
||
var warnings = [] | ||
var { method, body, jobId, job_id, ...querystring } = params | ||
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) | ||
|
||
var ignore = options.ignore | ||
if (typeof ignore === 'number') { | ||
options.ignore = [ignore] | ||
} | ||
|
||
var path = '' | ||
|
||
if ((job_id || jobId) != null) { | ||
if (method == null) method = 'GET' | ||
path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) | ||
} else { | ||
if (method == null) method = 'GET' | ||
path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' | ||
} | ||
|
||
// build request object | ||
const request = { | ||
method, | ||
path, | ||
body: null, | ||
querystring | ||
} | ||
|
||
options.warnings = warnings.length === 0 ? null : warnings | ||
return makeRequest(request, options, callback) | ||
} | ||
} | ||
|
||
module.exports = buildCatMlJobs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.