def refreshAuthToken(self, arInDTO): arInDTO = DictUtil.dto2dict(arInDTO) authUrl = RestConstant.REFRESH_TOKEN payload = json.dumps(arInDTO) logging.info(arInDTO), logging.info(payload) return NorthApiClient.invokeAPI(RestConstant.HTTPPOST, authUrl, payload, None)
def clientInfo(self): clientInfo = ClientInfo() clientInfo.setPlatformIp((Constant().readConfFile())[0]) clientInfo.setPlatformPort((Constant().readConfFile())[1]) clientInfo.setAppId((Constant().readConfFile())[2]) clientInfo.setSecret((Constant().readConfFile())[3]) clientInfo = DictUtil.dto2dict(clientInfo) return clientInfo
def deleteBatchSubscriptions(self, dbsInDTO, accessToken): dbsInDTO = DictUtil.dto2dict(dbsInDTO) authUrl = RestConstant.DELETE_BATCH_SUB_SCRIPTIONS for key in dbsInDTO.keys(): if dbsInDTO[key] != None: authUrl += "&" + key + "=" + dbsInDTO[key] logging.info(dbsInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPDELETE, authUrl, None, accessToken)
def queryBatchSubscriptions(self, qbsInDTO, accessToken): qbsInDTO = DictUtil.dto2dict(qbsInDTO) authUrl = RestConstant.QUERY_BATCH_SUB_SCRIPTIONS for key in qbsInDTO.keys(): if qbsInDTO[key] != None: authUrl += "&" + key + "=" + qbsInDTO[key] logging.info(qbsInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPGET, authUrl, None, accessToken)
def subDeviceBusinessData(self, sdbdInDTO, accessToken): sdbdInDTO = DictUtil.dto2dict(sdbdInDTO) authUrl = RestConstant.SUB_DEVICE_BUSINESS_DATA if sdbdInDTO['ownerFlag'] != None: authUrl += "?ownerFlag=" + sdbdInDTO['ownerFlag'] payload = json.dumps(sdbdInDTO) logging.info(sdbdInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPOST, authUrl, payload, accessToken)
def queryBatchDevicesInfo(self, qbdiInDTO, accessToken): qbdiInDTO = DictUtil.dto2dict(qbdiInDTO) authUrl = RestConstant.QUERY_BATCH_DEVICES_INFO for key in qbdiInDTO.keys(): if qbdiInDTO[key] != None: authUrl += "&" + key + "=" + qbdiInDTO[key] logging.info(qbdiInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPGET, authUrl, None, accessToken)
def queryDeviceDataHistory(self, qddhInDTO, accessToken): authUrl = "/iocm/app/data/v1.2.0/deviceDataHistory" payload = DictUtil.dto2dict(qddhInDTO) logging.info(qddhInDTO), logging.info(accessToken), logging.info( payload) return NorthApiClient.invokeAPI(RestConstant.HTTPGET, authUrl, payload, accessToken)
def postDeviceCommand(self, pdcInDTO, appId, accessToken): pdcInDTO = DictUtil.dto2dict(pdcInDTO) authUrl = RestConstant.POST_DEVICE_COMMAND if appId != None: authUrl += "?appId=" + appId payload = json.dumps(pdcInDTO) logging.info(pdcInDTO), logging.info(appId), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPOST, authUrl, payload, accessToken)
def refreshDeviceKey(self, rdkInDTO, appId, accessToken): rdkInDTO = DictUtil.dto2dict(rdkInDTO) authUrl = RestConstant.REFRESH_DEVICE_KEY + rdkInDTO['deviceId'] if appId != None: authUrl += "?appId=" + appId payload = json.dumps(rdkInDTO) logging.info(rdkInDTO), logging.info(appId), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPUT, authUrl, payload, accessToken)
def queryDeviceRealtimeLocation(self, qdrlInDTO, appId, accessToken): qdrlInDTO = DictUtil.dto2dict(qdrlInDTO) authUrl = RestConstant.QUERY_DEVICE_REALTIME_LOCATION if appId != None: authUrl += "?appId=" + appId payload = json.dumps(qdrlInDTO) logging.info(qdrlInDTO), logging.info(appId), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPOST, authUrl, payload, accessToken)
def queryDeviceCmdCancelTask(self, qdcctInDTO, accessToken): qdcctInDTO = DictUtil.dto2dict(qdcctInDTO) authUrl = RestConstant.QUERY_DEVICE_CMD_CANCEL_TASK for key in qdcctInDTO.keys(): if qdcctInDTO[key] != None: authUrl += "&" + key + "=" + qdcctInDTO[key] logging.info(qdcctInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPGET, authUrl, None, accessToken)
def regDirectDevice(self, rddInDto, appId, accessToken): rddInDto = DictUtil.dto2dict(rddInDto) authUrl = RestConstant.REG_DIRECT_DEVICE if appId != None: authUrl += "?appId=" + appId payload = json.dumps(rddInDto) logging.info(rddInDto), logging.info(appId), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPOST, authUrl, payload, accessToken)
def queryDeviceCommand(self, qdcInDTO, accessToken): qdcInDTO = DictUtil.dto2dict(qdcInDTO) authUrl = RestConstant.QUERY_DEVICE_COMMAND for key in qdcInDTO.keys(): if qdcInDTO[key] != None: authUrl += "&" + key + "=" + qdcInDTO[key] logging.info(qdcInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPGET, authUrl, None, accessToken)
def modifyDeviceShadow(self, mdsInDTO, deviceId, appId, accessToken): mdsInDTO = DictUtil.dto2dict(mdsInDTO) authUrl = RestConstant.MODIFY_DEVICE_SHADOW + deviceId if appId != None: authUrl += "?appId=" + appId payload = json.dumps(mdsInDTO) logging.info(mdsInDTO), logging.info(deviceId), logging.info( appId), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPUT, authUrl, payload, accessToken)
def createDeviceCmdCancelTask(self, cdcctInDTO, appId, accessToken): cdcctInDTO = DictUtil.dto2dict(cdcctInDTO) authUrl = RestConstant.CREATE_DEVICE_CMD_CANCEL_TASK if appId != None: authUrl += "?appId=" + appId payload = json.dumps(cdcctInDTO) logging.info(cdcctInDTO), logging.info(appId), logging.info( accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPOST, authUrl, payload, accessToken)
def queryDeviceDesiredHistory(self, qddhInDTO, accessToken): qddhInDTO = DictUtil.dto2dict(qddhInDTO) authUrl = RestConstant.QUERY_DEVICE_DESIRED_HISTORY + qddhInDTO[ 'deviceId'] + "&gatewayId=" + qddhInDTO['gatewayId'] for key in qddhInDTO.keys(): if qddhInDTO[key] != None: authUrl += "&" + key + "=" + qddhInDTO[key] logging.info(qddhInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPGET, authUrl, None, accessToken)
def updateDeviceCommand(self, udcInDTO, deviceCommandId, appId, accessToken): udcInDTO = DictUtil.dto2dict(udcInDTO) authUrl = RestConstant.UPDATE_DEVICE_COMMAND + deviceCommandId if appId != None: authUrl += "?appId=" + appId payload = json.dumps(udcInDTO) logging.info(udcInDTO), logging.info(deviceCommandId), logging.info( appId), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPUT, authUrl, payload, accessToken)
def subDeviceManagementData(self, sdmdInDTO, accessToken): sdmdInDTO = DictUtil.dto2dict(sdmdInDTO) authUrl = RestConstant.SUB_DEVICE_MANAGEMENT_DATA payload = json.dumps(sdmdInDTO) logging.info(sdmdInDTO), logging.info(accessToken) return NorthApiClient.invokeAPI(RestConstant.HTTPPOST, authUrl, payload, accessToken)