Skip to content

设备转移

设备转移功能允许将设备从当前组织转移到另一个组织,是跨组织管理设备的重要功能。

设备转移

http
POST /api/v2/devices/{device_id}/transfer/

接口说明

将设备从当前组织转移到另一个组织。转移后:

  • 设备在新组织中,需重新分配至设备组
  • 设备的绑定时间 bind_time 会重置

请求参数

参数类型必填说明
target_org_slugstring目标组织的slug

请求示例

请求数据

json
{
    "target_org_slug": "target_organization_slug"
}

响应

返回数据 (200 OK)

json
{
    "detail": "设备已成功转移到目标组织"
}

代码示例

Python
python
def transfer_device(device_id, target_org_slug):
    """设备转移
    
    Args:
        device_id: 设备ID
        target_org_slug: 目标组织的slug
    """
    headers = {
        "Authorization": f"Bearer {ACCESS_TOKEN}",
        "Content-Type": "application/json"
    }
    
    data = {
        "target_org_slug": target_org_slug
    }
    
    url = f"{API_BASE}/devices/{device_id}/transfer/"
    response = requests.post(url, headers=headers, json=data)
    return response.json()

# 使用示例
device_id = "device_1"
target_org_slug = "target_organization_slug"
result = transfer_device(device_id, target_org_slug)
print(f"迁移结果: {result}")
cURL
bash
curl -X POST "https://ums.holdingbyte.com/api/v2/devices/device_1/transfer/" \
     -H "Authorization: Bearer your_access_token" \
     -H "Content-Type: application/json" \
     -d '{"target_org_slug": "target_organization_slug"}'

错误响应

错误响应

设备转移API可能返回的错误响应遵循统一的格式。有关详细的错误码和处理方法,请参阅API错误响应文档。

常见错误

错误码说明
400无效的请求数据
401未认证
403没有权限执行此操作
404设备或目标组织不存在