Renamed REST path parameters to snake case. (elastic/elasticsearch#367)

* Renamed REST path parameters to snake case.

And added missing parameter descriptions

* Document endpoint which accept body parameters

* Endpoints that support body parameters must also accept POST

Original commit: elastic/x-pack-elasticsearch@2cad2e8af6
This commit is contained in:
David Kyle 2016-11-29 16:04:08 +00:00 committed by GitHub
parent c99ee42f0e
commit 688b5cc202
26 changed files with 154 additions and 124 deletions

View File

@ -32,8 +32,10 @@ public class RestGetInfluencersAction extends BaseRestHandler {
super(settings);
this.transportAction = transportAction;
controller.registerHandler(RestRequest.Method.GET,
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/influencers",
this);
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/influencers", this);
// endpoints that support body parameters must also accept POST
controller.registerHandler(RestRequest.Method.POST,
PrelertPlugin.BASE_PATH + "results/{" + Job.ID.getPreferredName() + "}/influencers", this);
}
@Override

View File

@ -52,6 +52,8 @@ public class RestGetModelSnapshotsAction extends BaseRestHandler {
super(settings);
this.transportGetModelSnapshotsAction = transportGetModelSnapshotsAction;
controller.registerHandler(RestRequest.Method.GET, PrelertPlugin.BASE_PATH + "modelsnapshots/{jobId}", this);
// endpoints that support body parameters must also accept POST
controller.registerHandler(RestRequest.Method.POST, PrelertPlugin.BASE_PATH + "modelsnapshots/{jobId}", this);
}
@Override

View File

@ -2,10 +2,10 @@
"xpack.prelert.close_data": {
"methods": [ "POST" ],
"url": {
"path": "/_xpack/prelert/data/{jobId}/_close",
"paths": [ "/_xpack/prelert/data/{jobId}/_close" ],
"path": "/_xpack/prelert/data/{job_id}/_close",
"paths": [ "/_xpack/prelert/data/{job_id}/_close" ],
"parts": {
"jobId": {
"job_id": {
"type": "string",
"required": true,
"description": "The name of the job to close"

View File

@ -2,15 +2,15 @@
"xpack.prelert.delete_model_snapshot": {
"methods": [ "DELETE" ],
"url": {
"path": "/_xpack/prelert/modelsnapshots/{jobId}/{snapshotId}",
"paths": [ "/_xpack/prelert/modelsnapshots/{jobId}/{snapshotId}" ],
"path": "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}",
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}" ],
"parts": {
"jobId": {
"job_id": {
"type": "string",
"required": true,
"description": "The ID of the job to fetch"
},
"snapshotId": {
"snapshot_id": {
"type": "string",
"required": true,
"description": "The Snapshot ID of the job to fetch"

View File

@ -4,12 +4,12 @@
"POST"
],
"url": {
"path": "/_xpack/prelert/data/{jobId}/_flush",
"path": "/_xpack/prelert/data/{job_id}/_flush",
"paths": [
"/_xpack/prelert/data/{jobId}/_flush"
"/_xpack/prelert/data/{job_id}/_flush"
],
"parts": {
"jobId": {
"job_id": {
"type": "string",
"required": true,
"description": "The name of the job to flush"
@ -33,6 +33,9 @@
"description": "Setting this tells the Engine API that no data prior to advanceTime is expected"
}
}
},
"body": {
"description": "Flush parameters"
}
}
}

View File

@ -2,29 +2,34 @@
"xpack.prelert.get_buckets": {
"methods": [ "GET", "POST" ],
"url": {
"path": "/_xpack/prelert/results/{jobId}/buckets/{timestamp}",
"path": "/_xpack/prelert/results/{job_id}/buckets/{timestamp}",
"paths": [
"/_xpack/prelert/results/{jobId}/buckets/{timestamp}",
"/_xpack/prelert/results/{jobId}/buckets"
"/_xpack/prelert/results/{job_id}/buckets/{timestamp}",
"/_xpack/prelert/results/{job_id}/buckets"
],
"parts": {
"jobId": {
"job_id": {
"type" : "string",
"required": true
"required": true,
"description": "ID of the job to get bucket results from"
},
"timestamp": {
"type" : "string"
"type" : "string",
"description" : "The timestamp of the desired single bucket result"
}
},
"params": {
"expand": {
"type": "boolean"
"type": "boolean",
"description" : "Include anomaly records"
},
"includeInterim": {
"type": "boolean"
"type": "boolean",
"description" : "Include interim results"
},
"partitionValue": {
"type": "string"
"type": "string",
"description": "If expand is true filter anomaly records by the partitionFieldValue"
},
"from": {
"type": "int",
@ -35,16 +40,20 @@
"description": "specifies a max number of buckets to get"
},
"start": {
"type": "string"
"type": "string",
"description" : "Start time filter for buckets"
},
"end": {
"type": "string"
"type": "string",
"description" : "End time filter for buckets"
},
"anomalyScore": {
"type": "double"
"type": "double",
"description": "Filter for the most anomalous buckets"
},
"maxNormalizedProbability": {
"type": "double"
"type": "double",
"description": "Filter for buckets containing the most anomalous records"
}
}
},

View File

@ -2,18 +2,20 @@
"xpack.prelert.get_categories": {
"methods": [ "GET" ],
"url": {
"path": "/_xpack/prelert/results/{jobId}/categorydefinitions/{categoryId}",
"path": "/_xpack/prelert/results/{job_id}/categorydefinitions/{category_id}",
"paths": [
"/_xpack/prelert/results/{jobId}/categorydefinitions/{categoryId}",
"/_xpack/prelert/results/{jobId}/categorydefinitions/"
"/_xpack/prelert/results/{job_id}/categorydefinitions/{category_id}",
"/_xpack/prelert/results/{job_id}/categorydefinitions/"
],
"parts": {
"jobId": {
"job_id": {
"type" : "string",
"required": true
"required": true,
"description": "The name of the job"
},
"categoryId": {
"type" : "string"
"category_id": {
"type" : "string",
"description" : "The identifier of the category definition of interest"
}
},
"params": {

View File

@ -1,18 +1,19 @@
{
"xpack.prelert.get_influencers": {
"methods": [ "GET" ],
"methods": [ "GET", "POST" ],
"url": {
"path": "/_xpack/prelert/results/{jobId}/influencers",
"paths": [ "/_xpack/prelert/results/{jobId}/influencers" ],
"path": "/_xpack/prelert/results/{job_id}/influencers",
"paths": [ "/_xpack/prelert/results/{job_id}/influencers" ],
"parts": {
"jobId": {
"job_id": {
"type" : "string",
"required": true
}
},
"params": {
"includeInterim": {
"type": "boolean"
"type": "boolean",
"description" : "Include interim results"
},
"from": {
"type": "int",
@ -45,6 +46,9 @@
"description": "whether the results should be sorted in decending order"
}
}
},
"body": {
"description": "Influencer selection criteria"
}
}
}

View File

@ -31,7 +31,7 @@
}
},
"body": {
"description" : "Job selection criteria"
"description": "Job selection criteria"
}
}
}

View File

@ -1,11 +1,11 @@
{
"xpack.prelert.get_model_snapshots": {
"methods": [ "GET" ],
"methods": [ "GET", "POST" ],
"url": {
"path": "/_xpack/prelert/modelsnapshots/{jobId}",
"paths": [ "/_xpack/prelert/modelsnapshots/{jobId}" ],
"path": "/_xpack/prelert/modelsnapshots/{job_id}",
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}" ],
"parts": {
"jobId": {
"job_id": {
"type": "string",
"required": true,
"description": "The ID of the job to fetch"
@ -14,7 +14,7 @@
"params": {
"from": {
"type": "integer",
"description": ""
"description": "Skips a number of documents"
},
"size": {
"type": "integer",
@ -42,6 +42,8 @@
}
}
},
"body": null
"body": {
"description": "Model snapshot selection criteria"
}
}
}

View File

@ -2,10 +2,10 @@
"xpack.prelert.get_records": {
"methods": [ "GET" ],
"url": {
"path": "/_xpack/prelert/results/{jobId}/records",
"paths": [ "/_xpack/prelert/results/{jobId}/records" ],
"path": "/_xpack/prelert/results/{job_id}/records",
"paths": [ "/_xpack/prelert/results/{job_id}/records" ],
"parts": {
"jobId": {
"job_id": {
"type" : "string",
"required": true
}
@ -15,7 +15,8 @@
"type": "boolean"
},
"includeInterim": {
"type": "boolean"
"type": "boolean",
"description" : "Include interim results"
},
"from": {
"type": "int",
@ -27,11 +28,13 @@
},
"start": {
"type": "string",
"required": true
"required": true,
"description" : "Start time filter for records"
},
"end": {
"type": "string",
"required": true
"required": true,
"description" : "End time filter for records"
},
"anomalyScore": {
"type": "double"
@ -40,13 +43,16 @@
"type": "double"
},
"partitionValue": {
"type": "string"
"type": "string",
"description": "Filter anomaly records by the partitionFieldValue"
},
"sort": {
"type": "string"
"type": "string",
"description": "Sort records by a particular field"
},
"desc": {
"type": "boolean"
"type": "boolean",
"description": "Set the sort direction"
}
}
}

View File

@ -2,10 +2,10 @@
"xpack.prelert.post_data": {
"methods": [ "POST" ],
"url": {
"path": "/_xpack/prelert/data/{jobId}",
"paths": [ "/_xpack/prelert/data/{jobId}" ],
"path": "/_xpack/prelert/data/{job_id}",
"paths": [ "/_xpack/prelert/data/{job_id}" ],
"parts": {
"jobId": {
"job_id": {
"type": "string",
"required": true,
"description": "The name of the job receiving the data"

View File

@ -7,7 +7,7 @@
"params": {
"overwrite": {
"type": "boolean",
"description": ""
"description": "Overwrite an existing job"
}
}
},

View File

@ -2,15 +2,15 @@
"xpack.prelert.put_model_snapshot_description": {
"methods": [ "PUT" ],
"url": {
"path": "/_xpack/prelert/modelsnapshots/{jobId}/{snapshotId}/description",
"paths": [ "/_xpack/prelert/modelsnapshots/{jobId}/{snapshotId}/description" ],
"path": "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}/description",
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}/{snapshot_id}/description" ],
"parts": {
"jobId": {
"job_id": {
"type": "string",
"required": true,
"description": "The ID of the job to fetch"
},
"snapshotId": {
"snapshot_id": {
"type": "string",
"required": true,
"description": "The ID of the snapshot whose description is to be updated"

View File

@ -2,20 +2,16 @@
"xpack.prelert.revert_model_snapshot": {
"methods": [ "POST" ],
"url": {
"path": "/_xpack/prelert/modelsnapshots/{jobId}/_revert",
"paths": [ "/_xpack/prelert/modelsnapshots/{jobId}/_revert" ],
"path": "/_xpack/prelert/modelsnapshots/{job_id}/_revert",
"paths": [ "/_xpack/prelert/modelsnapshots/{job_id}/_revert" ],
"parts": {
"jobId": {
"job_id": {
"type": "string",
"required": true,
"description": "The ID of the job to fetch"
}
},
"params": {
"from": {
"type": "integer",
"description": ""
},
"time": {
"type": "date",
"description": "revert to a snapshot with a timestamp no later than this time"
@ -34,6 +30,8 @@
}
}
},
"body": null
"body": {
"description": "Model snapshot selection criteria"
}
}
}

View File

@ -24,6 +24,8 @@
}
}
},
"body": null
"body": {
"description": "The start scheduler parameters"
}
}
}

View File

@ -78,10 +78,10 @@ setup:
- do:
catch: param
xpack.prelert.delete_model_snapshot:
jobId: "foo"
job_id: "foo"
---
"Test delete snapshot missing jobId":
"Test delete snapshot missing job_id":
- do:
catch: param
xpack.prelert.delete_model_snapshot:
@ -91,7 +91,7 @@ setup:
"Test valid delete snapshot":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
- match: { count: 2 }
- do:
@ -103,8 +103,8 @@ setup:
- do:
xpack.prelert.delete_model_snapshot:
jobId: "foo"
snapshotId: "foo1"
job_id: "foo"
snapshot_id: "foo1"
- match: { acknowledged: true }
- do:
@ -113,7 +113,7 @@ setup:
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
- match: { count: 1 }
- match: { modelSnapshots.0.snapshotId: "foo2"}
@ -128,11 +128,11 @@ setup:
"Test delete with in-use model":
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
snapshotId: "foo2"
- do:
catch: request
xpack.prelert.delete_model_snapshot:
jobId: "foo"
snapshotId: "foo2"
job_id: "foo"
snapshot_id: "foo2"

View File

@ -32,7 +32,7 @@ setup:
"Test get model snapshots API with no params":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
- match: { count: 2 }
@ -43,7 +43,7 @@ setup:
"Test get model snapshots API with start/end":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
start: "2016-05-01T00:00:00Z"
end: "2016-07-01T00:00:00Z"
@ -56,7 +56,7 @@ setup:
"Test get model snapshots API with ascending":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
desc: false
@ -68,7 +68,7 @@ setup:
"Test get model snapshots API with size":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
size: 1
@ -81,7 +81,7 @@ setup:
"Test get model snapshots API with from":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
from: 1

View File

@ -28,7 +28,7 @@ setup:
"Test result buckets api":
- do:
xpack.prelert.get_buckets:
jobId: "farequote"
job_id: "farequote"
start: "2016-05-01T00:00:00Z"
end: "2016-07-01T00:00:00Z"
@ -41,7 +41,7 @@ setup:
"Test result single bucket api":
- do:
xpack.prelert.get_buckets:
jobId: "farequote"
job_id: "farequote"
timestamp: "2016-06-01T00:00:00Z"
- match: { buckets.0.timestamp: 1464739200000}

View File

@ -26,7 +26,7 @@ setup:
"Test result categories api":
- do:
xpack.prelert.get_categories:
jobId: "farequote"
job_id: "farequote"
- match: { count: 2 }
- match: { categories.0.jobId: farequote }
@ -38,8 +38,8 @@ setup:
"Test result category api":
- do:
xpack.prelert.get_categories:
jobId: "farequote"
categoryId: "1"
job_id: "farequote"
category_id: "1"
- match: { categories.0.jobId: farequote }
- match: { categories.0.categoryId: 1 }

View File

@ -36,7 +36,7 @@ setup:
"Test result influencers api":
- do:
xpack.prelert.get_influencers:
jobId: "farequote"
job_id: "farequote"
start: "2016-05-01T00:00:00Z"
end: "2016-07-01T00:00:00Z"

View File

@ -42,7 +42,7 @@ setup:
"Test result records api":
- do:
xpack.prelert.get_records:
jobId: "farequote"
job_id: "farequote"
start: "2016-05-01T00:00:00Z"
end: "2016-07-01T00:00:00Z"

View File

@ -54,14 +54,14 @@ setup:
- do:
xpack.prelert.post_data:
jobId: job-stats-test
job_id: job-stats-test
body: >
{"airline":"AAL","responsetime":"132.2046","time":"1403481600"}
{"airline":"JZA","responsetime":"990.4628","time":"1403481600"}
- do:
xpack.prelert.flush_data:
jobId: job-stats-test
job_id: job-stats-test
- match: { acknowledged: true }

View File

@ -20,7 +20,7 @@ setup:
"Test POST data job api, flush, close and verify DataCounts doc":
- do:
xpack.prelert.post_data:
jobId: farequote
job_id: farequote
body: >
{"airline":"AAL","responsetime":"132.2046","sourcetype":"farequote","time":"1403481600"}
{"airline":"JZA","responsetime":"990.4628","sourcetype":"farequote","time":"1403481700"}
@ -37,12 +37,12 @@ setup:
- do:
xpack.prelert.flush_data:
jobId: farequote
job_id: farequote
- match: { acknowledged: true }
- do:
xpack.prelert.close_data:
jobId: farequote
job_id: farequote
- match: { acknowledged: true }
- do:
@ -72,7 +72,7 @@ setup:
- do:
catch: /parse_exception/
xpack.prelert.post_data:
jobId: foo
job_id: foo
resetStart: not_a_date
body: >
{"airline":"AAL","responsetime":"132.2046","sourcetype":"farequote","time":"1403481600"}
@ -81,7 +81,7 @@ setup:
- do:
catch: /parse_exception/
xpack.prelert.post_data:
jobId: foo
job_id: foo
resetEnd: end_not_a_date
body: >
{"airline":"AAL","responsetime":"132.2046","sourcetype":"farequote","time":"1403481600"}
@ -92,17 +92,17 @@ setup:
- do:
catch: /parse_exception/
xpack.prelert.flush_data:
jobId: foo
job_id: foo
start: not_a_date
- do:
catch: /parse_exception/
xpack.prelert.flush_data:
jobId: foo
job_id: foo
end: end_not_a_date
- do:
catch: /parse_exception/
xpack.prelert.flush_data:
jobId: foo
job_id: foo
advanceTime: advance_time_not_a_date

View File

@ -46,8 +46,8 @@ setup:
- do:
catch: request
xpack.prelert.put_model_snapshot_description:
jobId: "foo"
snapshotId: "foo"
job_id: "foo"
snapshot_id: "foo"
body: >
{
"some_field": "foo"
@ -57,7 +57,7 @@ setup:
"Test with valid description":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
description: "new_description"
- match: { count: 0 }
@ -65,8 +65,8 @@ setup:
- do:
xpack.prelert.put_model_snapshot_description:
jobId: "foo"
snapshotId: "foo"
job_id: "foo"
snapshot_id: "foo"
body: >
{
"description": "new_description"
@ -78,7 +78,7 @@ setup:
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
description: "new_description"
- match: { count: 1 }
@ -89,7 +89,7 @@ setup:
"Test with conflict against existing description":
- do:
xpack.prelert.get_model_snapshots:
jobId: "foo"
job_id: "foo"
description: "bar"
- match: { count: 1 }
@ -100,8 +100,8 @@ setup:
- do:
catch: request
xpack.prelert.put_model_snapshot_description:
jobId: "foo"
snapshotId: "foo"
job_id: "foo"
snapshot_id: "foo"
body: >
{
"description": "bar"

View File

@ -73,18 +73,18 @@ setup:
index: prelertresults-foo
---
"Test revert model with only jobId":
"Test revert model with only job_id":
- do:
catch: request
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
---
"Test revert model with invalid time":
- do:
catch: request
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
time: "foo"
---
@ -92,7 +92,7 @@ setup:
- do:
catch: /resource_not_found_exception/
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
snapshotId: "not_exist"
---
@ -100,14 +100,14 @@ setup:
- do:
catch: /resource_not_found_exception/
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
description: "foo"
---
"Test revert model with valid snapshotId":
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
snapshotId: "foo1"
- match: { exists: true }
@ -120,7 +120,7 @@ setup:
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
snapshotId: "foo2"
- match: { exists: true }
@ -135,7 +135,7 @@ setup:
"Test revert model with valid time":
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
time: "2016-06-02T01:00:00Z"
- match: { exists: true }
@ -148,7 +148,7 @@ setup:
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
time: "2016-06-01T01:00:00Z"
- match: { exists: true }
@ -163,7 +163,7 @@ setup:
"Test revert model with valid description":
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
description: "first"
- match: { exists: true }
@ -176,7 +176,7 @@ setup:
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
description: "second"
- match: { exists: true }
@ -191,7 +191,7 @@ setup:
"Test revert model with deleteInterveningResults":
- do:
xpack.prelert.get_buckets:
jobId: "foo"
job_id: "foo"
start: "2016-01-01T00:00:00Z"
end: "2016-12-01T00:00:00Z"
@ -199,7 +199,7 @@ setup:
- do:
xpack.prelert.revert_model_snapshot:
jobId: "foo"
job_id: "foo"
snapshotId: "foo2"
deleteInterveningResults: true
@ -209,7 +209,7 @@ setup:
- do:
xpack.prelert.get_buckets:
jobId: "foo"
job_id: "foo"
start: "2016-01-01T00:00:00Z"
end: "2016-12-01T00:00:00Z"