Skip to content

Commit

Permalink
Merge pull request #12 from Monad-Inc/main
Browse files Browse the repository at this point in the history
Add support for encoded api keys.
  • Loading branch information
dtmirizzi authored Jan 2, 2024
2 parents e3a0438 + 89eca54 commit 3937a5f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions target_elasticsearch/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
BEARER_TOKEN = "bearer_token"
API_KEY_ID = "api_key_id"
API_KEY = "api_key"
ENCODED_API_KEY = "encoded_api_key"
SSL_CA_FILE = "ssl_ca_file"
INDEX_FORMAT = "index_format"
INDEX_TEMPLATE_FIELDS = "index_schema_fields"
Expand Down
3 changes: 3 additions & 0 deletions target_elasticsearch/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
BEARER_TOKEN,
API_KEY_ID,
API_KEY,
ENCODED_API_KEY,
SSL_CA_FILE,
INDEX_TEMPLATE_FIELDS,
ELASTIC_YEARLY_FORMAT,
Expand Down Expand Up @@ -189,6 +190,8 @@ def _authenticated_client(self) -> elasticsearch.Elasticsearch:
config["basic_auth"] = (self.config[USERNAME], self.config[PASSWORD])
elif API_KEY in self.config and API_KEY_ID in self.config:
config["api_key"] = (self.config[API_KEY_ID], self.config[API_KEY])
elif ENCODED_API_KEY in self.config:
config["api_key"] = self.config[ENCODED_API_KEY]
elif BEARER_TOKEN in self.config:
config["bearer_auth"] = self.config[BEARER_TOKEN]
else:
Expand Down
7 changes: 7 additions & 0 deletions target_elasticsearch/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
BEARER_TOKEN,
API_KEY_ID,
API_KEY,
ENCODED_API_KEY,
SSL_CA_FILE,
INDEX_TEMPLATE_FIELDS,
METADATA_FIELDS,
Expand Down Expand Up @@ -74,6 +75,12 @@ class TargetElasticsearch(Target):
description="api key for auth key authorization",
default=None,
),
th.Property(
ENCODED_API_KEY,
th.StringType,
description="Encoded api key for auth key authorization",
default=None,
),
th.Property(
SSL_CA_FILE,
th.StringType,
Expand Down

0 comments on commit 3937a5f

Please sign in to comment.