SameerMesiah97 commented on code in PR #67524:
URL: https://github.com/apache/airflow/pull/67524#discussion_r3329166985
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/dms.py:
##########
@@ -118,6 +121,274 @@ def execute(self, context: Context):
return task_arn
+class DmsModifyTaskOperator(AwsBaseOperator[DmsHook]):
+ """
+ Modifies an existing AWS DMS replication task.
+
+ If the task is not already stopped, set ``stop_task_before=True`` to stop
it first.
+ To restart the task after modification, set ``restart_task_after=True``.
+
+ .. seealso::
+ For more information on how to use this operator, take a look at the
guide:
+ :ref:`howto/operator:DmsModifyTaskOperator`
+
+ :param replication_task_arn: Replication task ARN
+ :param table_mappings: New table mappings. If not provided, existing
mappings are kept.
+ :param migration_type: Migration type
('full-load'|'cdc'|'full-load-and-cdc').
+ If not provided, existing type is kept.
+ :param replication_task_settings: Task settings dict. If not provided,
existing settings are kept.
+ :param cdc_start_time: Start time for CDC.
+ :param cdc_start_position: Indicates when to start CDC (checkpoint or
LSN/SCN format).
+ Mutually exclusive with cdc_start_time.
+ :param cdc_stop_position: Indicates when to stop CDC.
+ :param stop_task_before: If True, stop the task before modifying if it is
not already stopped.
+ :param restart_task_after: If True, restart the task after modifying.
+ :param start_replication_task_type: Start type used when restarting the
task.
+ One of 'start-replication', 'resume-processing', or 'reload-target'.
+ Defaults to 'resume-processing'. Only used when
``restart_task_after=True``.
+ :param wait_for_completion: Only applies when the task is already in
``modifying`` state
+ when ``execute()`` is called. If True, wait for the modification to
finish before
+ proceeding. If False, raises immediately instead of waiting.
+ :param deferrable: Run the operator in deferrable mode.
+ :param waiter_delay: Seconds between waiter polls (default: 30).
+ :param waiter_max_attempts: Maximum waiter poll attempts (default: 60).
+ :param aws_conn_id: The Airflow connection used for AWS credentials.
+ If this is ``None`` or empty then the default boto3 behaviour is used.
If
+ running Airflow in a distributed manner and aws_conn_id is None or
+ empty, then default boto3 configuration would be used (and must be
+ maintained on each worker node).
+ :param region_name: AWS region_name. If not specified then the default
boto3 behaviour is used.
+ :param verify: Whether or not to verify SSL certificates. See:
+
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html
+ :param botocore_config: Configuration dictionary (key-values) for botocore
client. See:
+
https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
+ """
+
+ STOPPED_STATES = ("stopped", "ready", "failed", "created")
+ TERMINAL_STATES = frozenset({"failed", "stopped", "ready", "created",
"deleting"})
Review Comment:
I believe it would be better to move this state category i.e
`MODIFIABLE_STATES` in to the hook itself so that you can use them in both the
operator and trigger without risk of code drift. Also, after inspecting the
hook more closely, it seems like it would be better to just reuse the existing
enum class (adding any additional `ENUM` attributes you require) instead of
creating a new enum class. Keep in mind that it is acceptable to compose new
`ENUM` attributes using existing ones for e.g. `MODIFIABLE_STATES = (STOPPED,
READY, FAILED)`
I apologize if I was not as clear before. I did not look at the hook as
closely when I made that suggestion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]