규칙 생성
- 인쇄
- PDF
규칙 생성
- 인쇄
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
개요
규칙을 생성합니다
요청
요청 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"
}
}
}
항목 | 필수 여부 | 타입 | 제약 사항 | 설명 |
---|---|---|---|---|
rule | Yes | 규칙 | ||
rule.name | Yes | string | 128자 이내의 영대소문자, 숫자, -, _만 허용 | 규칙 이름 |
rule.description | No | string | 255자 이내 | 규칙 설명 |
rule.query | Yes | string | 규칙 쿼리 규칙 | 규칙 쿼리 |
actions | Yes | 액션 | ||
matchedActionList | Yes | 규칙 쿼리를 만족하는 경우 수행할 액션 | ||
actions.matchedActionList[].relateProduct | Yes | string | 하단 relatedProduct 참고 | 연동할 액션 종류 |
actions.matchedActionList[].relateProductAction | Yes | json | 하단 relatedProductAction 참고 | 연동할 액션 상세 |
errorAction | No | 에러 액션을 연동할 경우, relatedProduct, relatedProductAction 필드 필수 | 에러 액션 | |
errorAction.relateProduct | No | string | 하단 relatedProduct 참고 | 연동할 액션 종류 |
errorAction.relateProductAction | No | json | 하단 relatedProductAction 참고 | 연동할 액션 상세 |
relatedProduct
relatedProduct | 액션명 |
---|---|
REPUBLISH | 지정한 토픽으로 재발행 |
CLOUD_FUNCTIONS | Cloud Functions로 데이터 전송 |
relatedProductAction
- REPUBLISH
{
"topic": "string"
}
항목 | 필수 여부 | 타입 | 제약 사항 | 설명 |
---|---|---|---|---|
topic | Yes | string | 토픽 제한 | 재발행 토픽 |
- CLOUD_FUNCTIONS
{
"name": "string",
"batchTime": "integer"
}
항목 | 필수 여부 | 타입 | 제약 사항 | 설명 |
---|---|---|---|---|
name | Yes | string | Cloud Functions에 등록된 IoT rule 이름 | |
batchTime | No | integer | Min: 5, Max: 600 | Cloud Functions 배치 실행 시간(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"
}
}
}
}
항목 | 타입 | 설명 |
---|---|---|
status | string | 응답 성공 여부 |
body.rule.name | string | 규칙 이름 |
body.rule.description | string | 규칙 설명 |
body.rule.status | string | 규칙 상태 |
body.rule.query | string | 규칙 쿼리 |
body.rule.modifyTime | localDateTime | 최근 수정날짜 |
body.rule.registerTime | localDateTime | 규칙 생성날짜 |
body.rule.filterTopic | string | 규칙 토픽 |
body.actions.matchActionList[].type | string | 액션 역할 (M: matchedAction, E: errorAction) |
body.actions.matchActionList[].relatedProduct | string | 액션 종류 |
body.actions.matchActionList[].displayName | string | 액션 대표 이름 |
body.actions.matchActionList[].modifyTime | string | 액션 최근 수정날짜 |
body.actions.matchActionList[].registerTime | string | 액션 생성날짜 |
body.actions.matchActionList[].relatedProductAction | json | 액션 상세 |
body.actions.errorAction.type | string | 액션 역할 (M: matchedAction, E: errorAction) |
body.actions.errorAction.relatedProduct | string | 에러 액션 종류 |
body.actions.errorAction.displayName | string | 에러 액션 대표 이름 |
body.actions.errorAction.modifyTime | string | 에러 액션 최근 수정날짜 |
body.actions.errorAction.registerTime | string | 에러 액션 생성날짜 |
body.actions.errorAction.relatedProductAction | json | 에러 액션 상세 |
응답 예시
{
"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
}
}
}
}
}
이 문서가 도움이 되었습니까?