apache-airflow-providers-amazon 8.26.0rc2__py3-none-any.whl → 8.27.0rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. airflow/providers/amazon/__init__.py +1 -1
  2. airflow/providers/amazon/aws/datasets/__init__.py +16 -0
  3. airflow/providers/amazon/aws/datasets/s3.py +45 -0
  4. airflow/providers/amazon/aws/executors/batch/batch_executor.py +20 -13
  5. airflow/providers/amazon/aws/executors/ecs/ecs_executor.py +24 -13
  6. airflow/providers/amazon/aws/hooks/kinesis_analytics.py +65 -0
  7. airflow/providers/amazon/aws/hooks/rds.py +3 -3
  8. airflow/providers/amazon/aws/hooks/s3.py +26 -1
  9. airflow/providers/amazon/aws/hooks/step_function.py +18 -0
  10. airflow/providers/amazon/aws/operators/athena.py +16 -17
  11. airflow/providers/amazon/aws/operators/kinesis_analytics.py +348 -0
  12. airflow/providers/amazon/aws/operators/rds.py +17 -20
  13. airflow/providers/amazon/aws/operators/redshift_cluster.py +4 -2
  14. airflow/providers/amazon/aws/operators/s3.py +7 -11
  15. airflow/providers/amazon/aws/operators/sagemaker.py +2 -3
  16. airflow/providers/amazon/aws/operators/step_function.py +12 -2
  17. airflow/providers/amazon/aws/sensors/kinesis_analytics.py +234 -0
  18. airflow/providers/amazon/aws/transfers/redshift_to_s3.py +1 -0
  19. airflow/providers/amazon/aws/transfers/s3_to_redshift.py +1 -0
  20. airflow/providers/amazon/aws/triggers/emr.py +3 -1
  21. airflow/providers/amazon/aws/triggers/kinesis_analytics.py +69 -0
  22. airflow/providers/amazon/aws/waiters/kinesisanalyticsv2.json +151 -0
  23. airflow/providers/amazon/aws/waiters/rds.json +253 -0
  24. airflow/providers/amazon/get_provider_info.py +35 -2
  25. {apache_airflow_providers_amazon-8.26.0rc2.dist-info → apache_airflow_providers_amazon-8.27.0rc1.dist-info}/METADATA +29 -22
  26. {apache_airflow_providers_amazon-8.26.0rc2.dist-info → apache_airflow_providers_amazon-8.27.0rc1.dist-info}/RECORD +28 -20
  27. {apache_airflow_providers_amazon-8.26.0rc2.dist-info → apache_airflow_providers_amazon-8.27.0rc1.dist-info}/WHEEL +0 -0
  28. {apache_airflow_providers_amazon-8.26.0rc2.dist-info → apache_airflow_providers_amazon-8.27.0rc1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,234 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING, Any, Sequence
20
+
21
+ from airflow.configuration import conf
22
+ from airflow.exceptions import AirflowException, AirflowSkipException
23
+ from airflow.providers.amazon.aws.hooks.kinesis_analytics import KinesisAnalyticsV2Hook
24
+ from airflow.providers.amazon.aws.sensors.base_aws import AwsBaseSensor
25
+ from airflow.providers.amazon.aws.triggers.kinesis_analytics import (
26
+ KinesisAnalyticsV2ApplicationOperationCompleteTrigger,
27
+ )
28
+ from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
29
+
30
+ if TYPE_CHECKING:
31
+ from airflow.utils.context import Context
32
+
33
+
34
+ class KinesisAnalyticsV2BaseSensor(AwsBaseSensor[KinesisAnalyticsV2Hook]):
35
+ """
36
+ General sensor behaviour for AWS Managed Service for Apache Flink.
37
+
38
+ Subclasses must set the following fields:
39
+ - ``INTERMEDIATE_STATES``
40
+ - ``FAILURE_STATES``
41
+ - ``SUCCESS_STATES``
42
+ - ``FAILURE_MESSAGE``
43
+ - ``SUCCESS_MESSAGE``
44
+
45
+ :param application_name: Application name.
46
+ :param deferrable: If True, the sensor will operate in deferrable mode. This mode requires aiobotocore
47
+ module to be installed.
48
+ (default: False, but can be overridden in config file by setting default_deferrable to True)
49
+
50
+ """
51
+
52
+ aws_hook_class = KinesisAnalyticsV2Hook
53
+ ui_color = "#66c3ff"
54
+
55
+ INTERMEDIATE_STATES: tuple[str, ...] = ()
56
+ FAILURE_STATES: tuple[str, ...] = ()
57
+ SUCCESS_STATES: tuple[str, ...] = ()
58
+ FAILURE_MESSAGE = ""
59
+ SUCCESS_MESSAGE = ""
60
+
61
+ def __init__(
62
+ self,
63
+ application_name: str,
64
+ deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False),
65
+ **kwargs: Any,
66
+ ):
67
+ super().__init__(**kwargs)
68
+ self.application_name = application_name
69
+ self.deferrable = deferrable
70
+
71
+ def poke(self, context: Context, **kwargs) -> bool:
72
+ status = self.hook.conn.describe_application(ApplicationName=self.application_name)[
73
+ "ApplicationDetail"
74
+ ]["ApplicationStatus"]
75
+
76
+ self.log.info(
77
+ "Poking for AWS Managed Service for Apache Flink application: %s status: %s",
78
+ self.application_name,
79
+ status,
80
+ )
81
+
82
+ if status in self.FAILURE_STATES:
83
+ # TODO: remove this if block when min_airflow_version is set to higher than 2.7.1
84
+ if self.soft_fail:
85
+ raise AirflowSkipException(self.FAILURE_MESSAGE)
86
+ raise AirflowException(self.FAILURE_MESSAGE)
87
+
88
+ if status in self.SUCCESS_STATES:
89
+ self.log.info(
90
+ "%s `%s`.",
91
+ self.SUCCESS_MESSAGE,
92
+ self.application_name,
93
+ )
94
+ return True
95
+
96
+ return False
97
+
98
+
99
+ class KinesisAnalyticsV2StartApplicationCompletedSensor(KinesisAnalyticsV2BaseSensor):
100
+ """
101
+ Waits for AWS Managed Service for Apache Flink application to start.
102
+
103
+ .. seealso::
104
+ For more information on how to use this sensor, take a look at the guide:
105
+ :ref:`howto/sensor:KinesisAnalyticsV2StartApplicationCompletedSensor`
106
+
107
+ :param application_name: Application name.
108
+
109
+ :param deferrable: If True, the sensor will operate in deferrable mode. This mode requires aiobotocore
110
+ module to be installed.
111
+ (default: False, but can be overridden in config file by setting default_deferrable to True)
112
+ :param poke_interval: Polling period in seconds to check for the status of the job. (default: 120)
113
+ :param max_retries: Number of times before returning the current state. (default: 75)
114
+ :param aws_conn_id: The Airflow connection used for AWS credentials.
115
+ If this is ``None`` or empty then the default boto3 behaviour is used. If
116
+ running Airflow in a distributed manner and aws_conn_id is None or
117
+ empty, then default boto3 configuration would be used (and must be
118
+ maintained on each worker node).
119
+ :param region_name: AWS region_name. If not specified then the default boto3 behaviour is used.
120
+ :param verify: Whether to verify SSL certificates. See:
121
+ https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html
122
+ :param botocore_config: Configuration dictionary (key-values) for botocore client. See:
123
+ https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
124
+
125
+ """
126
+
127
+ INTERMEDIATE_STATES: tuple[str, ...] = KinesisAnalyticsV2Hook.APPLICATION_START_INTERMEDIATE_STATES
128
+ FAILURE_STATES: tuple[str, ...] = KinesisAnalyticsV2Hook.APPLICATION_START_FAILURE_STATES
129
+ SUCCESS_STATES: tuple[str, ...] = KinesisAnalyticsV2Hook.APPLICATION_START_SUCCESS_STATES
130
+
131
+ FAILURE_MESSAGE = "AWS Managed Service for Apache Flink application start failed."
132
+ SUCCESS_MESSAGE = "AWS Managed Service for Apache Flink application started successfully"
133
+
134
+ template_fields: Sequence[str] = aws_template_fields("application_name")
135
+
136
+ def __init__(
137
+ self,
138
+ *,
139
+ application_name: str,
140
+ max_retries: int = 75,
141
+ poke_interval: int = 120,
142
+ **kwargs: Any,
143
+ ) -> None:
144
+ super().__init__(application_name=application_name, **kwargs)
145
+ self.application_name = application_name
146
+ self.max_retries = max_retries
147
+ self.poke_interval = poke_interval
148
+
149
+ def execute(self, context: Context) -> Any:
150
+ if self.deferrable:
151
+ self.defer(
152
+ trigger=KinesisAnalyticsV2ApplicationOperationCompleteTrigger(
153
+ application_name=self.application_name,
154
+ waiter_name="application_start_complete",
155
+ aws_conn_id=self.aws_conn_id,
156
+ waiter_delay=int(self.poke_interval),
157
+ waiter_max_attempts=self.max_retries,
158
+ region_name=self.region_name,
159
+ verify=self.verify,
160
+ botocore_config=self.botocore_config,
161
+ ),
162
+ method_name="poke",
163
+ )
164
+ else:
165
+ super().execute(context=context)
166
+
167
+
168
+ class KinesisAnalyticsV2StopApplicationCompletedSensor(KinesisAnalyticsV2BaseSensor):
169
+ """
170
+ Waits for AWS Managed Service for Apache Flink application to stop.
171
+
172
+ .. seealso::
173
+ For more information on how to use this sensor, take a look at the guide:
174
+ :ref:`howto/sensor:KinesisAnalyticsV2StopApplicationCompletedSensor`
175
+
176
+ :param application_name: Application name.
177
+
178
+ :param deferrable: If True, the sensor will operate in deferrable mode. This mode requires aiobotocore
179
+ module to be installed.
180
+ (default: False, but can be overridden in config file by setting default_deferrable to True)
181
+ :param poke_interval: Polling period in seconds to check for the status of the job. (default: 120)
182
+ :param max_retries: Number of times before returning the current state. (default: 75)
183
+ :param aws_conn_id: The Airflow connection used for AWS credentials.
184
+ If this is ``None`` or empty then the default boto3 behaviour is used. If
185
+ running Airflow in a distributed manner and aws_conn_id is None or
186
+ empty, then default boto3 configuration would be used (and must be
187
+ maintained on each worker node).
188
+ :param region_name: AWS region_name. If not specified then the default boto3 behaviour is used.
189
+ :param verify: Whether to verify SSL certificates. See:
190
+ https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html
191
+ :param botocore_config: Configuration dictionary (key-values) for botocore client. See:
192
+ https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html
193
+
194
+ """
195
+
196
+ INTERMEDIATE_STATES: tuple[str, ...] = KinesisAnalyticsV2Hook.APPLICATION_STOP_INTERMEDIATE_STATES
197
+ FAILURE_STATES: tuple[str, ...] = KinesisAnalyticsV2Hook.APPLICATION_STOP_FAILURE_STATES
198
+ SUCCESS_STATES: tuple[str, ...] = KinesisAnalyticsV2Hook.APPLICATION_STOP_SUCCESS_STATES
199
+
200
+ FAILURE_MESSAGE = "AWS Managed Service for Apache Flink application stop failed."
201
+ SUCCESS_MESSAGE = "AWS Managed Service for Apache Flink application stopped successfully"
202
+
203
+ template_fields: Sequence[str] = aws_template_fields("application_name")
204
+
205
+ def __init__(
206
+ self,
207
+ *,
208
+ application_name: str,
209
+ max_retries: int = 75,
210
+ poke_interval: int = 120,
211
+ **kwargs: Any,
212
+ ) -> None:
213
+ super().__init__(application_name=application_name, **kwargs)
214
+ self.application_name = application_name
215
+ self.max_retries = max_retries
216
+ self.poke_interval = poke_interval
217
+
218
+ def execute(self, context: Context) -> Any:
219
+ if self.deferrable:
220
+ self.defer(
221
+ trigger=KinesisAnalyticsV2ApplicationOperationCompleteTrigger(
222
+ application_name=self.application_name,
223
+ waiter_name="application_stop_complete",
224
+ aws_conn_id=self.aws_conn_id,
225
+ waiter_delay=int(self.poke_interval),
226
+ waiter_max_attempts=self.max_retries,
227
+ region_name=self.region_name,
228
+ verify=self.verify,
229
+ botocore_config=self.botocore_config,
230
+ ),
231
+ method_name="poke",
232
+ )
233
+ else:
234
+ super().execute(context=context)
@@ -84,6 +84,7 @@ class RedshiftToS3Operator(BaseOperator):
84
84
  "unload_options",
