Pages domains API

原文:https://docs.gitlab.com/ee/api/pages_domains.html

Pages domains API

GitLab Pages 中连接自定义域和 TLS 证书的端点.

必须启用 GitLab 页面功能才能使用这些端点. 了解有关管理使用功能的更多信息.

List all pages domains

获取所有页面域的列表. 用户必须具有管理员权限.

GET /pages/domains 
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/pages/domains" 
[  {  "domain":  "ssl.domain.example",  "url":  "https://ssl.domain.example",  "project_id":  1337,  "auto_ssl_enabled":  false,  "certificate":  {  "expired":  false,  "expiration":  "2020-04-12T14:32:00.000Z"  }  }  ] 

List pages domains

Get a list of project pages domains. The user must have permissions to view pages domains.

GET /projects/:id/pages/domains 
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains" 
[  {  "domain":  "www.domain.example",  "url":  "http://www.domain.example"  },  {  "domain":  "ssl.domain.example",  "url":  "https://ssl.domain.example",  "auto_ssl_enabled":  false,  "certificate":  {  "subject":  "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",  "expired":  false,  "certificate":  "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",  "certificate_text":  "Certificate:\n … \n"  }  }  ] 

Single pages domain

获取单个项目页面域. 用户必须具有查看页面域的权限.

GET /projects/:id/pages/domains/:domain 
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
domain string yes 用户指定的自定义域
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/www.domain.example" 
{  "domain":  "www.domain.example",  "url":  "http://www.domain.example"  } 
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example" 
{  "domain":  "ssl.domain.example",  "url":  "https://ssl.domain.example",  "auto_ssl_enabled":  false,  "certificate":  {  "subject":  "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",  "expired":  false,  "certificate":  "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",  "certificate_text":  "Certificate:\n … \n"  }  } 

Create new pages domain

创建一个新的页面域. 用户必须具有创建新页面域的权限.

POST /projects/:id/pages/domains 
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
domain string yes 用户指定的自定义域
auto_ssl_enabled boolean no 启用自动生成由 Let's Encrypt 为自定义域颁发的 SSL 证书的功能.
certificate file/string no PEM 格式的证书,其中的中间体按照从最高到最低的顺序排列.
key file/string no PEM 格式的证书密钥.
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "domain=ssl.domain.example" --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" "https://gitlab.example.com/api/v4/projects/5/pages/domains" 
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "domain=ssl.domain.example" --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" "https://gitlab.example.com/api/v4/projects/5/pages/domains" 
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "domain=ssl.domain.example" --form "auto_ssl_enabled=true" "https://gitlab.example.com/api/v4/projects/5/pages/domains" 
{  "domain":  "ssl.domain.example",  "url":  "https://ssl.domain.example",  "auto_ssl_enabled":  true,  "certificate":  {  "subject":  "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",  "expired":  false,  "certificate":  "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",  "certificate_text":  "Certificate:\n … \n"  }  } 

Update pages domain

更新现有的项目页面域. 用户必须具有更改现有页面域的权限.

PUT /projects/:id/pages/domains/:domain 
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
domain string yes 用户指定的自定义域
auto_ssl_enabled boolean no 启用自动生成由 Let's Encrypt 为自定义域颁发的 SSL 证书的功能.
certificate file/string no PEM 格式的证书,其中的中间体按照从最高到最低的顺序排列.
key file/string no PEM 格式的证书密钥.

Adding certificate

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example" 
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example" 
{  "domain":  "ssl.domain.example",  "url":  "https://ssl.domain.example",  "auto_ssl_enabled":  false,  "certificate":  {  "subject":  "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate",  "expired":  false,  "certificate":  "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----",  "certificate_text":  "Certificate:\n … \n"  }  } 

Enabling Let’s Encrypt integration for Pages custom domains

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "auto_ssl_enabled=true" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example" 
{  "domain":  "ssl.domain.example",  "url":  "https://ssl.domain.example",  "auto_ssl_enabled":  true  } 

Removing certificate

要删除附加到 Pages 域的 SSL 证书,请运行:

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --form "certificate=" --form "key=" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example" 
{  "domain":  "ssl.domain.example",  "url":  "https://ssl.domain.example",  "auto_ssl_enabled":  false  } 

Delete pages domain

删除现有的项目页面域.

DELETE /projects/:id/pages/domains/:domain 
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
domain string yes 用户指定的自定义域
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example" 
Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2021-03-27 13:48:25

results matching ""

    No results matching ""