forked from opensearch-project/data-prepper
-
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.
Geoip database update implementation (opensearch-project#4105)
* Geoip processor implementation Signed-off-by: Asif Sohail Mohammed <nsifmoh@amazon.com>
- Loading branch information
1 parent
680ad7a
commit bb494de
Showing
68 changed files
with
3,533 additions
and
1,461 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
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
13 changes: 13 additions & 0 deletions
13
...p-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/GeoIPDatabase.java
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,13 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.processor; | ||
|
||
public enum GeoIPDatabase { | ||
CITY, | ||
COUNTRY, | ||
ASN, | ||
ENTERPRISE; | ||
} |
72 changes: 72 additions & 0 deletions
72
...eoip-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/GeoIPField.java
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,72 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.processor; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public enum GeoIPField { | ||
CONTINENT_CODE("continent_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
CONTINENT_NAME("continent_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
COUNTRY_NAME("country_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
IS_COUNTRY_IN_EUROPEAN_UNION("is_country_in_european_union", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
COUNTRY_ISO_CODE("country_iso_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
COUNTRY_CONFIDENCE("country_confidence", GeoIPDatabase.ENTERPRISE), | ||
REGISTERED_COUNTRY_NAME("registered_country_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REGISTERED_COUNTRY_ISO_CODE("registered_country_iso_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REPRESENTED_COUNTRY_NAME("represented_country_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REPRESENTED_COUNTRY_ISO_CODE("represented_country_iso_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REPRESENTED_COUNTRY_TYPE("represented_country_type", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
CITY_NAME("city_name", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
CITY_CONFIDENCE("city_confidence", GeoIPDatabase.ENTERPRISE), | ||
LOCATION("location", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LATITUDE("latitude", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LONGITUDE("longitude", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LOCATION_ACCURACY_RADIUS("location_accuracy_radius", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
METRO_CODE("metro_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
TIME_ZONE("time_zone", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
POSTAL_CODE("postal_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
POSTAL_CODE_CONFIDENCE("postal_code_confidence", GeoIPDatabase.ENTERPRISE), | ||
MOST_SPECIFIED_SUBDIVISION_NAME("most_specified_subdivision_name", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
MOST_SPECIFIED_SUBDIVISION_ISO_CODE("most_specified_subdivision_iso_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
MOST_SPECIFIED_SUBDIVISION_CONFIDENCE("most_specified_subdivision_confidence", GeoIPDatabase.ENTERPRISE), | ||
LEAST_SPECIFIED_SUBDIVISION_NAME("least_specified_subdivision_name", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LEAST_SPECIFIED_SUBDIVISION_ISO_CODE("least_specified_subdivision_iso_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LEAST_SPECIFIED_SUBDIVISION_CONFIDENCE("least_specified_subdivision_confidence", GeoIPDatabase.ENTERPRISE), | ||
|
||
ASN("asn", GeoIPDatabase.ASN), | ||
ASN_ORGANIZATION("asn_organization", GeoIPDatabase.ASN), | ||
NETWORK("network", GeoIPDatabase.ASN), | ||
IP("ip", GeoIPDatabase.ASN); | ||
|
||
private final HashSet<GeoIPDatabase> geoIPDatabases; | ||
private final String fieldName; | ||
|
||
GeoIPField(final String fieldName, final GeoIPDatabase... geoIPDatabases) { | ||
this.fieldName = fieldName; | ||
this.geoIPDatabases = new HashSet<>(Arrays.asList(geoIPDatabases)); | ||
} | ||
|
||
public static GeoIPField findByName(final String name) { | ||
GeoIPField result = null; | ||
for (GeoIPField geoIPField : values()) { | ||
if (geoIPField.getFieldName().equalsIgnoreCase(name)) { | ||
result = geoIPField; | ||
break; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public String getFieldName() { | ||
return fieldName; | ||
} | ||
|
||
public Set<GeoIPDatabase> getGeoIPDatabases() { | ||
return geoIPDatabases; | ||
} | ||
} |
Oops, something went wrong.