文档

CreateDataAPIService

更新时间:

调用该接口创建数据算法服务API。

QPS限制

单个阿里云账号调用该接口的每秒请求数(QPS)最大限制为1。

说明 RAM用户共享阿里云账号配额。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String CreateDataAPIService

系统规定参数。取值:CreateDataAPIService。

ApiPath String device/getDeviceCountByStatus

API调用地址的自定义部分。作为API资源标识符,需具有全局唯一性。

说明 API调用地址的前一段部分由系统生成。
DisplayName String 查询设备总数

API的显示名称,需具有全局唯一性。仅支持中文汉字、英文字母、数字、下划线(_)、连接符(-)、英文圆括号和空格,长度不超过20个字符。

OriginSql String SELECT COUNT(iot_id) AS deviceCount FROM ${system.device} WHERE status=1

API对应的原始SQL,指定数据开发的SQL样式。

例如select count(*) as deviceCount from ${system.device} where status = 1。其中,${system.device}是平台系统的设备表,具体请参见数据表中的表说明。

TemplateSql String SELECT COUNT(iot_id) AS deviceCount FROM ${system.device} WHERE status=${status}

服务的模板SQL,即原始SQL的模板化。

例如select count(*) as deviceCount from ${system.device} where status = ${status}。其中,${status}是模板化的参数。支持设置模板参数为动态值。

RequestParam.N.Name String status

请求参数名称。

例如,${status}格式的模板参数,参数名称就是status

RequestParam.N.Type String VARCHAR

请求参数类型,请参见JDBCType

目前仅支持:

  • ARRAY
  • VARCHAR
  • INTEGER
  • BIGINT
  • BOOLEAN
  • DECIMAL
  • TIMESTAMP
RequestParam.N.Desc String 设备状态

请求参数的描述。

RequestParam.N.Example String dksiaiek23s

请求参数值示例。

RequestParam.N.Required Boolean true

该请求参数是否必填。

  • true(默认):必填。
  • false:非必填。
Desc String 数据分析API

API的描述。

ResponseParam.N.Name String deviceCount

返回参数名称。

ResponseParam.N.Type String INTEGER

返回参数类型,请参见JDBCType

目前仅支持:

  • VARCHAR
  • INTEGER
  • BIGINT
  • BOOLEAN
  • DECIMAL
  • TIMESTAMP
ResponseParam.N.Desc String 设备总数

返回参数描述。

ResponseParam.N.Example String 100

返回参数值示例。

ResponseParam.N.Required Boolean true

该返回参数是否必须返回。

  • true:必须返回。
  • false:非必须返回。
说明 返回参数中,此参数无需处理。
IotInstanceId String iot_instc_pu****_c*-v64********

实例ID。您可在物联网平台控制台的实例概览页面,查看当前实例的ID

重要
  • 若有ID值,必须传入该ID值,否则调用会失败。
  • 若无实例概览页面或ID值,则无需传入。

实例的更多信息,请参见实例概述

调用API时,除了本文介绍的该API的特有请求参数,还需传入公共请求参数。公共请求参数说明,请参见公共参数文档

返回数据

名称 类型 示例值 描述
Code String Success

调用失败时,返回的错误码。更多信息,请参见错误码

Data Struct

调用成功时,返回创建的API信息。

ApiSrn String acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2

API资源标识符,API的全局唯一标识。

示例:

acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2

以上示例中的信息说明如下:

  • 127103983461****是阿里云主账号ID。
  • /device/getDeviceCountByStatus是请求参数ApiPath的值,即API调用地址的自定义部分。
CreateTime Long 1557839468865

API的创建时间,单位为毫秒(ms)。

LastUpdateTime Long 1557839468865

API的最后更新时间,单位为毫秒(ms)。

ErrorMessage String 请求参数错误

调用失败时,返回的出错信息。

RequestId String 57b144cf-09fc-4916-a272-a62902d5b207

阿里云为该请求生成的唯一标识符。

Success Boolean true

是否调用成功。

  • true:调用成功。
  • false:调用失败。

示例

请求示例

http(s)://iot.cn-shanghai.aliyuncs.com/?Action=CreateDataAPIService
&ApiPath=device/getDeviceCountByStatus
&DisplayName=查询设备总数
&OriginSql=SELECT COUNT(iot_id) AS deviceCount FROM ${system.device} WHERE status=1
&RequestParam.1.Desc=设备状态
&RequestParam.1.Example=dksiaiek23s
&RequestParam.1.Name=status
&RequestParam.1.Required=true
&RequestParam.1.Type=VARCHAR
&ResponseParam.1.Desc=设备总数
&ResponseParam.1.Example=100
&ResponseParam.1.Name=deviceCount
&ResponseParam.1.Required=true
&ResponseParam.1.Type=INTEGER
&TemplateSql=SELECT COUNT(iot_id) AS deviceCount FROM ${system.device} WHERE status=${status}
&<公共请求参数>

正常返回示例

XML格式

<CreateDataAPIServiceResponse>
      <RequestId>57b144cf-09fc-4916-a272-a62902d5b207</RequestId>
      <Success>true</Success>
      <Data>
            <ApiSrn>acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2</ApiSrn>
            <CreateTime>1557839468865</CreateTime>
            <LastUpdateTime>1557839468865</LastUpdateTime>
      </Data>
</CreateDataAPIServiceResponse>

JSON格式

{
    "RequestId": "57b144cf-09fc-4916-a272-a62902d5b207", 
    "Success": true, 
    "Data": {
        "ApiSrn": "acs:iot:*:127103983461****:serveapi/device/getDeviceCountByStatus2", 
        "CreateTime": 1557839468865, 
        "LastUpdateTime": 1557839468865
    }
}
  • 本页导读 (1)
文档反馈