From 9a0750a88c155fa2b991175b291585d194144f83 Mon Sep 17 00:00:00 2001 From: Tobias Cadee Date: Tue, 27 Aug 2024 08:52:09 +0200 Subject: [PATCH] refactor: :fire: remove sqlalchemy parameters target uses `redshift_connector` so all sqlalchemy parameters should go --- target_redshift/target.py | 72 +++++++++------------------------------ 1 file changed, 17 insertions(+), 55 deletions(-) diff --git a/target_redshift/target.py b/target_redshift/target.py index 41b6a32..815e928 100644 --- a/target_redshift/target.py +++ b/target_redshift/target.py @@ -37,35 +37,10 @@ def __init__( parse_env_config=parse_env_config, validate_config=validate_config, ) - # There's a few ways to do this in JSON Schema but it is schema draft dependent. - # https://stackoverflow.com/questions/38717933/jsonschema-attribute-conditionally-required # noqa: E501 - assert ( - (self.config.get("sqlalchemy_url") is not None) - or ( - self.config.get("host") is not None - and self.config.get("port") is not None - and self.config.get("user") is not None - and self.config.get("password") is not None - ) - or ( - self.config.get("host") is not None - and self.config.get("port") is not None - and self.config.get("user") is not None - and self.config.get("enable_iam_authentication") is not None - and self.config.get("cluster_identifier") is not None - ) - ), ("Need either the sqlalchemy_url to be set or host, port, user," + "password, and dialect+driver to be set") - - # If sqlalchemy_url is not being used and ssl_enable is on, ssl_mode must have - # one of six allowable values. If ssl_mode is verify-ca or verify-full, a - # certificate authority must be provided to verify against. - assert ( - (self.config.get("sqlalchemy_url") is not None) - or (self.config.get("ssl_enable") is False) - or (self.config.get("ssl_mode") in {"disable", "allow", "prefer", "require"}) - ) - assert self.config.get("add_record_metadata") or not self.config.get("activate_version"), ( + assert self.config.get("add_record_metadata") or not self.config.get( + "activate_version" + ), ( "Activate version messages can't be processed unless add_record_metadata " "is set to true. To ignore Activate version messages instead, Set the " "`activate_version` configuration to False." @@ -79,7 +54,9 @@ def __init__( th.Property( "host", th.StringType, - description=("Hostname for redshift instance. Note if sqlalchemy_url is set this will be ignored."), + description=( + "Hostname for redshift instance. Note if sqlalchemy_url is set this will be ignored." + ), ), th.Property( "port", @@ -107,38 +84,22 @@ def __init__( th.Property( "user", th.StringType, - description=("User name used to authenticate. Note if sqlalchemy_url is set this will be ignored."), + description=( + "User name used to authenticate. Note if sqlalchemy_url is set this will be ignored." + ), ), th.Property( "password", th.StringType, - description=("Password used to authenticate. Note if sqlalchemy_url is set this will be ignored."), - ), - th.Property( - "dbname", - th.StringType, - description=("Database name. Note if sqlalchemy_url is set this will be ignored."), - ), - th.Property( - "sqlalchemy_url", - th.StringType, description=( - "SQLAlchemy connection string. " - + "This will override using host, user, password, port, " - + "dialect, and all ssl settings. Note that you must escape password " - + "special characters properly. See " - + "https://docs.sqlalchemy.org/en/20/core/engines.html#escaping-special-characters-such-as-signs-in-passwords" + "Password used to authenticate. Note if sqlalchemy_url is set this will be ignored." ), ), th.Property( - "dialect+driver", + "dbname", th.StringType, - default="redshift+redshift_connector", description=( - "Dialect+driver see " - + "https://aws.amazon.com/blogs/big-data/use-the-amazon-redshift-sqlalchemy-dialect-to-interact-with-amazon-redshift. " - + "Generally just leave this alone. " - + "Note if sqlalchemy_url is set this will be ignored." + "Database name. Note if sqlalchemy_url is set this will be ignored." ), ), th.Property( @@ -175,7 +136,10 @@ def __init__( description="If you want to remove staging files in S3", ), th.Property( - "temp_dir", th.StringType, default="temp", description="Where you want to store your temp data files." + "temp_dir", + th.StringType, + default="temp", + description="Where you want to store your temp data files.", ), th.Property( "default_target_schema", @@ -222,7 +186,6 @@ def __init__( + " ssl_certificate_authority and ssl_mode for further customization." + " To use a client certificate to authenticate yourself to the server," + " use ssl_client_certificate_enable instead." - + " Note if sqlalchemy_url is set this will be ignored." ), ), th.Property( @@ -230,10 +193,9 @@ def __init__( th.StringType, default="verify-full", description=( - "SSL Protection method, see [postgres documentation](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION)" + "SSL Protection method, see [redshift documentation](https://docs.aws.amazon.com/redshift/latest/mgmt/connecting-ssl-support.html" + " for more information. Must be one of disable, allow, prefer," + " require, verify-ca, or verify-full." - + " Note if sqlalchemy_url is set this will be ignored." ), ), ).to_dict()