iotery.io python服务器sdk

iotery-python-server-sdk的Python项目详细描述


iotery.io python服务器sdk

python iotery.io sdk将用于您的服务器或数据处理应用程序中,以与itoery.io iot平台进行交互。sdk是REST API的功能齐全的包装器。

开始

iotery.io上设置免费帐户,然后转到settings dashboard获取服务器api密钥。

获取密钥后,安装sdk:

pip install iotery-python-server-sdk

Note: Make sure you are using Python 3.5+!

最后,一些简单的示例用法:

fromiotery_python_server_sdkimportIoteryiotery=Iotery("my-key")# find the exact `data` specification at https://iotery.io/v1/docs#createDeviceTypedevice_type=iotery.createDeviceType(data={"name":"My Device Type","enum":"MY_DEVICE_TYPE",...})device_type_by_uuid=iotery.getDeviceTypeByUuid(deviceTypeUuid=device_type["uuid"],opts={"limit":1})

The above code connects you to the iotary.io platform, creates a device type and then gets that device type.

接下来,您可能需要为创建的设备类型创建一个数据类型…下面是一个示例片段:

temperature_data_type=iotery.createDataType(deviceTypeUuid=device_type_by_uuid["uuid"],data={name:"Temperature",enum:"TEMPERATURE",units:"C",isNumber:true})

To have a "thing" (like a Raspberry Pi) create data, you will want to check out the iotery.io thing client.

有关使用iotery.io在15分钟内设置完整堆栈系统的教程,请查看this link

API

这个sdk简单地包装了REST API,因此可以在那里找到更多的信息和细节。由于api是restapi的包装器,因此语法是iotery.io资源上每个创建、读取、更新和删除操作的标准。所有方法都返回一个包含api响应的dictional。如果有错误,方法将raise一个期望值。

创建资源

在iotery.io python sdk中创建资源的通用语法如下:

iotery.methodName(inputParameter="parameter",data={"data":"variables"})

例如,要创建设备,javascript看起来像

createDevice(deviceTypeUuid="a-valid-device-type-uuid",data={"name":"My Device","other":"parameter"})

其中createDevice映射到methodNamedeviceTypeUuid映射到inputParameter,并且nameother映射到上述广义形式的指令{data : "variables"}

可用的资源创建方法是

^{}^{}link^{}
createAccountManagerlinkCreate an account manager.
createConsumerlinkCreate a consumer.
linkConsumerToDeviceconsumerUuidlinkLink a consumer to a device.
linkConsumerToNetworkconsumerUuidlinkLink a consumer to a network.
createConsumerSecretconsumerUuidlinkCreate a consumer secret for authentication.
createDeviceTypelinkCreate a device type.
createSettingTypelinkCreate a setting type.
createDefaultSettinglinkCreate a default setting.
createDataTypelinkCreate a data type.
createDevicelinkCreate a device.
createBatchedCommandInstanceslinkCreate a set of batched command instances.
clearUnexecutedDeviceCommandInstancesdeviceUuidlinkClear all unexecuted command instance for a device.
createDeviceCommandInstancedeviceUuidlinkCreate a command instance for a device.
createDeviceNotificationInstancedeviceUuidlinkCreate a notification instance for a device.
createSettingdeviceUuidlinkCreate a setting for a device.
createFirmwareRecordlinkCreate a firmware record.
createSeverityTypelinkCreate a severity type.
createNotificationTypelinkCreate a notification type.
createNotificationFieldlinkCreate a notification field.
createPriorityTypelinkCreate a priority type.
createCommandTypelinkCreate a command type.
createCommandFieldlinkCreate a command field.
createEventTypelinkCreate an event type.
createEventlinkCreate an event.
createGroupingTypelinkCreate a grouping type.
createTeamlinkCreate a team.
linkAccountManagerToTeamuserUuidlinkLink account manager to a team.
resetTeamteamUuidlinkReset a team by uuid.
createGroupingBatchedCommandsgroupingUuidlinkCreate a set of batched commands for a grouping and all child grouping devices.
moveDeviceToGroupinggroupingUuidlinkMove a device to a grouping.
createNetworklinkCreate a network.
createNetworkBatchedCommandsnetworkUuidlinkCreate a set of batched commands for a network's devices.
createGroupingnetworkUuidlinkCreate a network grouping.
addChildGroupingnetworkUuid,groupingUuidlinkAdd a child grouping.
createNetworkLocationnetworkUuidlinkCreate a network location.
createSchedulenetworkUuidlinkCreate a schedule.
executeNetworkSchedulenetworkUuid,scheduleUuidlinkExecute a schedule.
deprovisionNetworknetworkUuidlinkDeprovision a network.
provisionNetworklinkProvision a network.
provisionDevicenetworkUuid,deviceUuidlinkProvision a device.
deprovisionDevicenetworkUuid,deviceUuidlinkDeprovision a device.
executeSchedulescheduleUuidlinkExecute a schedule.
createGroupingDevicelinkCreate a GroupingDevice link.
createGroupingLinklinkCreate a GroupingLink.
createWebhookActionlinkCreate a webhook action.

