|
| 1 | +# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). |
| 4 | +# You may not use this file except in compliance with the License. |
| 5 | +# A copy of the License is located at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is distributed |
| 10 | +# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 | +# express or implied. See the License for the specific language governing |
| 12 | +# permissions and limitations under the License. |
| 13 | +from __future__ import absolute_import |
| 14 | + |
| 15 | +from stepfunctions.steps.states import Task |
| 16 | +from stepfunctions.steps.fields import Field |
| 17 | + |
| 18 | + |
| 19 | +class DynamoDBGetItemStep(Task): |
| 20 | + """ |
| 21 | + Creates a Task state to get an item from DynamoDB. See `Call DynamoDB APIs with Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/connect-ddb.html>`_ for more details. |
| 22 | + """ |
| 23 | + |
| 24 | + def __init__(self, state_id, **kwargs): |
| 25 | + """ |
| 26 | + Args: |
| 27 | + state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine. |
| 28 | + comment (str, optional): Human-readable comment or description. (default: None) |
| 29 | + input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$') |
| 30 | + parameters (dict, optional): The value of this field becomes the effective input for the state. |
| 31 | + result_path (str, optional): Path specifying the raw input’s combination with or replacement by the state’s result. (default: '$') |
| 32 | + output_path (str, optional): Path applied to the state’s output after the application of `result_path`, producing the effective output which serves as the raw input for the next state. (default: '$') |
| 33 | + """ |
| 34 | + kwargs[Field.Resource.value] = 'arn:aws:states:::dynamodb:getItem' |
| 35 | + super(DynamoDBGetItemStep, self).__init__(state_id, **kwargs) |
| 36 | + |
| 37 | + |
| 38 | +class DynamoDBPutItemStep(Task): |
| 39 | + |
| 40 | + """ |
| 41 | + Creates a Task state to put an item to DynamoDB. See `Call DynamoDB APIs with Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/connect-ddb.html>`_ for more details. |
| 42 | + """ |
| 43 | + |
| 44 | + def __init__(self, state_id, **kwargs): |
| 45 | + """ |
| 46 | + Args: |
| 47 | + state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine. |
| 48 | + comment (str, optional): Human-readable comment or description. (default: None) |
| 49 | + input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$') |
| 50 | + parameters (dict, optional): The value of this field becomes the effective input for the state. |
| 51 | + result_path (str, optional): Path specifying the raw input’s combination with or replacement by the state’s result. (default: '$') |
| 52 | + output_path (str, optional): Path applied to the state’s output after the application of `result_path`, producing the effective output which serves as the raw input for the next state. (default: '$') |
| 53 | + """ |
| 54 | + kwargs[Field.Resource.value] = 'arn:aws:states:::dynamodb:putItem' |
| 55 | + super(DynamoDBPutItemStep, self).__init__(state_id, **kwargs) |
| 56 | + |
| 57 | + |
| 58 | +class DynamoDBDeleteItemStep(Task): |
| 59 | + |
| 60 | + """ |
| 61 | + Creates a Task state to delete an item from DynamoDB. See `Call DynamoDB APIs with Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/connect-ddb.html>`_ for more details. |
| 62 | + """ |
| 63 | + |
| 64 | + def __init__(self, state_id, **kwargs): |
| 65 | + """ |
| 66 | + Args: |
| 67 | + state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine. |
| 68 | + comment (str, optional): Human-readable comment or description. (default: None) |
| 69 | + input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$') |
| 70 | + parameters (dict, optional): The value of this field becomes the effective input for the state. |
| 71 | + result_path (str, optional): Path specifying the raw input’s combination with or replacement by the state’s result. (default: '$') |
| 72 | + output_path (str, optional): Path applied to the state’s output after the application of `result_path`, producing the effective output which serves as the raw input for the next state. (default: '$') |
| 73 | + """ |
| 74 | + kwargs[Field.Resource.value] = 'arn:aws:states:::dynamodb:deleteItem' |
| 75 | + super(DynamoDBDeleteItemStep, self).__init__(state_id, **kwargs) |
| 76 | + |
| 77 | + |
| 78 | +class DynamoDBUpdateItemStep(Task): |
| 79 | + |
| 80 | + """ |
| 81 | + Creates a Task state to update an item from DynamoDB. See `Call DynamoDB APIs with Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/connect-ddb.html>`_ for more details. |
| 82 | + """ |
| 83 | + |
| 84 | + def __init__(self, state_id, **kwargs): |
| 85 | + """ |
| 86 | + Args: |
| 87 | + state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine. |
| 88 | + comment (str, optional): Human-readable comment or description. (default: None) |
| 89 | + input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$') |
| 90 | + parameters (dict, optional): The value of this field becomes the effective input for the state. |
| 91 | + result_path (str, optional): Path specifying the raw input’s combination with or replacement by the state’s result. (default: '$') |
| 92 | + output_path (str, optional): Path applied to the state’s output after the application of `result_path`, producing the effective output which serves as the raw input for the next state. (default: '$') |
| 93 | + """ |
| 94 | + kwargs[Field.Resource.value] = 'arn:aws:states:::dynamodb:updateItem' |
| 95 | + super(DynamoDBUpdateItemStep, self).__init__(state_id, **kwargs) |
| 96 | + |
| 97 | + |
| 98 | +class SnsPublishStep(Task): |
| 99 | + |
| 100 | + """ |
| 101 | + Creates a Task state to publish a message to SNS topic. See `Call Amazon SNS with Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/connect-sns.html>`_ for more details. |
| 102 | + """ |
| 103 | + |
| 104 | + def __init__(self, state_id, wait_for_callback=False, **kwargs): |
| 105 | + """ |
| 106 | + Args: |
| 107 | + state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine. |
| 108 | + wait_for_callback(bool, optional): Boolean value set to `True` if the Task state should wait for callback to resume the operation. (default: False) |
| 109 | + timeout_seconds (int, optional): Positive integer specifying timeout for the state in seconds. If the state runs longer than the specified timeout, then the interpreter fails the state with a `States.Timeout` Error Name. (default: 60) |
| 110 | + heartbeat_seconds (int, optional): Positive integer specifying heartbeat timeout for the state in seconds. This value should be lower than the one specified for `timeout_seconds`. If more time than the specified heartbeat elapses between heartbeats from the task, then the interpreter fails the state with a `States.Timeout` Error Name. |
| 111 | + comment (str, optional): Human-readable comment or description. (default: None) |
| 112 | + input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$') |
| 113 | + parameters (dict, optional): The value of this field becomes the effective input for the state. |
| 114 | + result_path (str, optional): Path specifying the raw input’s combination with or replacement by the state’s result. (default: '$') |
| 115 | + output_path (str, optional): Path applied to the state’s output after the application of `result_path`, producing the effective output which serves as the raw input for the next state. (default: '$') |
| 116 | + """ |
| 117 | + if wait_for_callback: |
| 118 | + kwargs[Field.Resource.value] = 'arn:aws:states:::sns:publish.waitForTaskToken' |
| 119 | + else: |
| 120 | + kwargs[Field.Resource.value] = 'arn:aws:states:::sns:publish' |
| 121 | + |
| 122 | + super(SnsPublishStep, self).__init__(state_id, **kwargs) |
| 123 | + |
| 124 | + |
| 125 | +class SqsSendMessageStep(Task): |
| 126 | + |
| 127 | + """ |
| 128 | + Creates a Task state to send a message to SQS queue. See `Call Amazon SQS with Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/connect-sqs.html>`_ for more details. |
| 129 | + """ |
| 130 | + |
| 131 | + def __init__(self, state_id, wait_for_callback=False, **kwargs): |
| 132 | + """ |
| 133 | + Args: |
| 134 | + state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine. |
| 135 | + wait_for_callback(bool, optional): Boolean value set to `True` if the Task state should wait for callback to resume the operation. (default: False) |
| 136 | + timeout_seconds (int, optional): Positive integer specifying timeout for the state in seconds. If the state runs longer than the specified timeout, then the interpreter fails the state with a `States.Timeout` Error Name. (default: 60) |
| 137 | + heartbeat_seconds (int, optional): Positive integer specifying heartbeat timeout for the state in seconds. This value should be lower than the one specified for `timeout_seconds`. If more time than the specified heartbeat elapses between heartbeats from the task, then the interpreter fails the state with a `States.Timeout` Error Name. |
| 138 | + comment (str, optional): Human-readable comment or description. (default: None) |
| 139 | + input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$') |
| 140 | + parameters (dict, optional): The value of this field becomes the effective input for the state. |
| 141 | + result_path (str, optional): Path specifying the raw input’s combination with or replacement by the state’s result. (default: '$') |
| 142 | + output_path (str, optional): Path applied to the state’s output after the application of `result_path`, producing the effective output which serves as the raw input for the next state. (default: '$') |
| 143 | + """ |
| 144 | + if wait_for_callback: |
| 145 | + kwargs[Field.Resource.value] = 'arn:aws:states:::sqs:sendMessage.waitForTaskToken' |
| 146 | + else: |
| 147 | + kwargs[Field.Resource.value] = 'arn:aws:states:::sqs:sendMessage' |
| 148 | + |
| 149 | + super(SqsSendMessageStep, self).__init__(state_id, **kwargs) |
0 commit comments