Pages API
管理极狐GitLab Pages 的端点。
您必须开启极狐GitLab Pages 功能才能使用这些端点。详情请参见管理和使用此功能。
取消发布 Pages
先决条件:
- 您必须对实例具管理员访问权限。
移除 Pages。
DELETE /projects/:id/pages
参数 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id |
integer/string | yes | 经过身份验证的用户拥有的项目 ID 或 URL 编码的路径 |
curl --request 'DELETE' --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"
获取项目的 Pages 设置Get Pages settings for a project
- 引入于极狐GitLab 16.8。
先决条件:
- 您必须至少具有项目的维护者角色。
列出项目的 Pages 设置。
GET /projects/:id/pages
支持的参数:
属性 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | ID 或 URL 编码的项目路径 |
如果成功,则返回 200
并返回如下响应属性:
属性 | 类型 | 描述 |
---|---|---|
url |
string | 访问此项目 Pages 的 URL。 |
is_unique_domain_enabled |
boolean | 如果启用了独一无二的域名。 |
force_https |
boolean | 如果项目设置了强制 HTTPS 则为 true 。 |
deployments[] |
array | 当前活跃的部署。 |
created_at |
date | 部署的创建日期。 |
url |
string | 部署的 URL。 |
path_prefix |
string | 当使用并行部署时的部署路径前缀。 |
root_directory |
string | 根目录 |
Example request:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/2/pages"
Example response:
{
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010",
"is_unique_domain_enabled": true,
"force_https": false,
"deployments": [
{
"created_at": "2024-01-05T18:58:14.916Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/",
"path_prefix": "",
"root_directory": null
},
{
"created_at": "2024-01-05T18:58:46.042Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3",
"path_prefix": "mr3",
"root_directory": null
}
]
}
更新项目的 Pages 设置
- 引入于极狐GitLab 17.0。
先决条件:
- 您必须是管理员。
更新项目的 Pages 设置:
PATCH /projects/:id/pages
支持的参数:
属性 | 类型 | 是否必需 | 描述 |
---|---|---|---|
id |
integer/string | Yes | ID 或 URL 编码的项目路径 |
pages_unique_domain_enabled |
boolean | No | 是否是独一无二的域名。 |
pages_https_only |
boolean | No | 是否强制使用 HTTS。 |
如果成功,返回 200
和以下响应属性:
Attribute | Type | Description |
---|---|---|
url |
string | 访问此项目 Pages 的 URL。 |
is_unique_domain_enabled |
boolean | 如果启用了独一无二的域名。 |
force_https |
boolean | 如果项目设置了强制 HTTPS 则为 true 。 |
deployments[] |
array | 当前活跃部署的列表。 |
created_at |
date | 部署创建的日期。 |
url |
string | 部署的 URL。 |
path_prefix |
string | 当使用并行部署时的部署路径前缀。 |
root_directory |
string | 根目录 |
示例请求:
curl --request PATCH --header "PRIVATE-TOKEN: <your_access_token>" --url "https://gitlab.example.com/api/v4/projects/:id/pages" \
--form 'pages_unique_domain_enabled=true' --form 'pages_https_only=true'
示例响应:
{
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010",
"is_unique_domain_enabled": true,
"force_https": false,
"deployments": [
{
"created_at": "2024-01-05T18:58:14.916Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/",
"path_prefix": "",
"root_directory": null
},
{
"created_at": "2024-01-05T18:58:46.042Z",
"url": "http://html-root-4160ce5f0e9a6c90ccb02755b7fc80f5a2a09ffbb1976cf80b653.pages.gdk.test:3010/mr3",
"path_prefix": "mr3",
"root_directory": null
}
]
}