阅读资源

iotery.io python sdk中用于读取(获取)资源的通用语法如下:

iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})

例如,要通过设备的唯一标识符uuid获取设备,python看起来像

getDeviceByUuid(deviceUuid="a-valid-device-uuid",opts={"limit":1})

其中getDeviceByUuid映射到methodNamedeviceUuid映射到inputParameter{ "limit": 1 }映射到上述广义形式的指令{"query" : "parameters"}

The limit option is for instructive purposes only. By definition, a uuid is unique and so there will never be more than one device for a given uuid.

对于更高级的查询,有些参数允许传入值数组。两个可用的选项是$in$btwn,这两个选项允许用户分别指定值的集合或范围。例如,当为设备请求数据时,可以如下使用sdk:

iotery.getDeviceDataList(opts={"dataTypeEnum":{"$in":["ENUM_1","ENUM_2","ENUM_3"]},"timestamp":{"$btwn":[1562759000,1562759500]},"limit":5},deviceUuid="a-valid-device-uuid")

请参阅iotery rest api文档,查看给定查询参数的$in$btwn等选项何时可用。

可用的资源创建方法是

^{}^{}link^{}
getHealthCheckResultlinkGet the result of a server health check.
getAccountManageruserUuidlinkGet an account manager by uuid.
getConsumerListlinkGet a list of available consumers.
getConsumerconsumerUuidlinkGet a consumer by uuid.
getDeviceTypeListlinkGet a list of available device types.
getDeviceTypedeviceTypeUuidlinkGet a device type by uuid.
getSettingTypeListlinkGet a list of available setting types.
getSettingTypesettingTypeUuidlinkGet a setting type by uuid.
getDefaultSettingListlinkGet a list of default settings.
getDefaultSettingdefaultSettingUuidlinkGet a default setting by uuid.
getDataTypeListlinkGet a list of available data types.
getDataTypedataTypeUuidlinkGet a data type by uuid.
getCommandInstanceListlinkGet a list of command instances.
getDeviceListlinkGet a list of devices.
getDevicedeviceUuidlinkGet a device by uuid.
getDeviceDataListdeviceUuidlinkGet a list of data for a device.
getDeviceEventListdeviceUuidlinkGet a list of events for a device.
getDeviceIsppConfigurationdeviceUuidlinkGet an ISPP configuration for a device.
getDeviceNotificationInstanceListdeviceUuidlinkGet a list of notification instances for a device.
getDeviceSettingListdeviceUuidlinkGet a list of settings for a device.
getNotificationInstancenotificationInstanceUuidlinkGet a notification instance by uuid.
getSettingsettingUuidlinkGet a setting by uuid.
getFirmwareRecordListlinkGet a list of firmware records.
getFirmwareRecordfirmwareUuidlinkGet a firmware record by uuid.
getSeverityTypeListlinkGet a list of available severity types.
getSeverityTypeseverityTypeUuidlinkDelete a severity type by uuid.
getNotificationTypeListlinkGet a list of available notification types.
getNotificationTypenotificationTypeUuidlinkGet a notification type by uuid.
getNotificationFieldListlinkGet a list of available notification fields.
getNotificationFieldnotificationFieldUuidlinkGet a notification field by uuid.
getPriorityTypeListlinkGet a list of available priority types.
getPriorityTypepriorityTypeUuidlinkGet a priority type by uuid.
getCommandTypeListlinkGet a list of available command types.
getCommandTypecommandTypeUuidlinkGet a command type by uuid.
getCommandFieldListlinkGet a list of available command fields.
getCommandFieldcommandFieldUuidlinkGet a command field by uuid.
getEventTypeListlinkGet a list of available event types.
getEventTypeeventTypeUuidlinkGet an event type by uuid.
getEventListlinkGet a list of events.
getEventeventUuidlinkGet an event by uuid.
getGroupingTypeListlinkGet a list of available grouping types.
getGroupingTypegroupingTypeUuidlinkGet a grouping type by uuid.
getTeamListlinkGet a list of available teams.
getTeamteamUuidlinkGet a team by uuid.
getGroupinggroupingUuidlinkGet a grouping by uuid.
getChildGroupingListgroupingUuidlinkGet a list of child groupings for a grouping.
getDeviceListForGroupinggroupingUuidlinkGet a list of devices for a grouping.
getNetworkListlinkGet a list of networks.
getNetworknetworkUuidlinkGet a network by uuid.
getNetworkDeviceListnetworkUuidlinkGet a network's devices.
getNetworkGroupingListnetworkUuidlinkGet a network's groupings.
getNetworkGroupingnetworkUuid,groupingUuidlinkGet a network's grouping by uuid.
getNetworkLocationListnetworkUuidlinkGet a network's locations.
getNetworkLocationnetworkUuid,networkLocationUuidlinkGet a network location by uuid.
getNetworkScheduleListnetworkUuidlinkGet a list of a network's schedules.
getNetworkSchedulenetworkUuid,scheduleUuidlinkGet a schedule by uuid.
getSchedulescheduleUuidlinkGet a schedule by uuid.
getGroupingDeviceListlinkGet a list of GroupingDevice links.
getGroupingDevicegroupingDeviceUuidlinkGet a GroupingDevice link by uuid.
getGroupingLinkListlinkGet a list of GroupingLinks.
getGroupingLinkgroupingLinkUuidlinkGet a GroupingLink by uuid.
getWebhookActionListlinkGet a list of webhook actions.
getWebhookActionwebhookActionUuidlinkGet a webhook action by uuid.
getWebhookActionTypeListlinkGet a list of webhook action types.
getWebhookActionTypewebhookActionTypeUuidlinkGet a webhook action type by uuid.

