Skip to content

Commit

Permalink
Add the new ip_location APIs and a test of them
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo committed Oct 11, 2024
1 parent 87494cf commit eb146af
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 0 deletions.
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" }
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":{
}
}
}
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":{
}
}
}
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
}
}
}

0 comments on commit eb146af

Please sign in to comment.