跳转至

统一目录拓扑查询



POST /api/v1/unified_catalog/topology/query

概述

从筛选起点展开目录实体拓扑,并按节点属性分组。

调用前和使用步骤

entityType/urn/providers/search/filters/orderBy作用于起点实体选择,展开后可能出现其他类型/来源节点,不是对所有返回节点再次过滤。relationTypes筛选关系种类;公开Body未声明maxDepth/nodeLimit,当前适配器使用默认最大深度10与节点限制200,不能提交这些未声明字段承诺放大结果。本结果不提供全工作空间完整图或总数保证。

groupByFields按顺序进行多层节点分组,entityType/entityStatus读顶层,其他读裸attributes键。数组属性可一节点多桶;组内data与递归groupByLayers、noGroupData都要遍历,不能把桶计数总和当唯一节点数。无分组时所有节点进入noGroupData,孤立节点也可能只在分组数据中出现。关系端点attributes完整返回,不附加实体详情的来源元数据/遥测/团队标签摘要。

所有实体类型都按有效健康配置处理,不依赖后台历史清理进度。system未配置类型策略默认default,其他类型未配置默认disabled;实体inherit继承类型、custom指定Func、disabled关闭。类型关闭后返回healthScore=null、healthStatus=unknown、healthUpdateAt=null,健康筛选/统计也按关闭态而非历史结果。筛选/排序/统计顶层健康字段必须明确entityType。

请求头

参数名 类型 必选 说明
DF-API-KEY string Y 工作空间的 OpenAPI 鉴权凭据。
例子: <DF-API-KEY>
获取或填写方式: 从目标工作空间的 API Key 管理获取有该操作权限的 OpenAPI Key。

Body 请求参数

参数名 类型 必选 说明
providers[*] string 数组内一个来源,省略父数组不筛选。
例子: manual
获取或填写方式: 单个已有实体provider值。
filters.属性字段名 string 动态键,推荐标量候选值数组;不能把任意DQL表达式当字段名。顶层内建字段如urn/provider/entityType和healthStatus及snake_case别名保持顶层,attributes/sourceMetadata/telemetrySelectors对象内键会展平。
例子: ["prod"]
获取或填写方式: 使用当前实体attributes真实字段名;复杂值筛选语义以已保存字段类型和查询服务能力为准。
filters.属性字段名[*] string 同字段一个候选值;数值/布尔保持原JSON类型,勿把null与字符串null混淆。
例子: prod
获取或填写方式: 从当前字段候选值/已有实体取值取得。
relationTypes[*] string links通常依赖,contains通常包含;不是实体类型/显示名。公开未枚举强校验,其他值按查询服务支持。
例子: contains
获取或填写方式: 已有关系类别标识。
groupByFields[*] string 空白项跳过;不是title/任意DQL。数组值只取非空标量去重;对象/嵌套数组不能作为组值。
例子: project
获取或填写方式: 裸属性键,如project/env,或entityType/entityStatus。
entityType string 可选的单个实体类型编码;省略或空字符串时不按类型限制。使用健康字段筛选或排序时必须明确单个类型。
允许 null: False
例子: database
获取或填写方式: 从实体类型列表items[].entityType获取编码,不是类型UUID/显示名。
urn string 可选起点实体URN,从实体列表取得;不传可按其他条件选起点。不是严格仅返回该节点,关系展开会包含相邻类型/来源节点。
允许 null: False
例子: urn:database:default:demo
获取或填写方式: 从本空间实体列表items[].urn取得,优先原样使用完整URN。
providers array 可选来源数组,非空时优先于provider;[]不加来源过滤,不是只选空来源。公开数组未逐项声明字符串校验,建议只用真实字符串。
允许 null: False
例子: ["manual"]
获取或填写方式: 从field_value/count对provider的候选分桶获取实际来源值。
relationTypes array 可选,省略/[]转发空列表由查询服务处理默认范围,不承诺只取一种关系;多个值作为关系类别集合,不改变关系方向。
允许 null: False
例子: ["links", "contains"]
获取或填写方式: 从已有关系relationType取值;本产品实体编辑生成links/contains。
orderBy string 可选,默认排序由查询服务按updatedAt处理;健康排序须entityType。类型关闭健康度时健康排序改用updatedAt desc,不按历史健康值排。
允许 null: False
例子: updatedAt
获取或填写方式: 从类型视图/字段接口选可排序字段,内建如updatedAt/name/healthScore,属性用attributes.env。
filters json 可选对象,{}无附加过滤;裸属性键env转为attributes.env,显式attributes.entityType不会当顶层entityType。多个同字段候选值放数组;不同字段交由查询服务组合。健康字段有单独有效关闭态,见用法。
允许 null: False
例子: {"env": ["prod"]}
获取或填写方式: 字段名来自类型DataSchema/属性或拓扑字段列表,值取字段统计/现有实体。
groupByFields array 可选,数组顺序决定多层分组;[]/省略所有返回节点进noGroupData。除entityType/entityStatus读顶层,其余按attributes原键读,不自动去attributes.前缀。数组属性可把同节点放多桶,缺值向后续层级尝试,全部缺值进入noGroupData。
允许 null: False
例子: ["project", "env"]
获取或填写方式: 从实体attributes已有字段名选择分组,内建支持entityType/entityStatus。
search string 拓扑query时搜索起点实体URN/name/display_name;filter_options中是候选值关键词的历史兼容参数,fieldValue非空时优先。两场景不要混淆。
允许 null: False
例子: demo
获取或填写方式: 调用方输入查询关键词。

