From 89eca545649e7c13d539dad8e4f6c8338e97cc15 Mon Sep 17 00:00:00 2001 From: John Hwang Date: Tue, 28 Nov 2023 14:28:14 -0800 Subject: [PATCH] Add support for encoded api keys. --- target_elasticsearch/common.py | 1 + target_elasticsearch/sinks.py | 3 +++ target_elasticsearch/target.py | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/target_elasticsearch/common.py b/target_elasticsearch/common.py index d39d52d..c99959e 100644 --- a/target_elasticsearch/common.py +++ b/target_elasticsearch/common.py @@ -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" diff --git a/target_elasticsearch/sinks.py b/target_elasticsearch/sinks.py index dfc447c..c783489 100644 --- a/target_elasticsearch/sinks.py +++ b/target_elasticsearch/sinks.py @@ -21,6 +21,7 @@ BEARER_TOKEN, API_KEY_ID, API_KEY, + ENCODED_API_KEY, SSL_CA_FILE, INDEX_TEMPLATE_FIELDS, ELASTIC_YEARLY_FORMAT, @@ -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: diff --git a/target_elasticsearch/target.py b/target_elasticsearch/target.py index c684cf2..5570de0 100644 --- a/target_elasticsearch/target.py +++ b/target_elasticsearch/target.py @@ -12,6 +12,7 @@ BEARER_TOKEN, API_KEY_ID, API_KEY, + ENCODED_API_KEY, SSL_CA_FILE, INDEX_TEMPLATE_FIELDS, METADATA_FIELDS, @@ -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,