pre-receive 環境用の REST API エンドポイント
この REST API を使って、pre-receive フックの環境を作成、一覧表示、更新、削除します。
pre-receive 環境について
これらのエンドポイントは、認証されたサイト管理者のみが使用できます。 通常のユーザーは 404 応答を受け取ります。
メモ
これらのエンドポイントでは、personal access token (classic) を使う認証のみがサポートされます。 詳しくは、「個人用アクセス トークンを管理する」をご覧ください。
オブジェクトの属性
pre-receive 環境
| 名前 | Type | 説明 | 
|---|---|---|
name | string | UI に表示される環境の名前。 | 
image_url | string | ダウンロードおよび抽出される tarball への URL。 | 
default_environment | boolean | これが GitHub に同梱される既定の環境かどうか。 | 
download | object | この環境のダウンロードステータス。 | 
hooks_count | integer | この環境を使用する pre-receive フックの数。 | 
pre-receive 環境のダウンロード
| 名前 | Type | 説明 | 
|---|---|---|
state | string | 最新のダウンロードの状態。 | 
downloaded_at | string | 最新のダウンロードの開始時刻。 | 
message | string | 失敗時に、エラーメッセージが生成されます。 | 
state で有効な値は、not_started、in_progress、success、failed です。
List pre-receive environments
"List pre-receive environments" のきめ細かいアクセス トークン
このエンドポイントは、GitHub アプリのユーザー アクセス トークン、GitHub アプリのインストール アクセス トークン、またはきめ細かい個人用アクセス トークンでは機能しません。
"List pre-receive environments" のパラメーター
| 名前, Type, 説明 | 
|---|
accept string Setting to   | 
| 名前, Type, 説明 | 
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default:   | 
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default:   | 
direction string The direction to sort the results by. Default:  次のいずれかにできます:   | 
sort string Default:  次のいずれかにできます:   | 
"List pre-receive environments" の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
200 | OK  | 
"List pre-receive environments" のコード サンプル
要求の例
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/admin/pre-receive-environmentsResponse
Status: 200[
  {
    "id": 1,
    "name": "Default",
    "image_url": "githubenterprise://internal",
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1",
    "html_url": "https://github.example.com/admin/pre-receive-environments/1",
    "default_environment": true,
    "created_at": "2016-05-20T11:35:45-05:00",
    "hooks_count": 14,
    "download": {
      "url": "https://github.example.com/api/v3/admin/pre-receive-environments/1/downloads/latest",
      "state": "not_started",
      "downloaded_at": "2016-05-26T07:42:53-05:00",
      "message": null
    }
  },
  {
    "id": 2,
    "name": "DevTools Hook Env",
    "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
    "html_url": "https://github.example.com/admin/pre-receive-environments/2",
    "default_environment": false,
    "created_at": "2016-05-20T11:35:45-05:00",
    "hooks_count": 1,
    "download": {
      "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
      "state": "success",
      "downloaded_at": "2016-05-26T07:42:53-05:00",
      "message": null
    }
  }
]Create a pre-receive environment
"Create a pre-receive environment" のきめ細かいアクセス トークン
このエンドポイントは、GitHub アプリのユーザー アクセス トークン、GitHub アプリのインストール アクセス トークン、またはきめ細かい個人用アクセス トークンでは機能しません。
"Create a pre-receive environment" のパラメーター
| 名前, Type, 説明 | 
|---|
accept string Setting to   | 
| 名前, Type, 説明 | 
|---|
name string 必須The new pre-receive environment's name.  | 
image_url string 必須URL from which to download a tarball of this environment.  | 
"Create a pre-receive environment" の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
201 | Created  | 
"Create a pre-receive environment" のコード サンプル
要求の例
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/admin/pre-receive-environments \
  -d '{"name":"DevTools Hook Env","image_url":"https://my_file_server/path/to/devtools_env.tar.gz"}'Response