更新资源

iotery.io python sdk中更新资源的通用语法如下:

iotery.methodName(inputParameter="parameter",data={"data":"variables"})

例如,要更新设备类型,javascript看起来像

updateDeviceType(deviceTypeUuid="a-valid-device-type-uuid",data={"name":"My New Name"})

其中updateDevice映射到methodNamedeviceTypeUuid映射到inputParameter{ "name": "My New Name" }映射到上述广义形式的指令{data : "variables"}

可用的更新方法是

^{}^{}link^{}
updateAccountManageruserUuidlinkUpdate an account manager by uuid.
updateConsumerconsumerUuidlinkUpdate a consumer by uuid.
updateDeviceTypedeviceTypeUuidlinkUpdate a device type by uuid.
updateSettingTypesettingTypeUuidlinkUpdate a setting type by uuid.
updateDefaultSettingdefaultSettingUuidlinkUpdate a default setting by uuid.
updateDataTypedataTypeUuidlinkUpdate a data type by uuid.
updateDevicedeviceUuidlinkUpdate a device by uuid.
updateNotificationInstancenotificationInstanceUuidlinkUpdate a notification instance.
updateSettingsettingUuidlinkUpdate a setting.
updateFirmwareRecordfirmwareUuidlinkUpdate a firmware record by uuid.
updateSeverityTypeseverityTypeUuidlinkUpdate a severity type by uuid.
updateNotificationTypenotificationTypeUuidlinkUpdate a notification type by uuid.
updateNotificationFieldnotificationFieldUuidlinkUpdate a notification field by uuid.
updatePriorityTypepriorityTypeUuidlinkUpdate a priority type by uuid.
updateCommandTypecommandTypeUuidlinkUpdate a command type by uuid.
updateCommandFieldcommandFieldUuidlinkUpdate a command field by uuid.
updateEventTypeeventTypeUuidlinkUpdate an event type by uuid.
updateEventeventUuidlinkUpdate an event by uuid.
updateGroupingTypegroupingTypeUuidlinkUpdate a grouping type by uuid.
updateTeamteamUuidlinkUpdate a team by uuid.
updateGroupinggroupingUuidlinkUpdate a grouping.
updateNetworkLocationnetworkLocationUuidlinkUpdate a network location by uuid.
updateNetworknetworkUuidlinkUpdate a network by uuid.
updateNetworkGroupingnetworkUuid,groupingUuidlinkUpdate a network grouping.
updateNetworkNetworkLocationnetworkUuid,networkLocationUuidlinkUpdate a network location.
updateNetworkSchedulenetworkUuid,scheduleUuidlinkUpdate a schedule.
updateSchedulescheduleUuidlinkUpdate a schedule.
updateGroupingDevicegroupingDeviceUuidlinkUpdate a GroupingDevice link by uuid.
updateGroupingLinkgroupingLinkUuidlinkUpdate a GroupingLink by uuid.
updateWebhookActionwebhookActionUuidlinkUpdate a webhook action by uuid.

删除资源

iotery.io python sdk中用于读取(获取)资源的通用语法如下:

iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})

例如,要通过设备的唯一标识符uuid获取设备,python看起来像

deleteDevice(deviceUuid="a-valid-device-uuid",opts={"some":"option"})

