Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
xibin.song authored and JuziAha committed Apr 7, 2023
1 parent 7069591 commit 42c06c2
Show file tree
Hide file tree
Showing 246 changed files with 22,743 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessKey = a4ba942c-ca4a-4b898ea0cf8c-0398-41a9
secretKey = 8ea0cf8c-0398-41a9-a231-5925cc9cf3fd
orgId = o15520323695671
url = https://apim-ppe1.envisioniot.com
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.idea/workspace.xml
/.idea/inspectionProfiles/profiles_settings.xml
/.idea
.idea
838 changes: 838 additions & 0 deletions IoTHub/alert/alertApp.py

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions IoTHub/alert/content/createAlertContent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
* Copyright (C), 2015-2021, Envision
* FileName: createAlertContent
* Author: Dylan Yeo
* Date: 15/02/22
* Description: Create a new alert content
* History:
* <author> <time> <version> <desc>
*
* https://support.envisioniot.com/docs/alert-api/en/2.3.0/create_alert_content.html
"""

import poseidon.poseidon
from requests.models import PreparedRequest

def createAlertContent(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "create", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={"alertContent": {"contentId": "Python_Content_ID",
"contentDesc": {"defaultValue": "Default_Contents",
"i18nValue": {"en_US": "Contents",
"zh_CN": "内容",
"ja_JP":"コンテンツ",
"es_ES":"Contenido"}},
"tags": {"ContentKey1": "ContentValue1",
"ContentKey2": "ContentValue2",
"ContentKey3": "ContentValue3"},
"modelId": "Python_Demo_Model",
"alertTypeId": "Python_Type_ID"}
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


30 changes: 30 additions & 0 deletions IoTHub/alert/content/deleteAlertContent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
* Copyright (C), 2015-2021, Envision
* FileName: deleteAlertContent
* Author: Dylan Yeo
* Date: 15/02/22
* Description: Delete an alert content. It cannot be deleted if it is used by other rules
* History:
* <author> <time> <version> <desc>
*
* https://support.envisioniot.com/docs/alert-api/en/2.3.0/delete_alert_content.html
"""

import poseidon.poseidon
from requests.models import PreparedRequest

def deleteAlertContent(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "delete", "orgId": orgId, "alertContentId": "Python_Content_ID"}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


30 changes: 30 additions & 0 deletions IoTHub/alert/content/getAlertContent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
* Copyright (C), 2015-2021, Envision
* FileName: getAlertContent
* Author: Dylan Yeo
* Date: 15/02/22
* Description: Get an alert content based on orgId and contentId
* History:
* <author> <time> <version> <desc>
*
* https://support.envisioniot.com/docs/alert-api/en/2.3.0/get_alert_content.html
"""

import poseidon.poseidon
from requests.models import PreparedRequest

def getAlertContent(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "get", "orgId": orgId, "contentId": "Python_Content_ID"}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


91 changes: 91 additions & 0 deletions IoTHub/alert/content/searchAlertContent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"""
* Copyright (C), 2015-2021, Envision
* FileName: searchAlertContent
* Author: Dylan Yeo
* Date: 15/02/22
* Description: Search for alert content based on the search criteria
* History:
* <author> <time> <version> <desc>
*
* https://support.envisioniot.com/docs/alert-api/en/2.3.0/search_alert_content.html
"""

import poseidon.poseidon
from requests.models import PreparedRequest

def searchAlertContent(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "search", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={"pagination": {"pageNo": 1,
"pageSize": 10}
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


def searchAlertContent_modelId(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "search", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={"modelId": "Python_Demo_Model"
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


def searchAlertContent_alertTypeId(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "search", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={"alertTypeId": "Python_Type_ID"
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


def searchAlertContent_subAlertTypeId(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "search", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={"subAlertTypeId": "Python_Type_ID"
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


def searchAlertContent_Expression(accessKey, secretKey, orgId, url, Expression):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "search", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={"expression": Expression
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


40 changes: 40 additions & 0 deletions IoTHub/alert/content/updateAlertContent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
* Copyright (C), 2015-2021, Envision
* FileName: updateAlertContent
* Author: Dylan Yeo
* Date: 15/02/22
* Description: Update an alert content
* History:
* <author> <time> <version> <desc>
*
* https://support.envisioniot.com/docs/alert-api/en/2.3.0/update_alert_content.html
"""

import poseidon.poseidon
from requests.models import PreparedRequest

def updateAlertContent(accessKey, secretKey, orgId, url):
accessURL = url + '/event-service/v2.1/alert-contents'
params = {"action": "update", "orgId": orgId, "isPatchUpdate": "true"}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body={"alertContent": {"contentId": "Python_Content_ID",
"contentDesc": {"defaultValue": "Updated_Default_Contents",
"i18nValue": {"en_US": "Updated_Contents",
"zh_CN": "更新内容",
"ja_JP":"更新された内容",
"es_ES":"Contenidos Actualizados"}},
"tags": {"NewContentKey1": "NewContentValue1",
"NewContentKey2": "NewContentValue2",
"NewContentKey3": "NewContentValue3"},
"modelId": "Python_Demo_Model",
"alertTypeId": "Python_Type_ID"}
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)


32 changes: 32 additions & 0 deletions IoTHub/alert/record/new/alertTags/batchUpdateAlertTags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
* Copyright (C), 2015-2021, Envision
* FileName: batchUpdateAlertTags
* Author: Dylan Yeo
* Date: 18/02/22
* Description: Batch update the tags for the specified history and active alerts. The returned structure describes the update results of each alert. If an error message occurs, the error message will be recorded and the rest of the update will continue
* History:
* <author> <time> <version> <desc>
*
* https://support.envisioniot.com/docs/alert-api/en/2.3.0/new_version/batch_update_alert_tags.html
"""

import poseidon.poseidon
from requests.models import PreparedRequest

def batchUpdateAlertTags(accessKey, secretKey, orgId, url, alertId_list):
accessURL = url + '/alert-service/v2.1/alerts'
params = {"action": "batchUpdateTags", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body = {"alertIds": alertId_list,
"isPatchUpdate": True,
"tags": {"NewActiveAlert_newverKey1": "NewActiveAlert_newverValue1",
"NewActiveAlert_newverKey2": "NewActiveAlert_newverValue2",
"NewActiveAlert_newverKey3": "NewActiveAlert_newverValue3"},
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)
33 changes: 33 additions & 0 deletions IoTHub/alert/record/new/alertTags/updateAlertTags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
* Copyright (C), 2015-2021, Envision
* FileName: updateAlertTags
* Author: Dylan Yeo
* Date: 18/02/22
* Description: Update history and active alert tags
* History:
* <author> <time> <version> <desc>
*
* https://support.envisioniot.com/docs/alert-api/en/2.3.0/new_version/update_alert_tags.html
"""

import poseidon.poseidon
from requests.models import PreparedRequest

def updateAlertTags(accessKey, secretKey, orgId, url, alertId):
accessURL = url + '/alert-service/v2.1/alerts'
params = {"action": "updateTags", "orgId": orgId}
req = PreparedRequest()
req.prepare_url(accessURL, params)
print(req.url)

body = {"alertId": alertId,
"isPatchUpdate": True,
"tags": {"NewActiveAlert_newverKey1": "NewActiveAlert_newverValue1",
"NewActiveAlert_newverKey2": "NewActiveAlert_newverValue2",
"NewActiveAlert_newverKey3": "NewActiveAlert_newverValue3"},
}
print(body)

response = poseidon.poseidon.urlopen(accessKey, secretKey, req.url, body)
print(response)

Loading

0 comments on commit 42c06c2

Please sign in to comment.