你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Sensors - Create Or Update

创建传感器实体。

PATCH {endpoint}/sensor-partners/{sensorPartnerId}/sensors/{sensorId}?api-version=2023-11-01-preview

URI 参数

名称 必需 类型 说明
endpoint
path True

string (uri)

命名空间的主机名,例如 admaInstanceName.farmbeats.azure.net

sensorId
path True

string

传感器资源的 ID。

sensorPartnerId
path True

string

传感器合作伙伴的 ID。

api-version
query True

string

请求的 API 版本

请求头

Media Types: "application/merge-patch+json"

名称 必需 类型 说明
Authorization True

string

请为授权的 API 调用提供有效的持有者令牌。 请注意,如果之前尝试了未经身份验证的调用,可能需要清除浏览器缓存。

请求正文

Media Types: "application/merge-patch+json"

名称 类型 说明
depthInMeters

number[] (double)

每个传感器度量值的深度(以米为单位)。 像传感器湿度在2米,4米,6米。

description

string

minLength: 0
maxLength: 500

资源的文本说明。

deviceId

string

关联的设备的 ID。

hardwareId

string

关联的硬件的 ID。

integrationId

string

设备的集成 ID。

location

Location

位置模型类。

name

string

minLength: 0
maxLength: 100

用于标识资源的名称。

port

Port

用于存储端口值的架构。

properties

属于资源的键值对的集合。 每对不能具有大于 50 个字符的键,并且不能具有大于 150 个字符的值。 注意:最多可以为资源提供 25 个键值对,仅支持字符串、数字和日期/时间(yyyy-MM-ddTHH:mm:ssZ) 值。

sensorDataModelId

string

关联的传感器数据模型的 ID。

status

string

minLength: 0
maxLength: 100

资源的状态。

type

string

minLength: 0
maxLength: 100

传感器的类型。

响应

名称 类型 说明
200 OK

Sensor

成功

201 Created

Sensor

创建

Other Status Codes

ErrorResponse

错误

标头

x-ms-error-code: string

安全性

Authorization

请为授权的 API 调用提供有效的持有者令牌。 请注意,如果之前尝试了未经身份验证的调用,可能需要清除浏览器缓存。

类型: apiKey
在: header

示例

Sensors_CreateOrUpdate

示例请求

PATCH {endpoint}/sensor-partners/sp1/sensors/s124?api-version=2023-11-01-preview

{
  "sensorDataModelId": "sdm124",
  "integrationId": "string",
  "hardwareId": "SMHD 456",
  "deviceId": "d124",
  "type": "SM",
  "location": {
    "latitude": 23.5,
    "longitude": 42.7
  },
  "port": {
    "name": "measure",
    "type": "digital"
  },
  "status": "sm created",
  "name": "my new sm",
  "description": "description for sensor goes here",
  "properties": {
    "key1": "value1",
    "key2": 123.45
  }
}

示例响应

{
  "sensorDataModelId": "sdm124",
  "integrationId": "string",
  "hardwareId": "SMHD-456",
  "deviceId": "d124",
  "type": "SM",
  "location": {
    "latitude": 23.5,
    "longitude": 42.7
  },
  "port": {
    "name": "measure",
    "type": "digital"
  },
  "sensorPartnerId": "sp1",
  "id": "s124",
  "status": "sm created",
  "createdDateTime": "2022-01-24T06:27:05Z",
  "modifiedDateTime": "2022-01-24T06:27:05Z",
  "eTag": "040139eb-0000-0700-0000-61ee46b90000",
  "name": "my new sm",
  "description": "description for sensor goes here",
  "properties": {
    "key1": "value1",
    "key2": 123.45
  }
}
{
  "sensorDataModelId": "sdm124",
  "integrationId": "string",
  "hardwareId": "SMHD-456",
  "deviceId": "d124",
  "type": "SM",
  "location": {
    "latitude": 23.5,
    "longitude": 42.7
  },
  "port": {
    "name": "measure",
    "type": "digital"
  },
  "sensorPartnerId": "sp1",
  "id": "s124",
  "status": "sm created",
  "createdDateTime": "2022-01-24T06:27:05Z",
  "modifiedDateTime": "2022-01-24T06:27:05Z",
  "eTag": "040139eb-0000-0700-0000-61ee46b90000",
  "name": "my new sm",
  "description": "description for sensor goes here",
  "properties": {
    "key1": "value1",
    "key2": 123.45
  }
}

