Skip to content

Commit

Permalink
Moved cluster states to hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisms committed Jan 26, 2024
1 parent 1b20b51 commit 1cab491
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 3 additions & 0 deletions airflow/providers/amazon/aws/hooks/neptune.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class NeptuneHook(AwsBaseHook):
- :class:`~airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
"""

AVAILABLE_STATES = ["available"]
STOPPED_STATES = ["stopped"]

def __init__(self, *args, **kwargs):
kwargs["client_type"] = "neptune"
super().__init__(*args, **kwargs)
Expand Down
7 changes: 2 additions & 5 deletions airflow/providers/amazon/aws/operators/neptune.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
if TYPE_CHECKING:
from airflow.utils.context import Context

AVAILABLE_STATES = ["available"]
STOPPED_STATES = ["stopped"]


class NeptuneStartDbClusterOperator(AwsBaseOperator[NeptuneHook]):
"""Starts an Amazon Neptune DB cluster.
Expand Down Expand Up @@ -89,7 +86,7 @@ def execute(self, context: Context) -> dict[str, str]:

# Check to make sure the cluster is not already available.
status = self.hook.get_cluster_status(self.cluster_id)
if status.lower() in AVAILABLE_STATES:
if status.lower() in NeptuneHook.AVAILABLE_STATES:
self.log.info("Neptune cluster %s is already available.", self.cluster_id)
return {"db_cluster_id": self.cluster_id}

Expand Down Expand Up @@ -183,7 +180,7 @@ def execute(self, context: Context) -> dict[str, str]:

# Check to make sure the cluster is not already stopped.
status = self.hook.get_cluster_status(self.cluster_id)
if status.lower() in STOPPED_STATES:
if status.lower() in NeptuneHook.STOPPED_STATES:
self.log.info("Neptune cluster %s is already stopped.", self.cluster_id)
return {"db_cluster_id": self.cluster_id}

Expand Down

0 comments on commit 1cab491

Please sign in to comment.