参数补充说明

请求参数说明

参数名 type 必选 说明
entityType string 健康查询时必选 起点实体类型编码;filters/orderBy 涉及健康字段时必须唯一指定
urn string 否 聚焦实体 URN
providers array[string] 否 起点实体来源类型列表
relationTypes array[string] 否 需要返回的关系类型列表
orderBy string 否 起点实体排序字段;使用健康字段时必须传 entityType
filters json 否 起点实体过滤条件,支持 attributes 任意字段及顶层健康字段
groupByFields array[string] 否 拓扑实体节点分组字段列表
search string 否 起点实体搜索关键词

groupByFields 使用说明

  • 按数组顺序做多层级分组,例如:["project","env","serviceType"]。
  • entityType 从实体顶层字段读取,其他字段从实体 attributes 读取。
  • 分组基于拓扑结果中的实体节点,而不是关系边。
  • groupInfo.groupByLayers[].groupByData.*.data[] 和 groupInfo.noGroupData[] 返回 healthScore / healthStatus;healthScore 保留真实的 0 和 null。

调用注意事项

  • entityType、providers、search、urn、filters 只作用于起点实体确定。
  • filters 涉及 healthStatus/healthScore/healthUpdateAt/brokenComponents 及 snake_case 别名,或 orderBy 使用健康字段时,必须传 entityType;Studio 按有效关闭态过滤、排序,不直接信任 kodo 中待异步清理的历史健康值。
  • 返回结构固定为 items + groupInfo。
  • 平台内拓扑查询结果中,关系两端实体摘要的 attributes 为全量返回。
  • 关系两端和分组实体固定返回健康度开关与结果;所有类型始终按实体与类型有效配置计算,不依赖后台 readiness 清理进度。

请求例子

curl --request POST 'https://openapi.guance.com/api/v1/unified_catalog/topology/query' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"entityType":"service","filters":{"project":["demo"]},"relationTypes":["links","contains"],"groupByFields":["project"]}'

响应

HTTP 200,application/json。下方示例展示可直接读取的主要字段。