定义

名称 说明
Error

Azure AgPlatform 服务中的错误。

ErrorResponse

Azure AgPlatform 服务的错误响应。 请参阅 errorResponse 参考文档 https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

InnerError

包含错误列表的内部错误。请参阅 innerError 参考文档 https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#innererror--object

Location

位置模型类。

Port

用于存储端口值的架构。

Sensor

传感器 API 模型。

Error

Azure AgPlatform 服务中的错误。

名称 类型 说明
code

string

minLength: 1

服务器定义的错误代码集。

details

Error[]

导致此报告错误的特定错误的详细信息数组。

innererror

InnerError

包含错误列表的内部错误。请参阅 innerError 参考文档 https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#innererror--object

message

string

minLength: 1

错误的人工可读表示形式。

target

string

错误的目标。

ErrorResponse

Azure AgPlatform 服务的错误响应。 请参阅 errorResponse 参考文档 https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses

名称 类型 说明
error

Error

Azure AgPlatform 服务中的错误。

traceId

string

唯一跟踪 ID。

InnerError

包含错误列表的内部错误。请参阅 innerError 参考文档 https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#innererror--object

名称 类型 说明
code

string

包含的错误提供的特定错误代码。

innererror

InnerError

包含错误列表的内部错误。请参阅 innerError 参考文档 https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#innererror--object

Location

位置模型类。

名称 类型 说明
latitude

number (double)

minimum: -90
maximum: 90

位置的纬度。

longitude

number (double)

minimum: -180
maximum: 180

位置的经度。

Port

用于存储端口值的架构。

名称 类型 说明
name

string

minLength: 1
maxLength: 50

端口的名称。

type

string

minLength: 0
maxLength: 100

端口数字/模拟的类型。

Sensor

传感器 API 模型。

名称 类型 说明
createdBy

string

由用户/租户 ID 创建。

createdDateTime

string (date-time)

创建资源的日期时间,示例格式:yyyy-MM-ddTHH:mm:ssZ。

depthInMeters

number[] (double)

每个传感器度量值的深度(以米为单位)。 像传感器湿度在2米,4米,6米。

description

string

minLength: 0
maxLength: 500

资源的文本说明。

deviceId

string

关联的设备的 ID。

eTag

string

实现乐观并发的 ETag 值。

hardwareId

string

关联的硬件的 ID。

id

string

资源的 ID。

integrationId

string

设备的集成 ID。

location

Location

位置模型类。

modifiedBy

string

由用户/租户 ID 修改。

modifiedDateTime

string (date-time)

上次修改资源的日期时间,示例格式:yyyy-MM-ddTHH:mm:ssZ。

name

string

minLength: 0
maxLength: 100

用于标识资源的名称。

port

Port

用于存储端口值的架构。

properties

属于资源的键值对的集合。 每对不能具有大于 50 个字符的键,并且不能具有大于 150 个字符的值。 注意:最多可以为资源提供 25 个键值对,仅支持字符串、数字和日期/时间(yyyy-MM-ddTHH:mm:ssZ) 值。

sensorDataModelId

string

关联的传感器数据模型的 ID。

sensorPartnerId

string

关联的传感器合作伙伴的 ID。

status

string

minLength: 0
maxLength: 100

资源的状态。

type

string

minLength: 0
maxLength: 100

传感器的类型。