平台负责人

POST /core/v1/admin/users/{id}/role

平台负责人授予或撤销管理员角色;撤销目标会话

身份要求

平台负责人. 会话/管理写操作不在公共 Playground 执行。

接口

curl --request POST 'https://api.oneaster.ai/core/v1/admin/users/1/role' \
  --header 'Authorization: Bearer '"$ONEASTER_SESSION_TOKEN" \
  --header 'Idempotency-Key: '"$ONEASTER_INTENT" \
  --header 'Content-Type: application/json' \
  --data "$REQUEST_BODY_JSON"

参数

- id (path, 必填): {"type":"string","pattern":"^[0-9]+$"}

- Idempotency-Key (header, 必填): {"type":"string","minLength":1,"maxLength":100}

请求 JSON Schema

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "expected_version": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2147483646
    },
    "current_password": {
      "type": "string",
      "maxLength": 128,
      "writeOnly": true
    },
    "reference": {
      "type": "string",
      "minLength": 1,
      "maxLength": 300
    },
    "admin": {
      "type": "boolean"
    }
  },
  "required": [
    "expected_version",
    "current_password",
    "reference",
    "admin"
  ]
}

响应

200

平台负责人授予或撤销管理员角色;撤销目标会话

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "version": {
              "type": "integer",
              "minimum": 1
            },
            "reused": {
              "type": "boolean"
            }
          },
          "required": [
            "version",
            "reused"
          ]
        }
      },
      "required": [
        "success",
        "data"
      ]
    }
  }
}

default

错误代码见 core-api.md;供应商/数据库错误已隐藏。

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": false
        },
        "error": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "type": {
              "const": "oneaster_error"
            }
          },
          "required": [
            "code",
            "message",
            "type"
          ]
        },
        "data": {
          "type": "null"
        }
      },
      "required": [
        "success",
        "error",
        "data"
      ]
    }
  }
}