Pages API
- Tier: 基础版,专业版,旗舰版
- Offering: JihuLab.com,私有化部署
管理 极狐GitLab Pages 的端点。
必须启用极狐GitLab Pages 功能才能使用这些端点。了解更多关于管理和使用此功能的信息。
取消发布页面
History
- 在极狐GitLab 17.9 中,最小所需角色从管理员访问变更为维护者角色。
先决条件:
- 您必须至少具有项目的维护者角色。
移除页面。
plaintextDELETE /projects/:id/pages
| 属性 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| id | integer/string | 是 | 项目的 ID 或 URL 编码路径 |
shellcurl --request 'DELETE' --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"
获取项目的页面设置
History
- 引入于GitLab 16.8。
先决条件:
- 您必须至少具有项目的维护者角色。
列出项目的页面设置。
plaintextGET /projects/:id/pages
支持的属性:
| 属性 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| id | integer/string | 是 | 项目的 ID 或 URL 编码路径 |
如果成功,将返回 200 以及以下响应属性:
| 属性 | 类型 | 描述 |
|---|---|---|
| url | string | 访问此项目页面的 URL。 |
| is_unique_domain_enabled | boolean | 如果启用了 独特域名。 |
| force_https | boolean | 如果项目设置为强制 HTTPS,则为 true。 |
| deployments[] | array | 当前活动部署的列表。 |
| primary_domain | string | 将所有页面请求重定向到的主域名。Introduced in GitLab 17.8. |
| deployments[] 属性 | 类型 | 描述 |
|---|---|---|
| created_at | date | 部署创建的日期。 |
| url | string | 此部署的 URL。 |
| path_prefix | string | 使用 并行部署 时的部署路径前缀。 |
| root_directory | string | 根目录。 |
示例请求:
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"
示例响应:
json1{ 2 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010", 3 "is_unique_domain_enabled": true, 4 "force_https": false, 5 "deployments": [ 6 { 7 "created_at": "2024-01-05T18:58:14.916Z", 8 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/", 9 "path_prefix": "", 10 "root_directory": null 11 }, 12 { 13 "created_at": "2024-01-05T18:58:46.042Z", 14 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3", 15 "path_prefix": "mr3", 16 "root_directory": null 17 } 18 ], 19 "primary_domain": null 20}
更新项目的页面设置
History
- 引入于极狐GitLab 17.0。
- 在极狐GitLab 17.9 中,最小所需角色从管理员访问变更为维护者角色。
先决条件:
- 您必须至少具有项目的维护者角色。
更新项目的页面设置。
plaintextPATCH /projects/:id/pages
支持的属性:
| 属性 | 类型 | 是否必须 | 描述 |
|---|---|---|---|
| id | integer/string | 是 | 项目的 ID 或 URL 编码路径 |
| pages_unique_domain_enabled | boolean | 否 | 是否使用独特域名 |
| pages_https_only | boolean | 否 | 是否强制使用 HTTPS |
| pages_primary_domain | string | 否 | 从现有分配的域名中设置主域名以重定向所有页面请求。引入于极狐GitLab 17.8。 |
如果成功,将返回 200 以及以下响应属性:
| 属性 | 类型 | 描述 |
|---|---|---|
| url | string | 访问此项目页面的 URL。 |
| is_unique_domain_enabled | boolean | 如果启用了 独特域名。 |
| force_https | boolean | 如果项目设置为强制 HTTPS,则为 true。 |
| deployments[] | array | 当前活动部署的列表。 |
| primary_domain | string | 将所有页面请求重定向到的主域名。Introduced in GitLab 17.8. |
| deployments[] 属性 | 类型 | 描述 |
|---|---|---|
| created_at | date | 部署创建的日期。 |
| url | string | 此部署的 URL。 |
| path_prefix | string | 使用 并行部署 时的部署路径前缀。 |
| root_directory | string | 根目录。 |
示例请求:
shell1curl --request PATCH \ 2 --header "PRIVATE-TOKEN: <your_access_token>" \ 3 --url "https://gitlab.example.com/api/v4/projects/:id/pages" \ 4 --form 'pages_unique_domain_enabled=true' \ 5 --form 'pages_https_only=true' \ 6 --form 'pages_primary_domain=https://custom.example.com'
示例响应:
json1{ 2 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010", 3 "is_unique_domain_enabled": true, 4 "force_https": false, 5 "deployments": [ 6 { 7 "created_at": "2024-01-05T18:58:14.916Z", 8 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/", 9 "path_prefix": "", 10 "root_directory": null 11 }, 12 { 13 "created_at": "2024-01-05T18:58:46.042Z", 14 "url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3", 15 "path_prefix": "mr3", 16 "root_directory": null 17 } 18 ], 19 "primary_domain": null 20}