1. iModel 接口说明
iModels
接口一、创建 iModel
POST https://api.bentley.com/imodels/
创建一个 iModel。创建 iModel 有三种不同的方式。
创建一个空 iModel
创建空 iModel 不要提供 template 和 baselineFile 属性。
从已有的 iModel 中创建一个新的 iModel
从已有的 iModel 中创建一个新的 iModel 需要提供 template 属性。服务器将源 iModel 文件 changesetId 属性指定的变更集用作新创建的 iModel 的基线文件。用户必须对源 iModel 文件具有
imodels_read
权限。源项目和目标项目必须在同一个数据中心当中。使用基线文件创建一个新的 iModel
使用基线文件创建一个新的 iModel 允许上传定制化的 iModel 的文件以作为新创建的 iModel 的基线文件。使用基线文件创建一个新的 iModel 有三个步骤:
创建一个新的 iModel 并提供 baselineFile 属性。提供正确的文件大小很重要,否则 iModel 的创建将会在接下来的步骤中失败。
使用创建 iModel 响应中的 upload 属性对应的链接上传基线文件到 Blob 存储中。
Request syntax: PUT upload HTTP/1.1 Request headers: x-ms-blob-type: BlockBlob
确认基线文件已经成功上传,完成 iModel 的创建工作。请查阅完成 iModel 基线文件上传的相关文档。
iModel 的初始化
当创建一个空 iModel 它会立即进行初始化。当使用 twmplate 或者 baselineFile 属性创建 iModel 初始化会被调度执行,可以通过 state 属性查看状态。了解更多关于 iModel 初始化状态的信息请查阅https://developer.bentley.com/apis/operations/get-imodel-baseline-file/。
认证
需要在请求 Header 里包含 Authorization
字段,Authorization
字段要求是有效的且带有 imodels:modify
作用域的 Bearer 令牌。
想要了解更多关于授权以及如何获取 access token的细节,请参考这个https://developer.bentley.com/apis/overview/authorization/文档 。
授权
用户应该是此 iModel 所属的项目所在的组织上的组织管理员或者在项目级别上具有 imodels_manage
的权限。
组织管理员必须在用户管理中至少分配以下角色之一:Account Administrator(账户管理员), Co-Administrator(联合管理员), or CONNECT Services Administrator(CONNECT 服务管理员)。想要了解更多有关于用户管理的信息,请查看 Bentley 社区 的 wiki 页面 https://communities.bentley.com/communities/other_communities/licensing_cloud_and_web_services/w/wiki/50711/user-management-2-0。
接口使用率限制
所有在 iTwin Platform 上的接口都有接口使用率限制。想了解更多相关信息请查看 https://developer.bentley.com/apis/overview/rate-limits/
请求
请求头
名称 | 是否必须 | 描述 |
---|---|---|
Authorization | 是 | 带有 imodels:modify 作用域的 OAuth 访问令牌 |
Accept | 否 | 推荐设置为 application/vnd.bentley.itwin-platform.v1+json |
Content-Type | 否 | 标识请求主体的内容类型。支持的类型为 application/json |
请求主体
参数名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
projectId | String | 是 | 要创建的 iModel 所属的项目 ID |
name | String | 是 | iModel 的名字 |
description | String, null | 否 | iModel 的描述信息 |
extent | Extent | 否 | 地球上能容纳的 iModel 的最大矩形面积。最大范围用于帮助保持 iModel 清洁。导入新元素时,超出范围的元素将被标记以供进一步处理。 |
template | iModelTemplate | 否 | 如果有,将标识使用另外的 iModel 作为模板创建 iModel |
baselineFile | BaselineFileCreate | 否 | 如果有,标识使用定制化的基线文件创建 iModel |
例子
{
"projectId": "ad0ba809-9241-48ad-9eb0-c8038c1a1d51",
"name": "Sun City Renewable-energy Plant",
"description": "Overall model of wind and solar farms in Sun City",
"extent": {
"southWest": {
"latitude": 46.13267702834806,
"longitude": 7.672120009938448
},
"northEast": {
"latitude": 46.302763954781234,
"longitude": 7.835541640797823
}
},
"template": null,
"baselineFile": null
}
响应
返回 201 No Created:
Created
(1)空 iModel
{ "iModel": { "id": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "displayName": "Sun City Renewable-energy Plant", "name": "Sun City Renewable-energy Plant", "description": "Overall model of wind and solar farms in Sun City", "state": "initialized", "createdDateTime": "2020-10-20T10:51:33.1700000Z", "projectId": "ad0ba809-9241-48ad-9eb0-c8038c1a1d51", "extent": { "southWest": { "latitude": 46.13267702834806, "longitude": 7.672120009938448 }, "northEast": { "latitude": 46.302763954781234, "longitude": 7.835541640797823 } }, "_links": { "creator": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/users/42101fba-847a-4f4e-85a8-a4bed89065e4" }, "changesets": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/changesets" }, "namedVersions": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/namedversions" }, "upload": null, "complete": null } } }
(2)从模板创建来的 iModel
{ "iModel": { "id": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "displayName": "Sun City Renewable-energy Plant", "name": "Sun City Renewable-energy Plant", "description": "Overall model of wind and solar farms in Sun City", "state": "notInitialized", "createdDateTime": "2020-10-20T10:51:33.1700000Z", "projectId": "ad0ba809-9241-48ad-9eb0-c8038c1a1d51", "extent": { "southWest": { "latitude": 46.13267702834806, "longitude": 7.672120009938448 }, "northEast": { "latitude": 46.302763954781234, "longitude": 7.835541640797823 } }, "_links": { "creator": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/users/42101fba-847a-4f4e-85a8-a4bed89065e4" }, "changesets": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/changesets" }, "namedVersions": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/namedversions" }, "upload": null, "complete": null } } }
(3)从基线文件创建来的 iModel
{ "iModel": { "id": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "displayName": "Sun City Renewable-energy Plant", "name": "Sun City Renewable-energy Plant", "description": "Overall model of wind and solar farms in Sun City", "state": "notInitialized", "createdDateTime": "2020-10-20T10:51:33.1700000Z", "projectId": "ad0ba809-9241-48ad-9eb0-c8038c1a1d51", "extent": { "southWest": { "latitude": 46.13267702834806, "longitude": 7.672120009938448 }, "northEast": { "latitude": 46.302763954781234, "longitude": 7.835541640797823 } }, "_links": { "creator": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/users/42101fba-847a-4f4e-85a8-a4bed89065e4" }, "changesets": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/changesets" }, "namedVersions": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/namedversions" }, "upload": { "href": "https://imodelhub.blob.core.windows.net/imodelhub-5e19bee0-3aea-4355-a9f0-c6df9989ee7d/5e19bee0-3aea-4355-a9f0-c6df9989ee7d.bim?sv=2019-07-07&sr=b&sig=ByGsPs4cwKyUfnV6%2BjDZFDL3J7QiE0vl917MCX%2FC35Y%3D&st=2021-07-30T10%3A53%3A09.5224547Z&se=2021-07-30T11%3A13%3A09.5224552Z&sp=rw" }, "complete": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/baselinefile" } } } }
返回 401 Unauthorized:
此响应表示请求缺少有效的身份验证凭据。访问令牌可能未提供、或是由错误的颁发者颁发、没有所需的作用域或请求头的格式不正确。
{
"error": {
"code": "Unauthorized",
"message": "Access denied due to invalid access_token. Make sure to provide a valid token for this API endpoint."
}
}
- 返回 403 Forbidden:
用户无权创建变更集。
{
"error": {
"code": "InsufficientPermissions",
"message": "The user has insufficient permissions for the requested operation."
}
}
- Response 404 Not Found:
{
"error": {
"code": "ProjectNotFound",
"message": "Requested project is not available."
}
}
Response 409 Conflict:
项目内已有同名 iModel
{ "error": { "code": "iModelExists", "message": "iModel with the same name already exists within the project." } }
- Response 422 Unprocessable Entity:
状态代码表示由于客户端错误(例如,格式错误的请求语法),服务器无法处理请求。
(1)不合法的 iModels 请求
{ "error": { "code": "InvalidiModelsRequest", "message": "Cannot create iModel.", "details": [{ "code": "InvalidValue", "message": "Provided 'extent' value is not valid. Valid 'latitude' value range is -90 to 90.", "target": "extent" }, { "code": "InvalidHeaderValue", "message": "'application/xml' is not supported 'content-type'. Supported media type is 'application/json'.", "target": "content-type" }, { "code": "MissingRequiredProperty", "message": "Required property is missing.", "target": "name" }, { "code": "InvalidRequestBody", "message": "Failed to parse request body. Make sure it is a valid JSON." } ] } }
(2)请求主体缺失
{ "error": { "code": "MissingRequestBody", "message": "Request body was not provided." } }
- Response 429 Too many requests:
此响应表示用户在给定的时间内发送了太多请求
{
"error": {
"code": "TooManyRequests",
"message": "More requests were received than the subscription rate-limit allows."
}
}
响应头
名称 | 描述 |
---|---|
retry-after | 超过客户端订阅的速率限制的请求 |
接口二、删除 iModel
DELETE https://api.bentley.com/imodels/{id}
认证
需要在请求 Header 里包含 Authorization
字段,Authorization
字段要求是有效的且带有 imodels:modify
作用域的 Bearer 令牌。
想要了解更多关于授权以及如何获取 access token的细节,请参考这个https://developer.bentley.com/apis/overview/authorization/文档 。
授权
用户应该是此 iModel 所属的项目所在的组织上的组织管理员或者在项目级别上具有 imodels_delete
的权限。
组织管理员必须在用户管理中至少分配以下角色之一:Account Administrator(账户管理员), Co-Administrator(联合管理员), or CONNECT Services Administrator(CONNECT 服务管理员)。想要了解更多有关于用户管理的信息,请查看 Bentley 社区 的 wiki 页面 https://communities.bentley.com/communities/other_communities/licensing_cloud_and_web_services/w/wiki/50711/user-management-2-0。
接口使用率限制
所有在 iTwin Platform 上的接口都有接口使用率限制。想了解更多相关信息请查看 https://developer.bentley.com/apis/overview/rate-limits/
请求
请求参数
名称 | 所在位置 | 是否必须 | 描述 |
---|---|---|---|
id | template | 是 | iModel 的 ID |
请求头
名称 | 是否必须 | 描述 |
---|---|---|
Authorization | 是 | 带有 imodels:modify 作用域的 OAuth 访问令牌 |
Accept | 否 | 推荐设置为 application/vnd.bentley.itwin-platform.v1+json |
响应
返回 204 No Content:
没有内容
返回 401 Unauthorized:
此响应表示请求缺少有效的身份验证凭据。访问令牌可能未提供、或是由错误的颁发者颁发、没有所需的作用域或请求头的格式不正确。
{
"error": {
"code": "Unauthorized",
"message": "Access denied due to invalid access_token. Make sure to provide a valid token for this API endpoint."
}
}
- 返回 403 Forbidden:
用户无权删除变更集。
{
"error": {
"code": "InsufficientPermissions",
"message": "The user has insufficient permissions for the requested operation."
}
}
Response 404 Not Found:
无法找到指定的 iModel
{
"error": {
"code": "iModelNotFound",
"message": "Requested iModel is not available."
}
}
- Response 429 Too many requests:
此响应表示用户在给定的时间内发送了太多请求
{
"error": {
"code": "TooManyRequests",
"message": "More requests were received than the subscription rate-limit allows."
}
}
响应头
名称 | 描述 |
---|---|
retry-after | 超过客户端订阅的速率限制的请求 |
接口三、获取项目的 iModel
GET https://api.bentley.com/imodels/?projectId[&$skip][&$top][&$orderBy][&name]
从指定的项目中获取 iModel 的列表
说明
Header 中的 Perfer
可用于指定客户端需要多少元数据结果。Preer
用于指示特定的服务器行为是客户端首选的,但不是成功完成请求所必需的。
此操作支持“return=representation”和“return=minimal”首选项。
“return=representation”首选项表示客户端希望服务器在响应成功请求时包含一个表示资源当前状态的实体。“return=minimal”首选项表示客户端希望服务器对成功的请求只返回最小的响应。如果未指定首选标头,则这是默认首选项。
认证
需要在请求 Header 里包含 Authorization
字段,Authorization
字段要求是有效的且带有 imodels:read
作用域的 Bearer 令牌。
想要了解更多关于授权以及如何获取 access token的细节,请参考这个https://developer.bentley.com/apis/overview/authorization/文档 。
授权
用户必须在 iModel 级别上分配 imodels_webview
的权限,以及至少在项目级别上分配 imodels_webview
权限。如果未配置 iModel 级别的权限,则用户必须在项目级别分配 imodels_webview
权限。
或者,用户应该是此 iModel 所属的项目所在的组织上的组织管理员。
组织管理员必须在用户管理中至少分配以下角色之一:Account Administrator(账户管理员), Co-Administrator(联合管理员), or CONNECT Services Administrator(CONNECT 服务管理员)。想要了解更多有关于用户管理的信息,请查看 Bentley 社区 的 wiki 页面 https://communities.bentley.com/communities/other_communities/licensing_cloud_and_web_services/w/wiki/50711/user-management-2-0
接口使用率限制
所有在 iTwin Platform 上的接口都有接口使用率限制。想了解更多相关信息请查看 https://developer.bentley.com/apis/overview/rate-limits/
请求
请求参数
参数名称 | 所在位置 | 是否必须 | 描述 |
---|---|---|---|
projectId | query | 是 | 项目的 ID |
$top | query | 否 | $top 请求查询的集合结果中中要包含结果的数目。例如,仅返回第一个集合项,请提供以下查询:$top=1。如果此参数未提供则默认为100。此参数的值不能超过1000 |
$skip | query | 否 | $skip 选项请求查询集合中要跳过且不包含在结果中的项数。例如,要从第三位开始返回集合中的项目,请提供以下查询:$skip=2。 |
$orderBy | query | 否 | $orderBy 选项允许客户端使用“asc”请求升序,或使用“desc”请求降序,按其中一个项属性对返回的集合进行排序。目前,变更集唯一受支持的属性是“index”。如果未指定“asc”或“desc”关键字,则集合将按升序排序。要按降序排列集合,请提供'desc'关键字,例如:$orderBy=index desc |
name | query | 否 | 名称选项允许用户按名称属性筛选iModel。例如,要返回名称等于'Sun City Renewable-energy Plant'的 iModel,请提供以下查询:name=Sun%20City%20Renewable-energy%20Plant。此参数的有效值遵循与iModel创建相同的要求——字符串不应为空,不应仅由空格组成,且不应超过255个字符。此查询选项使用精确匹配。 |
请求头
名称 | 是否必须 | 描述 |
---|---|---|
Authorization | 是 | 带有 imodels:read 作用域的 OAuth 访问令牌 |
Accept | 否 | 推荐设置为 application/vnd.bentley.itwin-platform.v1+json |
Prefer | 否 | 标识响应中所携带信息的详细等级。此操作支持“return=representation”和“return=minimal”首选项 |
响应
返回 200 OK:
OK
(1)Prefer: return=minimal
{ "iModels": [{ "id": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "displayName": "Sun City Renewable-energy Plant" }, { "id": "e5692781-32b8-473d-8752-908468f46926", "displayName": "Power Town Processing Plant" } ], "_links": { "self": { "href": "https://api.bentley.com/imodels?projectId=ad0ba809-9241-48ad-9eb0-c8038c1a1d51&$skip=0&$top=100" }, "prev": { "href": "https://api.bentley.com/imodels?projectId=ad0ba809-9241-48ad-9eb0-c8038c1a1d51&$skip=0&$top=100" }, "next": { "href": "https://api.bentley.com/imodels?projectId=ad0ba809-9241-48ad-9eb0-c8038c1a1d51&$skip=100&$top=100" } } }
(2)Prefer: return=representation
{ "iModels": [{ "id": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "displayName": "Sun City Renewable-energy Plant", "name": "Sun City Renewable-energy Plant", "description": "Overall model of wind and solar farms in Sun City", "state": "initialized", "createdDateTime": "2020-10-20T10:51:33.1700000Z", "projectId": "ad0ba809-9241-48ad-9eb0-c8038c1a1d51", "extent": { "southWest": { "latitude": 46.13267702834806, "longitude": 7.672120009938448 }, "northEast": { "latitude": 46.302763954781234, "longitude": 7.835541640797823 } }, "_links": { "creator": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/users/42101fba-847a-4f4e-85a8-a4bed89065e4" }, "changesets": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/changesets" }, "namedVersions": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/namedversions" } } }, { "id": "e5692781-32b8-473d-8752-908468f46926", "displayName": "Power Town Processing Plant", "name": "Power Town Processing Plant", "description": "Overall model of processing plant in Power town", "state": "notInitialized", "createdDateTime": "2020-10-20T10:51:33.1700000Z", "projectId": "ad0ba809-9241-48ad-9eb0-c8038c1a1d51", "extent": { "southWest": { "latitude": 40.06505158641991, "longitude": -75.68920502461773 }, "northEast": { "latitude": 40.066956495561584, "longitude": -75.6865871886192 } }, "_links": { "creator": { "href": "https://api.bentley.com/imodels/e5692781-32b8-473d-8752-908468f46926/users/42101fba-847a-4f4e-85a8-a4bed89065e4" }, "changesets": { "href": "https://api.bentley.com/imodels/e5692781-32b8-473d-8752-908468f46926/changesets" }, "namedVersions": { "href": "https://api.bentley.com/imodels/e5692781-32b8-473d-8752-908468f46926/namedversions" } } } ], "_links": { "self": { "href": "https://api.bentley.com/imodels?projectId=ad0ba809-9241-48ad-9eb0-c8038c1a1d51&$skip=0&$top=100" }, "prev": { "href": "https://api.bentley.com/imodels?projectId=ad0ba809-9241-48ad-9eb0-c8038c1a1d51&$skip=0&$top=100" }, "next": { "href": "https://api.bentley.com/imodels?projectId=ad0ba809-9241-48ad-9eb0-c8038c1a1d51&$skip=100&$top=100" } } }
返回 401 Unauthorized:
此响应表示请求缺少有效的身份验证凭据。访问令牌可能未提供、或是由错误的颁发者颁发、没有所需的作用域或请求头的格式不正确。
{
"error": {
"code": "Unauthorized",
"message": "Access denied due to invalid access_token. Make sure to provide a valid token for this API endpoint."
}
}
- Response 404 Not Found:
无法找到指定的项目
{
"error": {
"code": "ProjectNotFound",
"message": "Requested project is not available."
}
}
Response 422 Unprocessable Entity:
状态代码表示由于客户端错误(例如,格式错误的请求语法),服务器无法处理请求。
{ "error": { "code": "InvalidiModelsRequest", "message": "Cannot get iModels.", "details": [{ "code": "InvalidValue", "message": "'abc' is not a valid 'projectId'.", "target": "projectId" }] } }
Response 429 Too many requests:
此响应表示用户在给定的时间内发送了太多请求
{
"error": {
"code": "TooManyRequests",
"message": "More requests were received than the subscription rate-limit allows."
}
}
响应头
名称 | 描述 |
---|---|
retry-after | 超过客户端订阅的速率限制的请求数 |
接口四、获取 iModel
GET https://api.bentley.com/imodels/{id}
获取 iModel 的元数据。
认证
需要在请求 Header 里包含 Authorization
字段,Authorization
字段要求是有效的且带有 imodels:read
作用域的 Bearer 令牌。
想要了解更多关于授权以及如何获取 access token的细节,请参考这个https://developer.bentley.com/apis/overview/authorization/文档 。
授权
用户必须在 iModel 级别上分配 imodels_webview
的权限,以及至少在项目级别上分配 imodels_webview
权限。如果未配置 iModel 级别的权限,则用户必须在项目级别分配 imodels_webview
权限。
或者,用户应该是此 iModel 所属的项目所在的组织上的组织管理员。
组织管理员必须在用户管理中至少分配以下角色之一:Account Administrator(账户管理员), Co-Administrator(联合管理员), or CONNECT Services Administrator(CONNECT 服务管理员)。想要了解更多有关于用户管理的信息,请查看 Bentley 社区 的 wiki 页面 https://communities.bentley.com/communities/other_communities/licensing_cloud_and_web_services/w/wiki/50711/user-management-2-0
接口使用率限制
所有在 iTwin Platform 上的接口都有接口使用率限制。想了解更多相关信息请查看 https://developer.bentley.com/apis/overview/rate-limits/
请求
请求参数
参数名称 | 所在位置 | 是否必须 | 描述 |
---|---|---|---|
id | template | 是 | iModel 的 ID |
请求头
名称 | 是否必须 | 描述 |
---|---|---|
Authorization | 是 | 带有 imodels:read 作用域的 OAuth 访问令牌 |
Accept | 否 | 推荐设置为 application/vnd.bentley.itwin-platform.v1+json |
响应
返回 200 OK:
OK
{ "iModel": { "id": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "displayName": "Sun City Renewable-energy Plant", "name": "Sun City Renewable-energy Plant", "description": "Overall model of wind and solar farms in Sun City", "state": "initialized", "createdDateTime": "2020-10-20T10:51:33.1700000Z", "projectId": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "extent": { "southWest": { "latitude": 46.13267702834806, "longitude": 7.672120009938448 }, "northEast": { "latitude": 46.302763954781234, "longitude": 7.835541640797823 } }, "_links": { "creator": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/users/42101fba-847a-4f4e-85a8-a4bed89065e4" }, "changesets": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/changesets" }, "namedVersions": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/namedversions" } } } }
返回 401 Unauthorized:
此响应表示请求缺少有效的身份验证凭据。访问令牌可能未提供、或是由错误的颁发者颁发、没有所需的作用域或请求头的格式不正确。
{
"error": {
"code": "Unauthorized",
"message": "Access denied due to invalid access_token. Make sure to provide a valid token for this API endpoint."
}
}
- Response 404 Not Found:
无法找到指定的 iModel
{
"error": {
"code": "iModelNotFound",
"message": "Requested iModel is not available."
}
}
- Response 429 Too many requests:
此响应表示用户在给定的时间内发送了太多请求
{
"error": {
"code": "TooManyRequests",
"message": "More requests were received than the subscription rate-limit allows."
}
}
响应头
名称 | 描述 |
---|---|
retry-after | 超过客户端订阅的速率限制的请求数 |
接口五、更新 iModel
PATCH https://api.bentley.com/imodels/{id}
更新 iModel 的元数据。
认证
需要在请求 Header 里包含 Authorization
字段,Authorization
字段要求是有效的且带有 imodels:modify
作用域的 Bearer 令牌。
想要了解更多关于授权以及如何获取 access token的细节,请参考这个https://developer.bentley.com/apis/overview/authorization/文档 。
授权
用户必须在 iModel 级别上分配 imodels_manage
的权限,以及至少在项目级别上分配 imodels_webview
权限。如果未配置 iModel 级别的权限,则用户必须在项目级别分配 imodels_manage
权限。
或者,用户应该是此 iModel 所属的项目所在的组织上的组织管理员。
组织管理员必须在用户管理中至少分配以下角色之一:Account Administrator(账户管理员), Co-Administrator(联合管理员), or CONNECT Services Administrator(CONNECT 服务管理员)。想要了解更多有关于用户管理的信息,请查看 Bentley 社区 的 wiki 页面 https://communities.bentley.com/communities/other_communities/licensing_cloud_and_web_services/w/wiki/50711/user-management-2-0
接口使用率限制
所有在 iTwin Platform 上的接口都有接口使用率限制。想了解更多相关信息请查看 https://developer.bentley.com/apis/overview/rate-limits/
请求
请求参数
参数名称 | 所在位置 | 是否必须 | 描述 |
---|---|---|---|
id | template | 是 | iModel 的 ID |
请求头
名称 | 是否必须 | 描述 |
---|---|---|
Authorization | 是 | 带有 imodels:modify 作用域的 OAuth 访问令牌 |
Accept | 否 | 推荐设置为 application/vnd.bentley.itwin-platform.v1+json |
Content-Type | 否 | 标识请求主体的内容类型。支持的类型是 application/json |
请求主体
iModel(更新)
参数名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
name | String | 是 | iModel 的名字 |
description | String, null | 否 | iModel 的描述信息 |
extent | Extent | 否 | 地球上能容纳的 iModel 的最大矩形面积。最大范围用于帮助保持 iModel 清洁。导入新元素时,超出范围的元素将被标记以供进一步处理。 |
例子
{
"name": "Sun City Renewable-energy Plant",
"description": "Overall model of wind and solar farms in Sun City",
"extent": {
"southWest": {
"latitude": 46.13267702834806,
"longitude": 7.672120009938448
},
"northEast": {
"latitude": 46.302763954781234,
"longitude": 7.835541640797823
}
}
}
响应
返回 200 OK:
OK
{ "iModel": { "id": "5e19bee0-3aea-4355-a9f0-c6df9989ee7d", "displayName": "Sun City Renewable-energy Plant", "name": "Sun City Renewable-energy Plant", "description": "Overall model of wind and solar farms in Sun City", "state": "initialized", "createdDateTime": "2020-10-20T10:51:33.1700000Z", "projectId": "ad0ba809-9241-48ad-9eb0-c8038c1a1d51", "extent": { "southWest": { "latitude": 46.13267702834806, "longitude": 7.672120009938448 }, "northEast": { "latitude": 46.302763954781234, "longitude": 7.835541640797823 } }, "_links": { "creator": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/users/42101fba-847a-4f4e-85a8-a4bed89065e4" }, "changesets": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/changesets" }, "namedVersions": { "href": "https://api.bentley.com/imodels/5e19bee0-3aea-4355-a9f0-c6df9989ee7d/namedversions" } } } }
返回 401 Unauthorized:
此响应表示请求缺少有效的身份验证凭据。访问令牌可能未提供、或是由错误的颁发者颁发、没有所需的作用域或请求头的格式不正确。
{
"error": {
"code": "Unauthorized",
"message": "Access denied due to invalid access_token. Make sure to provide a valid token for this API endpoint."
}
}
Response 403 Forbidden
用户无权更新 iModel
{ "error": { "code": "InsufficientPermissions", "message": "The user has insufficient permissions for the requested operation." } }
Response 404 Not Found:
请求的 iModel 无法找到
{
"error": {
"code": "iModelNotFound",
"message": "Requested iModel is not available."
}
}
Response 409 Conflict:
项目内已有同名 iModel
{ "error": { "code": "iModelExists", "message": "iModel with the same name already exists within the project." } }
Response 422 Unprocessable Entity:
状态代码表示由于客户端错误(例如,格式错误的请求语法),服务器无法处理请求。
(1)不合法的 iModels 请求
{ "error": { "code": "InvalidiModelsRequest", "message": "Cannot update iModel.", "details": [{ "code": "InvalidValue", "message": "Provided 'extent' value is not valid. Valid 'latitude' value range is -90 to 90.", "target": "extent" }, { "code": "InvalidHeaderValue", "message": "'application/xml' is not supported 'content-type'. Supported media type is 'application/json'.", "target": "content-type" }, { "code": "MissingRequiredProperty", "message": "Required property is missing. At least one of the following properties must be provided: 'extent', 'name', 'description'." }, { "code": "InvalidRequestBody", "message": "Failed to parse request body. Make sure it is a valid JSON." } ] } }
(2)请求主体缺失
{ "error": { "code": "MissingRequestBody", "message": "Request body was not provided." } }
Response 429 Too many requests:
此响应表示用户在给定的时间内发送了太多请求
{
"error": {
"code": "TooManyRequests",
"message": "More requests were received than the subscription rate-limit allows."
}
}
响应头
名称 | 描述 |
---|---|
retry-after | 超过客户端订阅的速率限制的请求数 |