{"meta":{"title":"사전 수신 환경에 대한 REST API 엔드포인트","intro":"REST API를 사용하면 사전 수신 후크에 대한 환경을 만들고, 나열하고, 업데이트하고, 삭제할 수 있습니다.","product":"REST API","breadcrumbs":[{"href":"/ko/enterprise-server@3.17/rest","title":"REST API"},{"href":"/ko/enterprise-server@3.17/rest/enterprise-admin","title":"기업 관리자"},{"href":"/ko/enterprise-server@3.17/rest/enterprise-admin/pre-receive-environments","title":"사전 수신 환경"}],"documentType":"article"},"body":"# 사전 수신 환경에 대한 REST API 엔드포인트\n\nREST API를 사용하면 사전 수신 후크에 대한 환경을 만들고, 나열하고, 업데이트하고, 삭제할 수 있습니다.\n\n## 사전 수신 환경에 대하여\n\n이러한 엔드포인트는 [인증된](/ko/enterprise-server@3.17/rest/authentication/authenticating-to-the-rest-api) 사이트 관리자만 사용할 수 있습니다. 일반 사용자는 `404` 응답을 받게 됩니다.\n\n> \\[!NOTE]\n> 이러한 엔드포인트는 personal access token (classic)을(를) 사용하는 인증만 지원합니다. 자세한 내용은 [개인용 액세스 토큰 관리](/ko/enterprise-server@3.17/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)을(를) 참조하세요.\n\n### 개체 특성\n\n#### 사전 수신 환경\n\n| 이름                             | 형식        | 설명                          |\n| ------------------------------ | --------- | --------------------------- |\n| `name`                         | `string`  | UI에 표시되는 환경 이름입니다.          |\n| `image_url`                    | `string`  | 다운로드하고 추출할 tarball의 URL입니다. |\n| `default_environment`          | `boolean` |                             |\n| GitHub와 함께 제공되는 기본 환경인지 여부입니다. |           |                             |\n| `download`                     | `object`  | 이 환경의 다운로드 상태입니다.           |\n| `hooks_count`                  | `integer` | 이 환경을 사용하는 사전 수신 후크 수입니다.   |\n\n#### 사전 수신 환경 다운로드\n\n| 이름              | 형식       | 설명                     |\n| --------------- | -------- | ---------------------- |\n| `state`         | `string` | 가장 최근 다운로드의 상태입니다.     |\n| `downloaded_at` | `string` | 가장 최근 다운로드가 시작된 시간입니다. |\n| `message`       | `string` | 오류 발생 시 생성된 오류 메시지입니다. |\n\n`state`의 가능한 값은 `not_started`, `in_progress`, `success`, `failed`입니다.\n\n> \\[!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2022-11-28`. Curl examples below omit these standard headers for brevity.\n\n## List pre-receive environments\n\n```\nGET /admin/pre-receive-environments\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n* **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n* **`direction`** (string)\n  The direction to sort the results by.\n  Default: `desc`\n  Can be one of: `asc`, `desc`\n\n* **`sort`** (string)\n  Default: `created`\n  Can be one of: `created`, `updated`, `name`\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments\n```\n\n**Response schema (Status: 200):**\n\nArray of objects:\n\n* `id`: integer, format: int64\n* `name`: string\n* `image_url`: string\n* `url`: string\n* `html_url`: string\n* `default_environment`: boolean\n* `created_at`: string\n* `hooks_count`: integer\n* `download`: object:\n  * `url`: string\n  * `state`: string\n  * `downloaded_at`: string or null\n  * `message`: string or null\n\n## Create a pre-receive environment\n\n```\nPOST /admin/pre-receive-environments\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Body parameters\n\n* **`name`** (string) (required)\n  The new pre-receive environment's name.\n\n* **`image_url`** (string) (required)\n  URL from which to download a tarball of this environment.\n\n### HTTP response status codes\n\n* **201** - Created\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments \\\n  -d '{\n  \"name\": \"DevTools Hook Env\",\n  \"image_url\": \"https://my_file_server/path/to/devtools_env.tar.gz\"\n}'\n```\n\n**Response schema (Status: 201):**\n\n* `id`: integer, format: int64\n* `name`: string\n* `image_url`: string\n* `url`: string\n* `html_url`: string\n* `default_environment`: boolean\n* `created_at`: string\n* `hooks_count`: integer\n* `download`: object:\n  * `url`: string\n  * `state`: string\n  * `downloaded_at`: string or null\n  * `message`: string or null\n\n## Get a pre-receive environment\n\n```\nGET /admin/pre-receive-environments/{pre_receive_environment_id}\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a pre-receive environment](#create-a-pre-receive-environment).\n\n## Update a pre-receive environment\n\n```\nPATCH /admin/pre-receive-environments/{pre_receive_environment_id}\n```\n\nYou cannot modify the default environment. If you attempt to modify the default environment, you will receive a 422 Unprocessable Entity response.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n#### Body parameters\n\n* **`name`** (string)\n  This pre-receive environment's new name.\n\n* **`image_url`** (string)\n  URL from which to download a tarball of this environment.\n\n### HTTP response status codes\n\n* **200** - OK\n\n* **422** - Client Errors\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PATCH \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID \\\n  -d '{\n  \"name\": \"DevTools Hook Env\",\n  \"image_url\": \"https://my_file_server/path/to/devtools_env.tar.gz\"\n}'\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a pre-receive environment](#create-a-pre-receive-environment).\n\n## Delete a pre-receive environment\n\n```\nDELETE /admin/pre-receive-environments/{pre_receive_environment_id}\n```\n\nIf you attempt to delete an environment that cannot be deleted, you will receive a 422 Unprocessable Entity response.\nThe possible error messages are:\n\nCannot modify or delete the default environment\nCannot delete environment that has hooks\nCannot delete environment when download is in progress\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **204** - No Content\n\n* **422** - Client Errors\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID\n```\n\n**Response schema (Status: 204):**\n\n## Start a pre-receive environment download\n\n```\nPOST /admin/pre-receive-environments/{pre_receive_environment_id}/downloads\n```\n\nTriggers 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.\nIf a download cannot be triggered, you will receive a 422 Unprocessable Entity response.\nThe possible error messages are:\n\nCannot modify or delete the default environment\nCan not start a new download when a download is in progress\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **202** - Accepted\n\n* **422** - Client Errors\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads\n```\n\n**Response schema (Status: 202):**\n\n* `url`: string\n* `state`: string\n* `downloaded_at`: string or null\n* `message`: string or null\n\n## Get the download status for a pre-receive environment\n\n```\nGET /admin/pre-receive-environments/{pre_receive_environment_id}/downloads/latest\n```\n\nIn 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.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`pre_receive_environment_id`** (integer) (required)\n  The unique identifier of the pre-receive environment.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/admin/pre-receive-environments/PRE_RECEIVE_ENVIRONMENT_ID/downloads/latest\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Start a pre-receive environment download](#start-a-pre-receive-environment-download)."}