forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the new ip_location APIs and a test of them
- Loading branch information
Showing
4 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
137 changes: 137 additions & 0 deletions
137
...p/src/yamlRestTest/resources/rest-api-spec/test/ingest_geoip/60_ip_location_databases.yml
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,137 @@ | ||
--- | ||
setup: | ||
- requires: | ||
cluster_features: | ||
- "put_database_configuration_action.ipinfo" | ||
reason: "ip location downloader database configuration APIs added in 8.16 to support more types" | ||
|
||
--- | ||
teardown: | ||
- do: | ||
ingest.delete_ip_location_database: | ||
id: "my_database_1" | ||
ignore: 404 | ||
- do: | ||
ingest.delete_ip_location_database: | ||
id: "my_database_2" | ||
ignore: 404 | ||
- do: | ||
ingest.delete_ip_location_database: | ||
id: "my_database_3" | ||
ignore: 404 | ||
|
||
--- | ||
"Test adding, getting, and removing ip location databases": | ||
- do: | ||
ingest.put_ip_location_database: | ||
id: "my_database_1" | ||
body: > | ||
{ | ||
"name": "GeoIP2-City", | ||
"maxmind": { | ||
"account_id": "1234" | ||
} | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
ingest.put_ip_location_database: | ||
id: "my_database_1" | ||
body: > | ||
{ | ||
"name": "GeoIP2-Country", | ||
"maxmind": { | ||
"account_id": "4321" | ||
} | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
ingest.put_ip_location_database: | ||
id: "my_database_2" | ||
body: > | ||
{ | ||
"name": "GeoIP2-City", | ||
"maxmind": { | ||
"account_id": "1234" | ||
} | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
catch: /illegal_argument_exception/ | ||
ingest.put_ip_location_database: | ||
id: "_web_TXlDdXN0b21HZW9MaXRlMi1DaXR5Lm1tZGI=" | ||
body: > | ||
{ | ||
"name": "GeoIP2-City", | ||
"web": { | ||
} | ||
} | ||
- do: | ||
ingest.put_ip_location_database: | ||
id: "my_database_3" | ||
body: > | ||
{ | ||
"name": "standard_privacy", | ||
"ipinfo": { | ||
} | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
ingest.get_ip_location_database: | ||
id: "my_database_1" | ||
- length: { databases: 1 } | ||
- match: { databases.0.id: "my_database_1" } | ||
- gte: { databases.0.modified_date_millis: 0 } | ||
- match: { databases.0.database.name: "GeoIP2-Country" } | ||
- match: { databases.0.database.maxmind.account_id: "4321" } | ||
|
||
- do: | ||
ingest.get_ip_location_database: {} | ||
- length: { databases: 7 } | ||
|
||
- do: | ||
ingest.get_ip_location_database: | ||
id: "my_database_1,my_database_2" | ||
- length: { databases: 2 } | ||
|
||
- do: | ||
ingest.get_ip_location_database: | ||
id: "_web_TXlDdXN0b21HZW9MaXRlMi1DaXR5Lm1tZGI=" | ||
- length: { databases: 1 } | ||
- match: { databases.0.id: "_web_TXlDdXN0b21HZW9MaXRlMi1DaXR5Lm1tZGI=" } | ||
- gte: { databases.0.modified_date_millis: -1 } | ||
- match: { databases.0.database.name: "MyCustomGeoLite2-City" } | ||
|
||
- do: | ||
ingest.delete_ip_location_database: | ||
id: "my_database_1" | ||
|
||
- do: | ||
catch: /resource_not_found_exception/ | ||
ingest.delete_ip_location_database: | ||
id: "_web_TXlDdXN0b21HZW9MaXRlMi1DaXR5Lm1tZGI=" | ||
|
||
- do: | ||
ingest.get_ip_location_database: {} | ||
- length: { databases: 6 } | ||
|
||
- do: | ||
ingest.get_ip_location_database: | ||
id: "my_database_2" | ||
- length: { databases: 1 } | ||
- match: { databases.0.id: "my_database_2" } | ||
- gte: { databases.0.modified_date_millis: 0 } | ||
- match: { databases.0.database.name: "GeoIP2-City" } | ||
- match: { databases.0.database.maxmind.account_id: "1234" } | ||
|
||
- do: | ||
ingest.get_ip_location_database: | ||
id: "my_database_3" | ||
- length: { databases: 1 } | ||
- match: { databases.0.id: "my_database_3" } | ||
- gte: { databases.0.modified_date_millis: 0 } | ||
- match: { databases.0.database.name: "standard_privacy" } |
31 changes: 31 additions & 0 deletions
31
rest-api-spec/src/main/resources/rest-api-spec/api/ingest.delete_ip_location_database.json
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,31 @@ | ||
{ | ||
"ingest.delete_ip_location_database":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-ip-location-database-api.html", | ||
"description":"Deletes an ip location database configuration" | ||
}, | ||
"stability":"stable", | ||
"visibility":"public", | ||
"headers":{ | ||
"accept": [ "application/json"] | ||
}, | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_ingest/ip_location/database/{id}", | ||
"methods":[ | ||
"DELETE" | ||
], | ||
"parts":{ | ||
"id":{ | ||
"type":"list", | ||
"description":"A comma-separated list of ip location database configurations to delete" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
rest-api-spec/src/main/resources/rest-api-spec/api/ingest.get_ip_location_database.json
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,37 @@ | ||
{ | ||
"ingest.get_ip_location_database":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/get-ip-location-database-api.html", | ||
"description":"Returns the specified ip location database configuration" | ||
}, | ||
"stability":"stable", | ||
"visibility":"public", | ||
"headers":{ | ||
"accept": [ "application/json"] | ||
}, | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_ingest/ip_location/database", | ||
"methods":[ | ||
"GET" | ||
] | ||
}, | ||
{ | ||
"path":"/_ingest/ip_location/database/{id}", | ||
"methods":[ | ||
"GET" | ||
], | ||
"parts":{ | ||
"id":{ | ||
"type":"list", | ||
"description":"A comma-separated list of ip location database configurations to get; use `*` to get all ip location database configurations" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
rest-api-spec/src/main/resources/rest-api-spec/api/ingest.put_ip_location_database.json
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,36 @@ | ||
{ | ||
"ingest.put_ip_location_database":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/put-ip-location-database-api.html", | ||
"description":"Puts the configuration for a ip location database to be downloaded" | ||
}, | ||
"stability":"stable", | ||
"visibility":"public", | ||
"headers":{ | ||
"accept": [ "application/json"], | ||
"content_type": ["application/json"] | ||
}, | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path":"/_ingest/ip_location/database/{id}", | ||
"methods":[ | ||
"PUT" | ||
], | ||
"parts":{ | ||
"id":{ | ||
"type":"string", | ||
"description":"The id of the database configuration" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{ | ||
}, | ||
"body":{ | ||
"description":"The database configuration definition", | ||
"required":true | ||
} | ||
} | ||
} |