Puntos de conexión de la API de REST para reglas de protección
Use la API REST para crear, configurar y eliminar reglas de protección de implementación.
Get all deployment protection rules for an environment
Gets all custom deployment protection rules that are enabled for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "Using environments for deployment."
For more information about the app that is providing this custom deployment rule, see the documentation for the GET /apps/{app_slug}
endpoint.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Tokens de acceso específicos para "Get all deployment protection rules for an environment"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- Tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
- Tokens de acceso personal específico
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Actions" repository permissions (read)
Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.
Parámetros para "Get all deployment protection rules for an environment"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string RequeridoThe name of the repository without the |
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
Códigos de estado de respuesta HTTP para "Get all deployment protection rules for an environment"
status code | Descripción |
---|---|
200 | List of deployment protection rules |
Ejemplos de código para "Get all deployment protection rules for an environment"
Ejemplo de solicitud
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/environments/ENVIRONMENT_NAME/deployment_protection_rules
List of deployment protection rules
Status: 200
{
"total_count": 2,
"custom_deployment_protection_rules": [
{
"id": 3,
"node_id": "IEH37kRlcGxveW1lbnRTdGF0ddiv",
"enabled": true,
"app": {
"id": 1,
"node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy",
"slug": "a-custom-app",
"integration_url": "https://HOSTNAME/apps/a-custom-app"
}
},
{
"id": 4,
"node_id": "MDE2OkRlcGxveW1lbnRTdHJ41128",
"enabled": true,
"app": {
"id": 1,
"node_id": "UHVE67RlcGxveW1lbnRTdTY!jfeuy",
"slug": "another-custom-app",
"integration_url": "https://HOSTNAME/apps/another-custom-app"
}
}
]
}
Create a custom deployment protection rule on an environment
Enable a custom deployment protection rule for an environment.
The authenticated user must have admin or owner permissions to the repository to use this endpoint.
For more information about the app that is providing this custom deployment rule, see the documentation for the GET /apps/{app_slug}
endpoint.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Tokens de acceso específicos para "Create a custom deployment protection rule on an environment"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- Tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
- Tokens de acceso personal específico
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Administration" repository permissions (write)
Parámetros para "Create a custom deployment protection rule on an environment"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string RequeridoThe name of the repository without the |
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
Nombre, Tipo, Descripción |
---|
integration_id integer The ID of the custom app that will be enabled on the environment. |
Códigos de estado de respuesta HTTP para "Create a custom deployment protection rule on an environment"
status code | Descripción |
---|---|
201 | The enabled custom deployment protection rule |
Ejemplos de código para "Create a custom deployment protection rule on an environment"
Ejemplo de solicitud
curl -L \
-X POST \
-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/environments/ENVIRONMENT_NAME/deployment_protection_rules \
-d '{"integration_id":5}'
The enabled custom deployment protection rule
Status: 201
{
"id": 3,
"node_id": "IEH37kRlcGxveW1lbnRTdGF0ddiv",
"enabled": true,
"app": {
"id": 1,
"node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy",
"slug": "a-custom-app",
"integration_url": "https://HOSTNAME/apps/a-custom-app"
}
}
List custom deployment rule integrations available for an environment
Gets all custom deployment protection rule integrations that are available for an environment.
The authenticated user must have admin or owner permissions to the repository to use this endpoint.
For more information about environments, see "Using environments for deployment."
For more information about the app that is providing this custom deployment rule, see "GET an app".
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Tokens de acceso específicos para "List custom deployment rule integrations available for an environment"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- Tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
- Tokens de acceso personal específico
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Administration" repository permissions (read)
Parámetros para "List custom deployment rule integrations available for an environment"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string RequeridoThe name of the repository without the |
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
Nombre, Tipo, Descripción |
---|
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Valor predeterminado: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Valor predeterminado: |
Códigos de estado de respuesta HTTP para "List custom deployment rule integrations available for an environment"
status code | Descripción |
---|---|
200 | A list of custom deployment rule integrations available for this environment. |
Ejemplos de código para "List custom deployment rule integrations available for an environment"
Ejemplo de solicitud
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/environments/ENVIRONMENT_NAME/deployment_protection_rules/apps
A list of custom deployment rule integrations available for this environment.
Status: 200
[
{
"total_count": 2
},
{
"available_custom_deployment_protection_rule_integrations": [
{
"id": 1,
"node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy",
"slug": "a-custom-app",
"integration_url": "https://HOSTNAME/apps/a-custom-app"
},
{
"id": 2,
"node_id": "UHVE67RlcGxveW1lbnRTdTY!jfeuy",
"slug": "another-custom-app",
"integration_url": "https://HOSTNAME/apps/another-custom-app"
}
]
}
]
Get a custom deployment protection rule
Gets an enabled custom deployment protection rule for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "Using environments for deployment."
For more information about the app that is providing this custom deployment rule, see GET /apps/{app_slug}
.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint with a private repository.
Tokens de acceso específicos para "Get a custom deployment protection rule"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- Tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
- Tokens de acceso personal específico
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Actions" repository permissions (read)
Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.
Parámetros para "Get a custom deployment protection rule"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
protection_rule_id integer RequeridoThe unique identifier of the protection rule. |
Códigos de estado de respuesta HTTP para "Get a custom deployment protection rule"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Get a custom deployment protection rule"
Ejemplo de solicitud
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/environments/ENVIRONMENT_NAME/deployment_protection_rules/PROTECTION_RULE_ID
Response
Status: 200
{
"id": 3,
"node_id": "IEH37kRlcGxveW1lbnRTdGF0ddiv",
"enabled": true,
"app": {
"id": 1,
"node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy",
"slug": "a-custom-app",
"integration_url": "https://HOSTNAME/apps/a-custom-app"
}
}
Disable a custom protection rule for an environment
Disables a custom deployment protection rule for an environment.
The authenticated user must have admin or owner permissions to the repository to use this endpoint.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint.
Tokens de acceso específicos para "Disable a custom protection rule for an environment"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- Tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
- Tokens de acceso personal específico
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Administration" repository permissions (write)
Parámetros para "Disable a custom protection rule for an environment"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
environment_name string RequeridoThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string RequeridoThe name of the repository without the |
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
protection_rule_id integer RequeridoThe unique identifier of the protection rule. |
Códigos de estado de respuesta HTTP para "Disable a custom protection rule for an environment"
status code | Descripción |
---|---|
204 | No Content |
Ejemplos de código para "Disable a custom protection rule for an environment"
Ejemplo de solicitud
curl -L \
-X DELETE \
-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/environments/ENVIRONMENT_NAME/deployment_protection_rules/PROTECTION_RULE_ID
Response
Status: 204