Search OTA Job


搜索 OTA job 信息。

操作权限

需授权的资源

所需操作权限

设备管理

Read

请求格式

POST https://{apigw-address}/connect-service/v2.1/ota-jobs?action=search

请求参数(URI)

名称

位置(Path/Query)

必需/可选

数据类型

描述

orgId

Query

必需

String

资产所属的组织 ID。如何获取 orgId 信息>>

请求参数(Body)

名称

必需/可选

数据类型

描述

expression

可选

String

查询表达式,支持类 SQL 的查询。查询的字段和对应的运算符清单如下。

  • productKeyfirmwareIdfirmwareVersion:= 和 in。

  • typestatus:=

  • firmwareName 支持指定语言模糊查询:

    • firmwareName like 'xxx':模糊查询 default、中文和英文名称。

    • firmwareName.defaultValue like 'xxx':模糊查询默认名称。

pagination

可选

Pagination 请求结构体

分页参数。如未指定,默认每页 10 条。每页最大记录数为 200 条,但为获得最佳性能,建议每页不超过 50 条。不支持使用 sorters 参数对结果进行排序,查询结果按照 createTime,最近创建的靠前排列。详见 Pagination 请求结构体>>

响应参数

名称

数据类型

描述

data

JobInfo 结构体数组

查询到的 OTA job 详情。其结构体参见 JobInfo 结构体

错误码

有关错误码的描述,参见 通用错误码

示例

请求示例

url: https://{apigw-address}/connect-service/v2.1/ota-jobs?action=search&orgId=yourOrgId
method: POST
requestBody:
{
    "expression":"productKey='yourProductKey'",
    "pagination":{
        "pageNo":1,
        "pageSize":5
    }
}

返回示例

{
    "code":0,
    "msg":"OK",
    "requestId":"99344e67-c79b-46bd-91d1-3ce3503ae769",
    "data":[
        {
            "orgId":"o15475466766371",
            "productKey":"BXwU4kMk",
            "jobId":"5ed758ca49f032b4663063aa",
            "name":{
                "defaultValue":"name",
                "i18nValue":{

                }
            },
            "firmwareId":"5ed0dd4a646542001b3d113f",
            "type":"upgrade",
            "enableUpgradeRequest":true,
            "upgradePolicy":null,
            "upgradeScope":{
                "type":"total",
                "versionNumbers":[
                    "1.0"
                ],
                "deviceKeys":null,
                "attributes":null,
                "tags":null,
                "assetTrees":null
            },
            "upgradeTimeout":7200,
            "startSchedule":0,
            "endSchedule":86399,
            "status":"started",
            "createTime":1591171274788,
            "startAfterCreate":true
        },
        {
            "orgId":"o15475466766371",
            "productKey":"BXwU4kMk",
            "jobId":"5ed0e177646542001b3d114d",
            "name":null,
            "firmwareId":"5ed0dd4a646542001b3d113f",
            "type":"verify",
            "enableUpgradeRequest":true,
            "upgradePolicy":null,
            "upgradeScope":{
                "type":"partial",
                "versionNumbers":[
                    "1.0"
                ],
                "deviceKeys":[
                    "ota-device1"
                ],
                "attributes":null,
                "tags":null,
                "assetTrees":null
            },
            "startSchedule":0,
            "endSchedule":86399,
            "status":"stopped",
            "createTime":1590747511198,
            "startAfterCreate":null
        },
        {
            "orgId":"o15475466766371",
            "productKey":"BXwU4kMk",
            "jobId":"5ed0de47646542001b3d1145",
            "name":null,
            "firmwareId":"5ed0dd4a646542001b3d113f",
            "type":"verify",
            "enableUpgradeRequest":true,
            "upgradePolicy":null,
            "upgradeScope":{
                "type":"partial",
                "versionNumbers":[
                    "1.0"
                ],
                "deviceKeys":[
                    "ota-device1"
                ],
                "attributes":null,
                "tags":null,
                "assetTrees":null
            },
            "startSchedule":0,
            "endSchedule":86399,
            "status":"stopped",
            "createTime":1590746695872,
            "startAfterCreate":null
        },
        {
            "orgId":"o15475466766371",
            "productKey":"BXwU4kMk",
            "jobId":"5ed0dd8c646542001b3d1140",
            "name":null,
            "firmwareId":"5ed0dd4a646542001b3d113f",
            "type":"verify",
            "enableUpgradeRequest":true,
            "upgradePolicy":null,
            "upgradeScope":{
                "type":"partial",
                "versionNumbers":[
                    "1.0"
                ],
                "deviceKeys":[
                    "ota-device1"
                ],
                "attributes":null,
                "tags":null,
                "assetTrees":null
            },
            "upgradeTimeout":7200,
            "startSchedule":0,
            "endSchedule":86399,
            "status":"stopped",
            "createTime":1590746508060,
            "startAfterCreate":null
        }
    ],
    "pagination":{
        "sortedBy":null,
        "pageNo":1,
        "pageSize":5,
        "totalSize":4
    }
}

Java SDK 调用示例

package com.envisioniot.enos.connect_service.ota.job;

import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.api.common.constant.request.Pagination;
import com.envisioniot.enos.connect_service.v2_1.ota.job.SearchJobRequest;
import com.envisioniot.enos.connect_service.v2_1.ota.job.SearchJobResponse;

public class SearchJob {
    public static void main(String[] args) {
        final String appKey = "yourAppKey";
        final String appSecret = "yourAppSecret";
        String serverUrl = "yourServerUrl";

        String orgId = "yourOrgId";

        SearchJobRequest request = new SearchJobRequest();
        request.setOrgId(orgId);

        request.setExpression("firmwareId='yourFirmwareId'");

        Pagination pagination = new Pagination();
        pagination.setPageNo(1);
        pagination.setPageSize(5);

        request.setPagination(pagination);

        SearchJobResponse response = Poseidon
                .config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                .url(serverUrl)
                .getResponse(request, SearchJobResponse.class);
    }
}