ルールの作成
    • PDF

    ルールの作成

    • PDF

    Article Summary

    概要

    ルールを作成します。

    リクエスト

    リクエストURL

    POST {CLOUD_IOT_CORE_API_URL}/rules
    
    Content-Type: application/json; charset=utf-8
    x-ncp-apigw-timestamp: {Timestamp}
    x-ncp-iam-access-key: {Sub Account Access Key}
    x-ncp-apigw-signature-v2: {API Gateway Signature}
    

    リクエストボディー

    {
            "rule": {
                "name": "string",
                "description": "string",
                "query": "string"
            },
            "actions": {
                "matchActionList": [
                    {
                        "relatedProduct": "string",
                        "relatedProductAction": "json"
                    }
                ],
                "errorAction": {
                    "relatedProduct": "string",
                    "relatedProductAction": "json"
                }
            }
        }
    
    項目必須の有無タイプ制約事項説明
    ruleYesルール
    rule.nameYesstring128字以内のアルファベットの大文字小文字、数字、-、_のみ許可ルール名
    rule.descriptionNostring255字以内ルール説明
    rule.queryYesstringルールクエリのルールルールクエリ
    actionsYesアクション
    matchedActionListYesルールクエリを満たす場合に実行するアクション
    actions.matchedActionList[].relateProductYesstring下段のrelatedProductを参考連携するアクションの種類
    actions.matchedActionList[].relateProductActionYesjson下段のrelatedProductActionを参考連携するアクションの詳細
    errorActionNoエラーアクションを連携する場合、relatedProduct、relatedProductActionフィールド必須エラーアクション
    errorAction.relateProductNostring下段のrelatedProductを参考連携するアクションの種類
    errorAction.relateProductActionNojson下段のrelatedProductActionを参考連携するアクションの詳細

    relatedProduct

    relatedProductアクション名
    REPUBLISH指定したトピックに再発行
    CLOUD_FUNCTIONSCloud Functionsにデータを転送

    relatedProductAction

    REPUBLISH

    {
            "topic":  "string"
    }
    
    項目必須の有無タイプ制約事項説明
    topicYesstringトピック制限再発行トピック

    CLOUD_FUNCTIONS

    {
            "name":  "string",
            "batchTime": "integer"
    }
    
    項目必須の有無タイプ制約事項説明
    nameYesstringCloud Functionsに登録されたIoT trigger名前
    batchTimeNointegerMin: 5, Max: 600Cloud Functions batch interval (Seconds)

    リクエスト例

    {
        "rule": {
            "name": "lux",
            "description": "turn off",
            "query": "select lux, bulb_id from \"myhome100/abc/+/abc\" where lux > -1"
        },
        "actions": {
            "matchActionList": [
                {
                    "relatedProduct": "REPUBLISH",
                    "relatedProductAction": {
                        "topic": "republish_a"
                    }
                }
            ],
            "errorAction": {
                "relatedProduct": "REPUBLISH",
                "relatedProductAction": {
                    "topic": "republish_a"
                }
            }
        }
    }
    

    レスポンス

    レスポンスボディ

    {
        "status": "string",
        "body": {
            "rule": {
                "name": "string",
                "description": "string",
                "status": "string",
                "query": "string",
                "modifyTime": "localDateTime",
                "registerTime": "localDateTime",
                "filterTopic": "string"
            },
            "actions": {
                "matchActionList": [
                    {
                        "type": "string",
                        "relatedProduct": "string",
                        "displayName": "string",
                        "modifyTime": "localDateTime",
                        "registerTime": "localDateTime",
                        "relatedProductAction": "json"
                    }
                ],
                "errorAction": {
                    "type": "string",
                    "relatedProduct": "string",
                    "displayName": "string",
                    "modifyTime": "localDateTime",
                    "registerTime": "localDateTime",
                    "relatedProductAction": "json"
                }
            }
        }
    }
    
    項目タイプ説明
    statusstringレスポンスの成否
    body.rule.namestringルール名
    body.rule.descriptionstringルール説明
    body.rule.statusstringルールの状態
    body.rule.querystringルールクエリ
    body.rule.modifyTimelocalDateTime最終修正日
    body.rule.registerTimelocalDateTimeルールの作成日
    body.rule.filterTopicstringルールトピック
    body.actions.matchActionList[].typestringアクションロール(M: matchedAction、E: errorAction)
    body.actions.matchActionList[].relatedProductstringアクションの種類
    body.actions.matchActionList[].displayNamestringアクションの代表名
    body.actions.matchActionList[].modifyTimestringアクションの最終修正日
    body.actions.matchActionList[].registerTimestringアクションの作成日
    body.actions.matchActionList[].relatedProductActionjsonアクションの詳細
    body.actions.errorAction.typestringアクションロール(M: matchedAction、E: errorAction)
    body.actions.errorAction.relatedProductstringエラーアクションの種類
    body.actions.errorAction.displayNamestringエラーアクションの代表名
    body.actions.errorAction.modifyTimestringエラーアクションの最終修正日
    body.actions.errorAction.registerTimestringエラーアクションの作成日
    body.actions.errorAction.relatedProductActionjsonエラーアクションの詳細

    レスポンス例

    {
        "status": "SUCCESS",
        "body": {
            "rule": {
                "name": "lux",
                "description": "turn off",
                "status": "ENABLE",
                "query": "select lux, bulb_id from \"myhome100/abc/+/abc\" where lux > -1",
                "modifyTime": "2020-09-27 12:52:08",
                "registerTime": "2020-09-27 12:52:08",
                "filterTopic": "myhome100/abc/+/abc"
            },
            "actions": {
                "matchActionList": [
                    {
                        "type": "M",
                        "relatedProduct": "REPUBLISH",
                        "displayName": "republish_a",
                        "modifyTime": "2020-09-27 12:52:08",
                        "registerTime": "2020-09-27 12:52:08",
                        "relatedProductAction": {
                            "topic": "republish_a",
                            "version": 1
                        }
                    }
                ],
                "errorAction": {
                    "type": "E",
                    "relatedProduct": "REPUBLISH",
                    "displayName": "republish_a",
                    "modifyTime": "2020-09-27 12:52:08",
                    "registerTime": "2020-09-27 12:52:08",
                    "relatedProductAction": {
                        "topic": "republish_a",
                        "version": 1
                    }
                }
            }
        }
    }
    

    この記事は役に立ちましたか?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.