自定义属性的 REST API 终结点
使用 REST API 列出组织分配给存储库的自定义属性。
关于自定义属性
您可以使用 REST API 查看由拥有存储库的组织分配给存储库的自定义属性。 有关详细信息,请参阅“管理组织中存储库的自定义属性”。 有关用于管理自定义属性的 REST API 终结点的详细信息,请参阅“自定义属性的 REST API 终结点”。
Get all custom property values for a repository
Gets all custom property values that are set for a repository. Users with read access to the repository can use this endpoint.
“Get all custom property values for a repository”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Metadata" repository permissions (read)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此终结点。
“Get all custom property values for a repository”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
owner string 必须The account owner of the repository. The name is not case sensitive. |
repo string 必须The name of the repository without the |
“Get all custom property values for a repository”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
403 | Forbidden |
404 | Resource not found |
“Get all custom property values for a repository”的示例代码
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/properties/values
Response
Create or update custom property values for a repository
Create new or update existing custom property values for a repository.
Using a value of null
for a custom property will remove or 'unset' the property value from the repository.
Repository admins and other users with the repository-level "edit custom property values" fine-grained permission can use this endpoint.
“Create or update custom property values for a repository”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Custom properties" repository permissions (write)
“Create or update custom property values for a repository”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
owner string 必须The account owner of the repository. The name is not case sensitive. |
repo string 必须The name of the repository without the |
名称, 类型, 说明 | |||
---|---|---|---|
properties array of objects 必须A list of custom property names and associated values to apply to the repositories. | |||
Properties of |
名称, 类型, 说明 |
---|
property_name string 必须The name of the property |
value null or string or array 必须The value assigned to the property |
“Create or update custom property values for a repository”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
204 | No Content when custom property values are successfully created or updated |
403 | Forbidden |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
“Create or update custom property values for a repository”的示例代码
请求示例
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/properties/values \
-d '{"properties":[{"property_name":"environment","value":"production"},{"property_name":"service","value":"web"},{"property_name":"team","value":"octocat"}]}'
No Content when custom property values are successfully created or updated
Status: 204