Skip to content

Commit

Permalink
NIFI-13825 Add property for custom certificates to OpenSearch process…
Browse files Browse the repository at this point in the history
…ors (#10)

Signed-off-by: David Handermann <[email protected]>
  • Loading branch information
mark-bathori authored Nov 13, 2024
1 parent bcad79a commit 6b6b566
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/extensions/vectorstores/OpenSearchVectorUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
sensitive=True,
validators=[StandardValidators.NON_EMPTY_VALIDATOR],
)
CERTIFICATE_PATH = PropertyDescriptor(
name="Certificate Path",
description="The path to the CA certificate to be used.",
required=False,
validators=[StandardValidators.NON_EMPTY_VALIDATOR],
)
INDEX_NAME = PropertyDescriptor(
name="Index Name",
description="The name of the OpenSearch index.",
Expand Down Expand Up @@ -74,12 +80,16 @@
def create_authentication_params(context):
username = context.getProperty(USERNAME).getValue()
password = context.getProperty(PASSWORD).getValue()
certificate_path = context.getProperty(CERTIFICATE_PATH).getValue()

params = {"verify_certs": "true"}
params = {}

if username is not None and password is not None:
params["http_auth"] = (username, password)

if certificate_path is not None:
params["ca_certs"] = certificate_path

return params


Expand Down
2 changes: 2 additions & 0 deletions src/extensions/vectorstores/PutOpenSearchVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from nifiapi.flowfiletransform import FlowFileTransform, FlowFileTransformResult
from nifiapi.properties import ExpressionLanguageScope, PropertyDependency, PropertyDescriptor, StandardValidators
from OpenSearchVectorUtils import (
CERTIFICATE_PATH,
COSINESIMIL,
HTTP_HOST,
HUGGING_FACE_API_KEY,
Expand Down Expand Up @@ -188,6 +189,7 @@ class ProcessorDetails:
HTTP_HOST,
USERNAME,
PASSWORD,
CERTIFICATE_PATH,
INDEX_NAME,
DOC_ID_FIELD_NAME,
VECTOR_FIELD,
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/vectorstores/QueryOpenSearchVector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from nifiapi.flowfiletransform import FlowFileTransform, FlowFileTransformResult
from nifiapi.properties import ExpressionLanguageScope, PropertyDependency, PropertyDescriptor, StandardValidators
from OpenSearchVectorUtils import (
CERTIFICATE_PATH,
COSINESIMIL,
HTTP_HOST,
HUGGING_FACE_API_KEY,
Expand Down Expand Up @@ -138,6 +139,7 @@ class ProcessorDetails:
HTTP_HOST,
USERNAME,
PASSWORD,
CERTIFICATE_PATH,
INDEX_NAME,
QUERY,
VECTOR_FIELD,
Expand Down

0 comments on commit 6b6b566

Please sign in to comment.