字段 类型 说明
content.items array<object> 拓扑关系边数组,无关系为[];不包含分页totalCount。
content.items[].id integer 或 string 或 null 按关系身份补查的记录标识,未匹配可null。
content.items[].workspaceUUID string 所属工作空间。
content.items[].sourceUrn string 来源节点URN。
content.items[].targetUrn string 目标节点URN。
content.items[].relationType string 关系类别,如links/contains。
content.items[].sourceUrnInfo object 关系端点摘要,未找到可{},attributes全量可用;不附加teamInfo/tagsInfo/遥测/来源大字段。
content.items[].sourceUrnInfo.id integer 或 string 或 null 底层实体记录标识,可能无值;客户定位使用urn。
content.items[].sourceUrnInfo.workspaceUUID string 鉴权工作空间UUID。
content.items[].sourceUrnInfo.urn string 实体规范URN,后续读取/修改/删除使用。
content.items[].sourceUrnInfo.entityType string 实体类型编码。
content.items[].sourceUrnInfo.provider string 采集/手工等实际来源,值由实体上报决定。
content.items[].sourceUrnInfo.name string 实体名称。
content.items[].sourceUrnInfo.displayName string 实体显示名;可空。
content.items[].sourceUrnInfo.attributes object 实体动态属性;本拓扑返回全部可用属性。
content.items[].sourceUrnInfo.attributes.字段名 JSON 对应类型DataSchema及上报实际字段;如env/project/owner/custom_tags/关系配置/健康覆盖字段,不固定每个实体都有。
content.items[].sourceUrnInfo.healthScore integer 或 null 有效健康分数,负值/无值归一null;关闭健康为null,不直接等于0。
content.items[].sourceUrnInfo.healthStatus string healthy/warning/critical/unknown;关闭健康为unknown。
content.items[].sourceUrnInfo.healthUpdateAt string 或 null 健康更新时间,通常YYYY-MM-DD HH:mm:ss;关闭/无值为null。
content.items[].sourceUrnInfo.createdAt string 或 null 创建时间,通常YYYY-MM-DD HH:mm:ss,按服务格式返回。
content.items[].sourceUrnInfo.updatedAt string 或 null 最后更新时间,同创建时间格式。
content.items[].sourceUrnInfo.healthConfig object 实体覆盖策略,不是类型策略拷贝。
content.items[].sourceUrnInfo.healthConfig.mode string inherit/func/disabled;历史仅func_id归一为func。
content.items[].sourceUrnInfo.healthConfig.funcId string 仅func模式出现的函数UUID。
content.items[].sourceUrnInfo.healthEnabled boolean 综合类型和实体配置的有效开关;类型disabled时实体custom也不能开启。
content.items[].sourceUrnInfo.entityStatus string online/offline,旧数据缺省online;状态不等于健康等级。
content.items[].sourceUrnInfo.lifecycleManaged boolean 是否受实体生命周期管理;缺省false。
content.items[].sourceUrnInfo.lastReportedAt integer 或 null 最近上报Unix秒,无值null。
content.items[].sourceUrnInfo.offlineAt integer 或 null 离线Unix秒,未离线null。
content.items[].sourceUrnInfo.deleteAt integer 或 null 预计生命周期清理Unix秒,未安排null;不是本次API删除时间。
content.items[].sourceUrnInfo.statusUpdatedAt integer 或 null 实体状态更新时间Unix秒,无值null。
content.items[].targetUrnInfo object 关系端点摘要,未找到可{},attributes全量可用;不附加teamInfo/tagsInfo/遥测/来源大字段。
content.items[].targetUrnInfo.id integer 或 string 或 null 底层实体记录标识,可能无值;客户定位使用urn。
content.items[].targetUrnInfo.workspaceUUID string 鉴权工作空间UUID。
content.items[].targetUrnInfo.urn string 实体规范URN,后续读取/修改/删除使用。
content.items[].targetUrnInfo.entityType string 实体类型编码。
content.items[].targetUrnInfo.provider string 采集/手工等实际来源,值由实体上报决定。
content.items[].targetUrnInfo.name string 实体名称。
content.items[].targetUrnInfo.displayName string 实体显示名;可空。
content.items[].targetUrnInfo.attributes object 实体动态属性;本拓扑返回全部可用属性。
content.items[].targetUrnInfo.attributes.字段名 JSON 对应类型DataSchema及上报实际字段;如env/project/owner/custom_tags/关系配置/健康覆盖字段,不固定每个实体都有。
content.items[].targetUrnInfo.healthScore integer 或 null 有效健康分数,负值/无值归一null;关闭健康为null,不直接等于0。
content.items[].targetUrnInfo.healthStatus string healthy/warning/critical/unknown;关闭健康为unknown。
content.items[].targetUrnInfo.healthUpdateAt string 或 null 健康更新时间,通常YYYY-MM-DD HH:mm:ss;关闭/无值为null。
content.items[].targetUrnInfo.createdAt string 或 null 创建时间,通常YYYY-MM-DD HH:mm:ss,按服务格式返回。
content.items[].targetUrnInfo.updatedAt string 或 null 最后更新时间,同创建时间格式。
content.items[].targetUrnInfo.healthConfig object 实体覆盖策略,不是类型策略拷贝。
content.items[].targetUrnInfo.healthConfig.mode string inherit/func/disabled;历史仅func_id归一为func。
content.items[].targetUrnInfo.healthConfig.funcId string 仅func模式出现的函数UUID。
content.items[].targetUrnInfo.healthEnabled boolean 综合类型和实体配置的有效开关;类型disabled时实体custom也不能开启。
content.items[].targetUrnInfo.entityStatus string online/offline,旧数据缺省online;状态不等于健康等级。
content.items[].targetUrnInfo.lifecycleManaged boolean 是否受实体生命周期管理;缺省false。
content.items[].targetUrnInfo.lastReportedAt integer 或 null 最近上报Unix秒,无值null。
content.items[].targetUrnInfo.offlineAt integer 或 null 离线Unix秒,未离线null。
content.items[].targetUrnInfo.deleteAt integer 或 null 预计生命周期清理Unix秒,未安排null;不是本次API删除时间。
content.items[].targetUrnInfo.statusUpdatedAt integer 或 null 实体状态更新时间Unix秒,无值null。
content.groupInfo object 基于返回实体节点构造的分组,不是关系边数量分组。
content.groupInfo.groupByLayers array<object> 顶层分组层;[]无分组。
content.groupInfo.groupByLayers[].groupByField string 当前分组字段。
content.groupInfo.groupByLayers[].groupByData object 按组值字符串作为动态键的桶映射。
content.groupInfo.groupByLayers[].groupByData.组值 object 该组的节点数据及可选子分组。
content.groupInfo.groupByLayers[].groupByData.组值.data array<object> 当前层未进入子分组的节点,叶子层为该组全部节点。
content.groupInfo.groupByLayers[].groupByData.组值.groupByLayers array<object> 可选下一级分组,递归结构与groupInfo.groupByLayers相同;不能忽略其中节点。
content.groupInfo.noGroupData array<object> 未匹配所有分组字段的节点;无groupByFields时保存全部返回节点。
content.declaration object 或 null 非空业务对象附带的工作空间公共声明,未配置时可为null或空对象;空对象不添加。
content.groupInfo.groupByLayers[].groupByData.组值.data[].urn string 实体规范URN,后续读取/修改/删除使用。
content.groupInfo.groupByLayers[].groupByData.组值.data[].entityType string 实体类型编码。
content.groupInfo.groupByLayers[].groupByData.组值.data[].provider string 采集/手工等实际来源,值由实体上报决定。
content.groupInfo.groupByLayers[].groupByData.组值.data[].name string 实体名称。
content.groupInfo.groupByLayers[].groupByData.组值.data[].displayName string 实体显示名;可空。
content.groupInfo.groupByLayers[].groupByData.组值.data[].attributes object 实体动态属性;本拓扑返回全部可用属性。
content.groupInfo.groupByLayers[].groupByData.组值.data[].attributes.字段名 JSON 对应类型DataSchema及上报实际字段;如env/project/owner/custom_tags/关系配置/健康覆盖字段,不固定每个实体都有。
content.groupInfo.groupByLayers[].groupByData.组值.data[].healthScore integer 或 null 有效健康分数,负值/无值归一null;关闭健康为null,不直接等于0。
content.groupInfo.groupByLayers[].groupByData.组值.data[].healthStatus string healthy/warning/critical/unknown;关闭健康为unknown。
content.groupInfo.groupByLayers[].groupByData.组值.data[].healthUpdateAt string 或 null 健康更新时间,通常YYYY-MM-DD HH:mm:ss;关闭/无值为null。
content.groupInfo.groupByLayers[].groupByData.组值.data[].healthConfig object 实体覆盖策略,不是类型策略拷贝。
content.groupInfo.groupByLayers[].groupByData.组值.data[].healthConfig.mode string inherit/func/disabled;历史仅func_id归一为func。
content.groupInfo.groupByLayers[].groupByData.组值.data[].healthConfig.funcId string 仅func模式出现的函数UUID。
content.groupInfo.groupByLayers[].groupByData.组值.data[].healthEnabled boolean 综合类型和实体配置的有效开关;类型disabled时实体custom也不能开启。
content.groupInfo.groupByLayers[].groupByData.组值.data[].entityStatus string online/offline,旧数据缺省online;状态不等于健康等级。
content.groupInfo.groupByLayers[].groupByData.组值.data[].lifecycleManaged boolean 是否受实体生命周期管理;缺省false。
content.groupInfo.groupByLayers[].groupByData.组值.data[].lastReportedAt integer 或 null 最近上报Unix秒,无值null。
content.groupInfo.groupByLayers[].groupByData.组值.data[].offlineAt integer 或 null 离线Unix秒,未离线null。
content.groupInfo.groupByLayers[].groupByData.组值.data[].deleteAt integer 或 null 预计生命周期清理Unix秒,未安排null;不是本次API删除时间。
content.groupInfo.groupByLayers[].groupByData.组值.data[].statusUpdatedAt integer 或 null 实体状态更新时间Unix秒,无值null。
content.groupInfo.noGroupData[].urn string 实体规范URN,后续读取/修改/删除使用。
content.groupInfo.noGroupData[].entityType string 实体类型编码。
content.groupInfo.noGroupData[].provider string 采集/手工等实际来源,值由实体上报决定。
content.groupInfo.noGroupData[].name string 实体名称。
content.groupInfo.noGroupData[].displayName string 实体显示名;可空。
content.groupInfo.noGroupData[].attributes object 实体动态属性;本拓扑返回全部可用属性。
content.groupInfo.noGroupData[].attributes.字段名 JSON 对应类型DataSchema及上报实际字段;如env/project/owner/custom_tags/关系配置/健康覆盖字段,不固定每个实体都有。
content.groupInfo.noGroupData[].healthScore integer 或 null 有效健康分数,负值/无值归一null;关闭健康为null,不直接等于0。
content.groupInfo.noGroupData[].healthStatus string healthy/warning/critical/unknown;关闭健康为unknown。
content.groupInfo.noGroupData[].healthUpdateAt string 或 null 健康更新时间,通常YYYY-MM-DD HH:mm:ss;关闭/无值为null。
content.groupInfo.noGroupData[].healthConfig object 实体覆盖策略,不是类型策略拷贝。
content.groupInfo.noGroupData[].healthConfig.mode string inherit/func/disabled;历史仅func_id归一为func。
content.groupInfo.noGroupData[].healthConfig.funcId string 仅func模式出现的函数UUID。
content.groupInfo.noGroupData[].healthEnabled boolean 综合类型和实体配置的有效开关;类型disabled时实体custom也不能开启。
content.groupInfo.noGroupData[].entityStatus string online/offline,旧数据缺省online;状态不等于健康等级。
content.groupInfo.noGroupData[].lifecycleManaged boolean 是否受实体生命周期管理;缺省false。
content.groupInfo.noGroupData[].lastReportedAt integer 或 null 最近上报Unix秒,无值null。
content.groupInfo.noGroupData[].offlineAt integer 或 null 离线Unix秒,未离线null。
content.groupInfo.noGroupData[].deleteAt integer 或 null 预计生命周期清理Unix秒,未安排null;不是本次API删除时间。
content.groupInfo.noGroupData[].statusUpdatedAt integer 或 null 实体状态更新时间Unix秒,无值null。
{
  "code": 200,
  "content": {
    "items": [
      {
        "id": null,
        "workspaceUUID": "wksp_example",
        "sourceUrn": "urn:service:default:api",
        "targetUrn": "urn:database:default:demo",
        "relationType": "links",
        "sourceUrnInfo": {
          "id": null,
          "workspaceUUID": "wksp_example",
          "urn": "urn:service:default:api",
          "entityType": "service",
          "provider": "manual",
          "name": "api",
          "displayName": "API",
          "attributes": {
            "project": "demo",
            "env": "prod"
          },
          "healthScore": null,
          "healthStatus": "unknown",
          "healthUpdateAt": null,
          "createdAt": "2026-11-18 10:00:00",
          "updatedAt": "2026-11-18 10:00:00",
          "healthConfig": {
            "mode": "inherit"
          },
          "healthEnabled": false,
          "entityStatus": "online",
          "lifecycleManaged": false,
          "lastReportedAt": null,
          "offlineAt": null,
          "deleteAt": null,
          "statusUpdatedAt": null
        },
        "targetUrnInfo": {
          "id": null,
          "workspaceUUID": "wksp_example",
          "urn": "urn:database:default:demo",
          "entityType": "database",
          "provider": "manual",
          "name": "demo",
          "displayName": "Demo database",
          "attributes": {
            "project": "demo"
          },
          "healthScore": null,
          "healthStatus": "unknown",
          "healthUpdateAt": null,
          "createdAt": "2026-11-18 10:00:00",
          "updatedAt": "2026-11-18 10:00:00",
          "healthConfig": {
            "mode": "inherit"
          },
          "healthEnabled": false,
          "entityStatus": "online",
          "lifecycleManaged": false,
          "lastReportedAt": null,
          "offlineAt": null,
          "deleteAt": null,
          "statusUpdatedAt": null
        }
      }
    ],
    "groupInfo": {
      "groupByLayers": [
        {
          "groupByField": "project",
          "groupByData": {
            "demo": {
              "data": [
                {
                  "urn": "urn:service:default:api",
                  "entityType": "service",
                  "provider": "manual",
                  "name": "api",
                  "displayName": "API",
                  "attributes": {
                    "project": "demo",
                    "env": "prod"
                  },
                  "healthScore": null,
                  "healthStatus": "unknown",
                  "healthUpdateAt": null,
                  "healthConfig": {
                    "mode": "inherit"
                  },
                  "healthEnabled": false,
                  "entityStatus": "online",
                  "lifecycleManaged": false,
                  "lastReportedAt": null,
                  "offlineAt": null,
                  "deleteAt": null,
                  "statusUpdatedAt": null
                },
                {
                  "urn": "urn:database:default:demo",
                  "entityType": "database",
                  "provider": "manual",
                  "name": "demo",
                  "displayName": "Demo database",
                  "attributes": {
                    "project": "demo"
                  },
                  "healthScore": null,
                  "healthStatus": "unknown",
                  "healthUpdateAt": null,
                  "healthConfig": {
                    "mode": "inherit"
                  },
                  "healthEnabled": false,
                  "entityStatus": "online",
                  "lifecycleManaged": false,
                  "lastReportedAt": null,
                  "offlineAt": null,
                  "deleteAt": null,
                  "statusUpdatedAt": null
                }
              ]
            }
          }
        }
      ],
      "noGroupData": []
    },
    "declaration": {}
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

错误响应

鉴权、限流和公共请求错误参见公共错误定义。

下游错误沿Kodo共享映射,4xx可返回实际HTTP及ft.KodoCommonApiErr或已映射业务码;不是所有失败都转406。未透传的5xx/连接异常/成功结果结构不符最终为500 ft.InternalServerError。保留errorCode/message/traceId,按读取或写入阶段处理;成功HTTP不能替代实体实际可见性验收。

HTTP 状态 errorCode 触发条件 消息或响应说明 处理方式
406 ft.ParameterValidationFailed 请求字段缺失,或字段值违反声明的校验条件 参数解析失败 核对参数位置、字段名、类型和取值。
400 ft.RequestJsonFormatError 请求 JSON 语法无效 请求 JSON 格式错误 按 content.reason、line、column 修正 JSON。
400 ft.JsonFormatError Body顶层不是JSON对象 部分 json 文件格式错误 按示例提交对象,不用数组/字符串。
406 ft.InvalidParameter 健康filters/orderBy未唯一明确entityType 参数{}无效 填写单一类型编码,关闭态按null/unknown处理,不使用混合类型的历史健康值。
500 ft.InternalServerError 下游查询失败/超时、成功数据形状异常或标签/团队/时间格式化失败 内部错误 缩小查询范围后适当重试;持续失败保留traceId和筛选条件排查,不归因于本次写入。

文档评价

文档内容是否对您有帮助?