File: interval_seconds_decl.py

package info (click to toggle)
python-moto 5.1.18-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116,520 kB
  • sloc: python: 636,725; javascript: 181; makefile: 39; sh: 3
file content (26 lines) | stat: -rw-r--r-- 914 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import Final

from moto.stepfunctions.parser.asl.component.eval_component import EvalComponent
from moto.stepfunctions.parser.asl.eval.environment import Environment


class IntervalSecondsDecl(EvalComponent):
    """
    IntervalSeconds: its value MUST be a positive integer, representing the number of seconds before the
    first retry attempt (default value: 1);
    """

    DEFAULT_SECONDS: Final[int] = 1
    MAX_VALUE: Final[int] = 99999999

    def __init__(self, seconds: int = DEFAULT_SECONDS):
        if not (1 <= seconds <= IntervalSecondsDecl.MAX_VALUE):
            raise ValueError(
                f"IntervalSeconds value MUST be a positive integer between "
                f"1 and {IntervalSecondsDecl.MAX_VALUE}, got '{seconds}'."
            )

        self.seconds: Final[int] = seconds

    def _eval_body(self, env: Environment) -> None:
        env.stack.append(self.seconds)