Status: 201{
  "id": 2,
  "name": "DevTools Hook Env",
  "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
  "html_url": "https://github.example.com/admin/pre-receive-environments/2",
  "default_environment": false,
  "created_at": "2016-05-20T11:35:45-05:00",
  "hooks_count": 1,
  "download": {
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
    "state": "not_started",
    "downloaded_at": null,
    "message": null
  }
}Get a pre-receive environment
"Get a pre-receive environment" のきめ細かいアクセス トークン
このエンドポイントは、GitHub アプリのユーザー アクセス トークン、GitHub アプリのインストール アクセス トークン、またはきめ細かい個人用アクセス トークンでは機能しません。
"Get a pre-receive environment" のパラメーター
| 名前, Type, 説明 | 
|---|
accept string Setting to   | 
| 名前, Type, 説明 | 
|---|
pre_receive_environment_id integer 必須The unique identifier of the pre-receive environment.  | 
"Get a pre-receive environment" の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
200 | OK  | 
"Get a pre-receive environment" のコード サンプル
要求の例
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/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_IDResponse
Status: 200{
  "id": 2,
  "name": "DevTools Hook Env",
  "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
  "html_url": "https://github.example.com/admin/pre-receive-environments/2",
  "default_environment": false,
  "created_at": "2016-05-20T11:35:45-05:00",
  "hooks_count": 1,
  "download": {
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
    "state": "not_started",
    "downloaded_at": null,
    "message": null
  }
}Update a pre-receive environment
You cannot modify the default environment. If you attempt to modify the default environment, you will receive a 422 Unprocessable Entity response.
"Update a pre-receive environment" のきめ細かいアクセス トークン
このエンドポイントは、GitHub アプリのユーザー アクセス トークン、GitHub アプリのインストール アクセス トークン、またはきめ細かい個人用アクセス トークンでは機能しません。
"Update a pre-receive environment" のパラメーター
| 名前, Type, 説明 | 
|---|
accept string Setting to   | 
| 名前, Type, 説明 | 
|---|
pre_receive_environment_id integer 必須The unique identifier of the pre-receive environment.  | 
| 名前, Type, 説明 | 
|---|
name string This pre-receive environment's new name.  | 
image_url string URL from which to download a tarball of this environment.  | 
"Update a pre-receive environment" の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
200 | OK  | 
422 | Client Errors  | 
"Update a pre-receive environment" のコード サンプル
要求の例
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/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID \
  -d '{"name":"DevTools Hook Env","image_url":"https://my_file_server/path/to/devtools_env.tar.gz"}'Response
Status: 200{
  "id": 2,
  "name": "DevTools Hook Env",
  "image_url": "https://my_file_server/path/to/devtools_env.tar.gz",
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2",
  "html_url": "https://github.example.com/admin/pre-receive-environments/2",
  "default_environment": false,
  "created_at": "2016-05-20T11:35:45-05:00",
  "hooks_count": 1,
  "download": {
    "url": "https://github.example.com/api/v3/admin/pre-receive-environments/2/downloads/latest",
    "state": "success",
    "downloaded_at": "2016-05-26T07:42:53-05:00",
    "message": null
  }
}Delete a pre-receive environment
If you attempt to delete an environment that cannot be deleted, you will receive a 422 Unprocessable Entity response.
The possible error messages are:
- Cannot modify or delete the default environment
 - Cannot delete environment that has hooks
 - Cannot delete environment when download is in progress
 
"Delete a pre-receive environment" のきめ細かいアクセス トークン
このエンドポイントは、GitHub アプリのユーザー アクセス トークン、GitHub アプリのインストール アクセス トークン、またはきめ細かい個人用アクセス トークンでは機能しません。
"Delete a pre-receive environment" のパラメーター
| 名前, Type, 説明 | 
|---|
accept string Setting to   | 
| 名前, Type, 説明 | 
|---|
pre_receive_environment_id integer 必須The unique identifier of the pre-receive environment.  | 
"Delete a pre-receive environment" の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
204 | No Content  | 
422 | Client Errors  | 
"Delete a pre-receive environment" のコード サンプル
要求の例
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/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_IDResponse
Status: 204Start a pre-receive environment download
Triggers a new download of the environment tarball from the environment's image_url. When the download is finished, the newly downloaded tarball will overwrite the existing environment.
If a download cannot be triggered, you will receive a 422 Unprocessable Entity response.
The possible error messages are:
- Cannot modify or delete the default environment
 - Can not start a new download when a download is in progress
 
"Start a pre-receive environment download" のきめ細かいアクセス トークン
このエンドポイントは、GitHub アプリのユーザー アクセス トークン、GitHub アプリのインストール アクセス トークン、またはきめ細かい個人用アクセス トークンでは機能しません。
"Start a pre-receive environment download" のパラメーター
| 名前, Type, 説明 | 
|---|
accept string Setting to   | 
| 名前, Type, 説明 | 
|---|
pre_receive_environment_id integer 必須The unique identifier of the pre-receive environment.  | 
"Start a pre-receive environment download" の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
202 | Accepted  | 
422 | Client Errors  | 
"Start a pre-receive environment download" のコード サンプル
要求の例
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/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloadsResponse
Status: 202{
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest",
  "state": "not_started",
  "downloaded_at": null,
  "message": null
}Get the download status for a pre-receive environment
In addition to seeing the download status at the "Get a pre-receive environment" endpoint, there is also this separate endpoint for just the download status.
"Get the download status for a pre-receive environment" のきめ細かいアクセス トークン
このエンドポイントは、GitHub アプリのユーザー アクセス トークン、GitHub アプリのインストール アクセス トークン、またはきめ細かい個人用アクセス トークンでは機能しません。
"Get the download status for a pre-receive environment" のパラメーター
| 名前, Type, 説明 | 
|---|
accept string Setting to   | 
| 名前, Type, 説明 | 
|---|
pre_receive_environment_id integer 必須The unique identifier of the pre-receive environment.  | 
"Get the download status for a pre-receive environment" の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
200 | OK  | 
"Get the download status for a pre-receive environment" のコード サンプル
要求の例
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/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads/latestResponse
Status: 200{
  "url": "https://github.example.com/api/v3/admin/pre-receive-environments/3/downloads/latest",
  "state": "success",
  "downloaded_at": "2016-05-26T07:42:53-05:00",
  "message": null
}