其中deleteDevice映射到methodNamedeviceUuid映射到inputParameter{ "some": "option" }映射到上述广义形式的指令{"query" : "parameters"}

可用的资源创建方法是

^{}^{}link^{}
deleteAccountManageruserUuidlinkDelete an account manager by uuid.
deleteConsumerconsumerUuidlinkDelete a consumer by uuid.
unlinkConsumerFromDeviceconsumerUuid,deviceUuidlinkUnlink a consumer from a device.
unlinkConsumerFromNetworkconsumerUuid,networkUuidlinkUnlink a consumer from a network.
deleteConsumerSecretListconsumerUuidlinkDelete all stored consumer secrets.
deleteDeviceTypedeviceTypeUuidlinkDelete a device type by uuid.
deleteSettingTypesettingTypeUuidlinkDelete a setting type by uuid.
deleteDefaultSettingdefaultSettingUuidlinkDelete a default setting by uuid.
deleteDataTypedataTypeUuidlinkDelete a data type by uuid.
deleteDevicedeviceUuidlinkDelete a device by uuid.
deleteNotificationInstancenotificationInstanceUuidlinkDelete a notification instance by uuid.
deleteSettingsettingUuidlinkDelete a setting by uuid.
deleteFirmwareRecordfirmwareUuidlinkDelete a firmware record by uuid.
deleteSeverityTypeseverityTypeUuidlinkDelete a severity type by uuid.
deleteNotificationTypenotificationTypeUuidlinkDelete a notification type by uuid.
deleteNotificationFieldnotificationFieldUuidlinkDelete a notification field by uuid.
deletePriorityTypepriorityTypeUuidlinkDelete a priority type by uuid.
deleteCommandTypecommandTypeUuidlinkDelete a command type by uuid.
deleteCommandFieldcommandFieldUuidlinkDelete a command field by uuid.
deleteEventTypeeventTypeUuidlinkDelete an event type by uuid.
deleteEventeventUuidlinkDelete an event by uuid.
deleteGroupingTypegroupingTypeUuidlinkDelete a grouping type by uuid.
deleteTeamteamUuidlinkDelete a team by uuid.
unlinkAccountManagerFromTeamuserUuidlinkUnlink account manager from a team.
deleteGroupinggroupingUuidlinkDelete a grouping by uuid.
deleteNetworknetworkUuidlinkDelete a network by uuid.
deleteNetworkGroupingnetworkUuid,groupingUuidlinkDelete a network's grouping by uuid.
removeDeviceFromGroupingnetworkUuid,groupingUuid,deviceUuidlinkremove a device from a grouping
deleteNetworkLocationnetworkUuid,networkLocationUuidlinkDelete a network location by uuid.
deleteNetworkSchedulenetworkUuid,scheduleUuidlinkDelete a schedule by uuid.
deleteSchedulescheduleUuidlinkDelete a schedule by uuid.
deleteGroupingDevicegroupingDeviceUuidlinkDelete a GroupingDevice link by uuid.
deleteGroupingLinkgroupingLinkUuidlinkDelete a GroupingLink by uuid.
deleteWebhookActionwebhookActionUuidlinkDelete a webhook action type by uuid.

简单的数据获取示例

from iotery_python_server_sdk import Iotery
import json

API_KEY = "MY_TEAM_API_KEY"

DEVICE_UUID = "MY_DEVICE_UUID"
DATA_TYPE_ENUM = "MY_DATA_TYPE_ENUM"

iotery = Iotery(API_KEY)

device_data_list = iotery.getDeviceDataList(
    opts={"dataTypeEnum": DATA_TYPE_ENUM, "limit": 5}, deviceUuid=DEVICE_UUID)

print(json.dumps(device_data_list["results"], indent=2))

贡献

我们欢迎投稿人和公关!如果你感兴趣,请告诉我们。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javascript点击文本(文本链接到web url)如何打开   java将一个按钮替换为另一个按钮   J2ME上的java音频,我不知道哪里出了问题?   java异常仅在调试+断点中引发   图形按钮文本在4Gb Ram和IBM Java 1.5中消失   java如何在输入错误的用户名和/或密码时将用户从登录控件重定向到错误页面?   java对象的计算时代有什么好处?   加密限制了应用程序功能的启动   swing只有在我移动鼠标时才会显示组件。帮助(爪哇)   使用Spring进行java密码加密/解密   Java8Java。时间:如何更改一周中的某一天和一天的开始时间?   java Android:设置文本视图中来自另一个活动的文本不起作用   如何在java中创建ActionEvent类的对象?   java Tomcat 7和无效的密钥库格式   GWT面板类型的java问题   字符输入java中的异常   带有文件输出的java JOptionPane   java Kotlin泛型声明站点方差<在T>构造中   java是非对话框,带进度