85
85
  "select_query",
86
86
  "redshift_conn_id",
87
+ "redshift_data_api_kwargs",
87
88
  )
88
89
  template_ext: Sequence[str] = (".sql",)
89
90
  template_fields_renderers = {"select_query": "sql"}
@@ -77,6 +77,7 @@ class S3ToRedshiftOperator(BaseOperator):
77
77
  "copy_options",
78
78
  "redshift_conn_id",
79
79
  "method",
80
+ "redshift_data_api_kwargs",
80
81
  "aws_conn_id",
81
82
  )
82
83
  template_ext: Sequence[str] = ()
@@ -16,6 +16,7 @@
16
16
  # under the License.
17
17
  from __future__ import annotations
18
18
 
19
+ import sys
19
20
  import warnings
20
21
  from typing import TYPE_CHECKING
21
22
 
@@ -174,6 +175,7 @@ class EmrContainerTrigger(AwsBaseWaiterTrigger):
174
175
  :param job_id: job_id to check the state
175
176
  :param aws_conn_id: Reference to AWS connection id
176
177
  :param waiter_delay: polling period in seconds to check for the status
178
+ :param waiter_max_attempts: The maximum number of attempts to be made. Defaults to an infinite wait.
177
179
  """
178
180
 
179
181
  def __init__(
@@ -183,7 +185,7 @@ class EmrContainerTrigger(AwsBaseWaiterTrigger):
183
185
  aws_conn_id: str | None = "aws_default",
184
186
  poll_interval: int | None = None, # deprecated
185
187
  waiter_delay: int = 30,
186
- waiter_max_attempts: int = 600,
188
+ waiter_max_attempts: int = sys.maxsize,
187
189
  ):
188
190
  if poll_interval is not None:
189
191
  warnings.warn(
@@ -0,0 +1,69 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING
20
+
21
+ from airflow.providers.amazon.aws.hooks.kinesis_analytics import KinesisAnalyticsV2Hook
22
+ from airflow.providers.amazon.aws.triggers.base import AwsBaseWaiterTrigger
23
+
24
+ if TYPE_CHECKING:
25
+ from airflow.providers.amazon.aws.hooks.base_aws import AwsGenericHook
26
+
27
+
28
+ class KinesisAnalyticsV2ApplicationOperationCompleteTrigger(AwsBaseWaiterTrigger):
29
+ """
30
+ Trigger when a Managed Service for Apache Flink application Start or Stop is complete.
31
+
32
+ :param application_name: Application name.
33
+ :param waiter_name: The name of the waiter for stop or start application.
34
+ :param waiter_delay: The amount of time in seconds to wait between attempts. (default: 120)
35
+ :param waiter_max_attempts: The maximum number of attempts to be made. (default: 75)
36
+ :param aws_conn_id: The Airflow connection used for AWS credentials.
37
+ """
38
+
39
+ def __init__(
40
+ self,
41
+ application_name: str,
42
+ waiter_name: str,
43
+ waiter_delay: int = 120,
44
+ waiter_max_attempts: int = 75,
45
+ aws_conn_id: str | None = "aws_default",
46
+ **kwargs,
47
+ ) -> None:
48
+ super().__init__(
49
+ serialized_fields={"application_name": application_name, "waiter_name": waiter_name},
50
+ waiter_name=waiter_name,
51
+ waiter_args={"ApplicationName": application_name},
52
+ failure_message=f"AWS Managed Service for Apache Flink Application {application_name} failed.",
53
+ status_message=f"Status of AWS Managed Service for Apache Flink Application {application_name} is",
54
+ status_queries=["ApplicationDetail.ApplicationStatus"],
55
+ return_key="application_name",
56
+ return_value=application_name,
57
+ waiter_delay=waiter_delay,
58
+ waiter_max_attempts=waiter_max_attempts,
59
+ aws_conn_id=aws_conn_id,
60
+ **kwargs,
61
+ )
62
+
63
+ def hook(self) -> AwsGenericHook:
64
+ return KinesisAnalyticsV2Hook(
65
+ aws_conn_id=self.aws_conn_id,
66
+ region_name=self.region_name,
67
+ verify=self.verify,
68
+ config=self.botocore_config,
69
+ )
@@ -0,0 +1,151 @@
1
+ {
2
+ "version": 2,
3
+ "waiters": {
4
+ "application_start_complete": {
5
+ "delay": 120,
6
+ "maxAttempts": 75,
7
+ "operation": "DescribeApplication",
8
+ "acceptors": [
9
+ {
10
+ "matcher": "path",
11
+ "argument": "ApplicationDetail.ApplicationStatus",
12
+ "expected": "STARTING",
13
+ "state": "retry"
14
+ },
15
+ {
16
+ "matcher": "path",
17
+ "argument": "ApplicationDetail.ApplicationStatus",
18
+ "expected": "UPDATING",
19
+ "state": "retry"
20
+ },
21
+ {
22
+ "matcher": "path",
23
+ "argument": "ApplicationDetail.ApplicationStatus",
24
+ "expected": "AUTOSCALING",
25
+ "state": "retry"
26
+ },
27
+ {
28
+ "matcher": "path",
29
+ "argument": "ApplicationDetail.ApplicationStatus",
30
+ "expected": "DELETING",
31
+ "state": "failure"
32
+ },
33
+ {
34
+ "matcher": "path",
35
+ "argument": "ApplicationDetail.ApplicationStatus",
36
+ "expected": "STOPPING",
37
+ "state": "failure"
38
+ },
39
+ {
40
+ "matcher": "path",
41
+ "argument": "ApplicationDetail.ApplicationStatus",
42
+ "expected": "READY",
43
+ "state": "failure"
44
+ },
45
+ {
46
+ "matcher": "path",
47
+ "argument": "ApplicationDetail.ApplicationStatus",
48
+ "expected": "FORCE_STOPPING",
49
+ "state": "failure"
50
+ },
51
+ {
52
+ "matcher": "path",
53
+ "argument": "ApplicationDetail.ApplicationStatus",
54
+ "expected": "ROLLING_BACK",
55
+ "state": "failure"
56
+ },
57
+ {
58
+ "matcher": "path",
59
+ "argument": "ApplicationDetail.ApplicationStatus",
60
+ "expected": "MAINTENANCE",
61
+ "state": "failure"
62
+ },
63
+ {
64
+ "matcher": "path",
65
+ "argument": "ApplicationDetail.ApplicationStatus",
66
+ "expected": "ROLLED_BACK",
67
+ "state": "failure"
68
+ },
69
+ {
70
+ "matcher": "path",
71
+ "argument": "ApplicationDetail.ApplicationStatus",
72
+ "expected": "RUNNING",
73
+ "state": "success"
74
+ }
75
+ ]
76
+ },
77
+ "application_stop_complete": {
78
+ "delay": 120,
79
+ "maxAttempts": 75,
80
+ "operation": "DescribeApplication",
81
+ "acceptors": [
82
+ {
83
+ "matcher": "path",
84
+ "argument": "ApplicationDetail.ApplicationStatus",
85
+ "expected": "STARTING",
86
+ "state": "retry"
87
+ },
88
+ {
89
+ "matcher": "path",
90
+ "argument": "ApplicationDetail.ApplicationStatus",
91
+ "expected": "UPDATING",
92
+ "state": "retry"
93
+ },
94
+ {
95
+ "matcher": "path",
96
+ "argument": "ApplicationDetail.ApplicationStatus",
97
+ "expected": "AUTOSCALING",
98
+ "state": "retry"
99
+ },
100
+ {
101
+ "matcher": "path",
102
+ "argument": "ApplicationDetail.ApplicationStatus",
103
+ "expected": "RUNNING",
104
+ "state": "retry"
105
+ },
106
+ {
107
+ "matcher": "path",
108
+ "argument": "ApplicationDetail.ApplicationStatus",
109
+ "expected": "STOPPING",
110
+ "state": "retry"
111
+ },
112
+ {
113
+ "matcher": "path",
114
+ "argument": "ApplicationDetail.ApplicationStatus",
115
+ "expected": "FORCE_STOPPING",
116
+ "state": "retry"
117
+ },
118
+ {
119
+ "matcher": "path",
120
+ "argument": "ApplicationDetail.ApplicationStatus",
121
+ "expected": "DELETING",
122
+ "state": "failure"
123
+ },
124
+ {
125
+ "matcher": "path",
126
+ "argument": "ApplicationDetail.ApplicationStatus",
127
+ "expected": "ROLLING_BACK",
128
+ "state": "failure"
129
+ },
130
+ {
131
+ "matcher": "path",
132
+ "argument": "ApplicationDetail.ApplicationStatus",
133
+ "expected": "MAINTENANCE",
134
+ "state": "failure"
135
+ },
136
+ {
137
+ "matcher": "path",
138
+ "argument": "ApplicationDetail.ApplicationStatus",
139
+ "expected": "ROLLED_BACK",
140
+ "state": "failure"
141
+ },
142
+ {
143
+ "matcher": "path",
144
+ "argument": "ApplicationDetail.ApplicationStatus",
145
+ "expected": "READY",
146
+ "state": "success"
147
+ }
148
+ ]
149
+ }
150
+ }
151
+ }