aws-cdk.aws-iotevents-actions-alpha


Nameaws-cdk.aws-iotevents-actions-alpha JSON
Version 2.170.0a0 PyPI version JSON
download
home_pagehttps://github.com/aws/aws-cdk
SummaryReceipt Detector Model actions for AWS IoT Events
upload_time2024-11-22 04:42:23
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Actions for AWS::IoTEvents Detector Model

<!--BEGIN STABILITY BANNER-->---


![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.

---
<!--END STABILITY BANNER-->

This library contains integration classes to specify actions of state events of Detector Model in `@aws-cdk/aws-iotevents-alpha`.
Instances of these classes should be passed to `State` defined in `@aws-cdk/aws-iotevents-alpha`
You can define built-in actions to use a timer or set a variable, or send data to other AWS resources.

This library contains integration classes to use a timer or set a variable, or send data to other AWS resources.
AWS IoT Events can trigger actions when it detects a specified event or transition event.

Currently supported are:

* Use timer
* Set variable to detector instance
* Invoke a Lambda function

## Use timer

The code snippet below creates an Action that creates the timer with duration in seconds.

```python
# Example automatically generated from non-compiling source. May contain errors.
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions

# input: iotevents.IInput

state = iotevents.State(
    state_name="MyState",
    on_enter=[iotevents.Event(
        event_name="test-event",
        condition=iotevents.Expression.current_input(input),
        actions=[
            actions.SetTimerAction("MyTimer", {
                "duration": cdk.Duration.seconds(60)
            })
        ]
    )]
)
```

Setting duration by [IoT Events Expression](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-expressions.html):

```python
# Example automatically generated from non-compiling source. May contain errors.
actions.SetTimerAction("MyTimer",
    duration_expression=iotevents.Expression.input_attribute(input, "payload.durationSeconds")
)
```

And the timer can be reset and cleared. Below is an example of general
[Device HeartBeat](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-examples-dhb.html)
Detector Model:

```python
# Example automatically generated from non-compiling source. May contain errors.
online = iotevents.State(
    state_name="Online",
    on_enter=[{
        "event_name": "enter-event",
        "condition": iotevents.Expression.current_input(input),
        "actions": [
            actions.SetTimerAction("MyTimer",
                duration=cdk.Duration.seconds(60)
            )
        ]
    }],
    on_input=[{
        "event_name": "input-event",
        "condition": iotevents.Expression.current_input(input),
        "actions": [
            actions.ResetTimerAction("MyTimer")
        ]
    }],
    on_exit=[{
        "event_name": "exit-event",
        "actions": [
            actions.ClearTimerAction("MyTimer")
        ]
    }]
)
offline = iotevents.State(state_name="Offline")

online.transition_to(offline, when=iotevents.Expression.timeout("MyTimer"))
offline.transition_to(online, when=iotevents.Expression.current_input(input))
```

## Set variable to detector instance

The code snippet below creates an Action that set variable to detector instance
when it is triggered.

```python
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions

# input: iotevents.IInput

state = iotevents.State(
    state_name="MyState",
    on_enter=[iotevents.Event(
        event_name="test-event",
        condition=iotevents.Expression.current_input(input),
        actions=[
            actions.SetVariableAction("MyVariable",
                iotevents.Expression.input_attribute(input, "payload.temperature"))
        ]
    )]
)
```

## Invoke a Lambda function

The code snippet below creates an Action that invoke a Lambda function
when it is triggered.

```python
import aws_cdk.aws_iotevents_alpha as iotevents
import aws_cdk.aws_iotevents_actions_alpha as actions
import aws_cdk.aws_lambda as lambda_

# input: iotevents.IInput
# func: lambda.IFunction

state = iotevents.State(
    state_name="MyState",
    on_enter=[iotevents.Event(
        event_name="test-event",
        condition=iotevents.Expression.current_input(input),
        actions=[actions.LambdaInvokeAction(func)]
    )]
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aws/aws-cdk",
    "name": "aws-cdk.aws-iotevents-actions-alpha",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Amazon Web Services",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/8c/1f/ef730e0bce02cb46e30c586fc0ea0afe515a2f5ca880ac5e6cf9a0655a80/aws_cdk_aws_iotevents_actions_alpha-2.170.0a0.tar.gz",
    "platform": null,
    "description": "# Actions for AWS::IoTEvents Detector Model\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n<!--END STABILITY BANNER-->\n\nThis library contains integration classes to specify actions of state events of Detector Model in `@aws-cdk/aws-iotevents-alpha`.\nInstances of these classes should be passed to `State` defined in `@aws-cdk/aws-iotevents-alpha`\nYou can define built-in actions to use a timer or set a variable, or send data to other AWS resources.\n\nThis library contains integration classes to use a timer or set a variable, or send data to other AWS resources.\nAWS IoT Events can trigger actions when it detects a specified event or transition event.\n\nCurrently supported are:\n\n* Use timer\n* Set variable to detector instance\n* Invoke a Lambda function\n\n## Use timer\n\nThe code snippet below creates an Action that creates the timer with duration in seconds.\n\n```python\n# Example automatically generated from non-compiling source. May contain errors.\nimport aws_cdk.aws_iotevents_alpha as iotevents\nimport aws_cdk.aws_iotevents_actions_alpha as actions\n\n# input: iotevents.IInput\n\nstate = iotevents.State(\n    state_name=\"MyState\",\n    on_enter=[iotevents.Event(\n        event_name=\"test-event\",\n        condition=iotevents.Expression.current_input(input),\n        actions=[\n            actions.SetTimerAction(\"MyTimer\", {\n                \"duration\": cdk.Duration.seconds(60)\n            })\n        ]\n    )]\n)\n```\n\nSetting duration by [IoT Events Expression](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-expressions.html):\n\n```python\n# Example automatically generated from non-compiling source. May contain errors.\nactions.SetTimerAction(\"MyTimer\",\n    duration_expression=iotevents.Expression.input_attribute(input, \"payload.durationSeconds\")\n)\n```\n\nAnd the timer can be reset and cleared. Below is an example of general\n[Device HeartBeat](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-examples-dhb.html)\nDetector Model:\n\n```python\n# Example automatically generated from non-compiling source. May contain errors.\nonline = iotevents.State(\n    state_name=\"Online\",\n    on_enter=[{\n        \"event_name\": \"enter-event\",\n        \"condition\": iotevents.Expression.current_input(input),\n        \"actions\": [\n            actions.SetTimerAction(\"MyTimer\",\n                duration=cdk.Duration.seconds(60)\n            )\n        ]\n    }],\n    on_input=[{\n        \"event_name\": \"input-event\",\n        \"condition\": iotevents.Expression.current_input(input),\n        \"actions\": [\n            actions.ResetTimerAction(\"MyTimer\")\n        ]\n    }],\n    on_exit=[{\n        \"event_name\": \"exit-event\",\n        \"actions\": [\n            actions.ClearTimerAction(\"MyTimer\")\n        ]\n    }]\n)\noffline = iotevents.State(state_name=\"Offline\")\n\nonline.transition_to(offline, when=iotevents.Expression.timeout(\"MyTimer\"))\noffline.transition_to(online, when=iotevents.Expression.current_input(input))\n```\n\n## Set variable to detector instance\n\nThe code snippet below creates an Action that set variable to detector instance\nwhen it is triggered.\n\n```python\nimport aws_cdk.aws_iotevents_alpha as iotevents\nimport aws_cdk.aws_iotevents_actions_alpha as actions\n\n# input: iotevents.IInput\n\nstate = iotevents.State(\n    state_name=\"MyState\",\n    on_enter=[iotevents.Event(\n        event_name=\"test-event\",\n        condition=iotevents.Expression.current_input(input),\n        actions=[\n            actions.SetVariableAction(\"MyVariable\",\n                iotevents.Expression.input_attribute(input, \"payload.temperature\"))\n        ]\n    )]\n)\n```\n\n## Invoke a Lambda function\n\nThe code snippet below creates an Action that invoke a Lambda function\nwhen it is triggered.\n\n```python\nimport aws_cdk.aws_iotevents_alpha as iotevents\nimport aws_cdk.aws_iotevents_actions_alpha as actions\nimport aws_cdk.aws_lambda as lambda_\n\n# input: iotevents.IInput\n# func: lambda.IFunction\n\nstate = iotevents.State(\n    state_name=\"MyState\",\n    on_enter=[iotevents.Event(\n        event_name=\"test-event\",\n        condition=iotevents.Expression.current_input(input),\n        actions=[actions.LambdaInvokeAction(func)]\n    )]\n)\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Receipt Detector Model actions for AWS IoT Events",
    "version": "2.170.0a0",
    "project_urls": {
        "Homepage": "https://github.com/aws/aws-cdk",
        "Source": "https://github.com/aws/aws-cdk.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c7f4e194feb96f20bdb3f8f35cc90d8c81084941e8b2d91161c112ba01a69ed7",
                "md5": "6de79c9a239700be4c5fdabbb1256dbc",
                "sha256": "37ca043b63407ba1807fa303a11106e5bfdae7d3480545dd87b444a83d760a03"
            },
            "downloads": -1,
            "filename": "aws_cdk.aws_iotevents_actions_alpha-2.170.0a0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6de79c9a239700be4c5fdabbb1256dbc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 45263,
            "upload_time": "2024-11-22T04:41:36",
            "upload_time_iso_8601": "2024-11-22T04:41:36.880956Z",
            "url": "https://files.pythonhosted.org/packages/c7/f4/e194feb96f20bdb3f8f35cc90d8c81084941e8b2d91161c112ba01a69ed7/aws_cdk.aws_iotevents_actions_alpha-2.170.0a0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c1fef730e0bce02cb46e30c586fc0ea0afe515a2f5ca880ac5e6cf9a0655a80",
                "md5": "476c978015e68bf401d39618b83aaa10",
                "sha256": "cb42c37b2d3cda6f54cf7ebbedc438ff1fdd8c777f1733b5ea042ac6d65b2ae9"
            },
            "downloads": -1,
            "filename": "aws_cdk_aws_iotevents_actions_alpha-2.170.0a0.tar.gz",
            "has_sig": false,
            "md5_digest": "476c978015e68bf401d39618b83aaa10",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 46206,
            "upload_time": "2024-11-22T04:42:23",
            "upload_time_iso_8601": "2024-11-22T04:42:23.636238Z",
            "url": "https://files.pythonhosted.org/packages/8c/1f/ef730e0bce02cb46e30c586fc0ea0afe515a2f5ca880ac5e6cf9a0655a80/aws_cdk_aws_iotevents_actions_alpha-2.170.0a0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-22 04:42:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aws",
    "github_project": "aws-cdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aws-cdk.aws-iotevents-actions-alpha"
}
        
Elapsed time: 1.35735s