Skip to main content
REST API 现已开始进行版本化。 有关详细信息,请参阅“关于 API 版本控制”。

用于企业网络配置的 REST API 终结点

使用 REST API 与企业网络配置交互。

List hosted compute network configurations for an enterprise

Lists all hosted compute network configurations configured in an enterprise.

“List hosted compute network configurations for an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”List hosted compute network configurations for an enterprise 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

查询参数
名称, 类型, 说明
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

默认: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

默认: 1

“List hosted compute network configurations for an enterprise”的 HTTP 响应状态代码

状态代码说明
200

OK

“List hosted compute network configurations for an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

get/enterprises/{enterprise}/network-configurations
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/network-configurations

Response

Status: 200
{ "total_count": 2, "network_configurations": [ { "id": "123456789ABCDEF", "name": "My network configuration", "compute_service": "actions", "network_settings_ids": [ "23456789ABDCEF1", "3456789ABDCEF12" ], "created_on": "2022-10-09T23:39:01Z" }, { "id": "456789ABDCEF123", "name": "My other configuration", "compute_service": "none", "network_settings_ids": [ "56789ABDCEF1234", "6789ABDCEF12345" ], "created_on": "2023-04-26T15:23:37Z" } ] }

Create a hosted compute network configuration for an enterprise

Creates a hosted compute network configuration for an enterprise.

“Create a hosted compute network configuration for an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Create a hosted compute network configuration for an enterprise 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

主体参数
名称, 类型, 说明
name string 必须

Name of the network configuration. Must be between 1 and 100 characters and may only contain upper and lowercase letters a-z, numbers 0-9, ., -, and _.

compute_service string

The hosted compute service to use for the network configuration.

可以是以下选项之一: none, actions

network_settings_ids array of strings 必须

A list of identifiers of the network settings resources to use for the network configuration. Exactly one resource identifier must be specified in the list.

failover_network_settings_ids array of strings

A list of identifiers of the failover network settings resources to use for the network configuration. Exactly one resource identifier must be specified in the list.

failover_network_enabled boolean

Indicates whether the failover network resource is enabled.

“Create a hosted compute network configuration for an enterprise”的 HTTP 响应状态代码

状态代码说明
201

Created

“Create a hosted compute network configuration for an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

post/enterprises/{enterprise}/network-configurations
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/network-configurations \ -d '{"name":"my-network-configuration","network_settings_ids":["23456789ABDCEF1"],"compute_service":"actions"}'

Response

Status: 201
{ "id": "123456789ABCDEF", "name": "My network configuration", "compute_service": "actions", "network_settings_ids": [ "23456789ABDCEF1", "3456789ABDCEF12" ], "created_on": "2022-10-09T23:39:01Z" }

Get a hosted compute network configuration for an enterprise

Gets a hosted compute network configuration configured in an enterprise.

“Get a hosted compute network configuration for an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Get a hosted compute network configuration for an enterprise 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

network_configuration_id string 必须

Unique identifier of the hosted compute network configuration.

“Get a hosted compute network configuration for an enterprise”的 HTTP 响应状态代码

状态代码说明
200

OK

“Get a hosted compute network configuration for an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

get/enterprises/{enterprise}/network-configurations/{network_configuration_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/network-configurations/NETWORK_CONFIGURATION_ID

Response

Status: 200
{ "id": "123456789ABCDEF", "name": "My network configuration", "compute_service": "actions", "network_settings_ids": [ "23456789ABDCEF1", "3456789ABDCEF12" ], "created_on": "2022-10-09T23:39:01Z" }

Update a hosted compute network configuration for an enterprise

Updates a hosted compute network configuration for an enterprise.

“Update a hosted compute network configuration for an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Update a hosted compute network configuration for an enterprise 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

network_configuration_id string 必须

Unique identifier of the hosted compute network configuration.

主体参数
名称, 类型, 说明
name string

Name of the network configuration. Must be between 1 and 100 characters and may only contain upper and lowercase letters a-z, numbers 0-9, ., -, and _.

compute_service string

The hosted compute service to use for the network configuration.

可以是以下选项之一: none, actions

network_settings_ids array of strings

A list of identifiers of the network settings resources to use for the network configuration. Exactly one resource identifier must be specified in the list.

failover_network_settings_ids array of strings

A list of identifiers of the failover network settings resources to use for the network configuration. Exactly one resource identifier must be specified in the list.

failover_network_enabled boolean

Indicates whether the failover network resource is enabled.

“Update a hosted compute network configuration for an enterprise”的 HTTP 响应状态代码

状态代码说明
200

OK

“Update a hosted compute network configuration for an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

patch/enterprises/{enterprise}/network-configurations/{network_configuration_id}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/network-configurations/NETWORK_CONFIGURATION_ID \ -d '{"name":"my-network-configuration","network_settings_ids":["23456789ABDCEF1"],"compute_service":"actions"}'

Response

Status: 200
{ "id": "123456789ABCDEF", "name": "My network configuration", "compute_service": "actions", "network_settings_ids": [ "23456789ABDCEF1", "3456789ABDCEF12" ], "created_on": "2022-10-09T23:39:01Z" }

Delete a hosted compute network configuration from an enterprise

Deletes a hosted compute network configuration from an enterprise.

“Delete a hosted compute network configuration from an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Delete a hosted compute network configuration from an enterprise 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

network_configuration_id string 必须

Unique identifier of the hosted compute network configuration.

“Delete a hosted compute network configuration from an enterprise”的 HTTP 响应状态代码

状态代码说明
204

No Content

“Delete a hosted compute network configuration from an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

delete/enterprises/{enterprise}/network-configurations/{network_configuration_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/network-configurations/NETWORK_CONFIGURATION_ID

Response

Status: 204

Get a hosted compute network settings resource for an enterprise

Gets a hosted compute network settings resource configured for an enterprise.

“Get a hosted compute network settings resource for an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Get a hosted compute network settings resource for an enterprise 的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

network_settings_id string 必须

Unique identifier of the hosted compute network settings.

“Get a hosted compute network settings resource for an enterprise”的 HTTP 响应状态代码

状态代码说明
200

OK

“Get a hosted compute network settings resource for an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

get/enterprises/{enterprise}/network-settings/{network_settings_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/network-settings/NETWORK_SETTINGS_ID

Response

Status: 200
{ "id": "220F78DACB92BBFBC5E6F22DE1CCF52309D", "network_configuration_id": "934E208B3EE0BD60CF5F752C426BFB53562", "name": "my_network_settings", "subnet_id": "/subscriptions/14839728-3ad9-43ab-bd2b-fa6ad0f75e2a/resourceGroups/my-rg/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/my-subnet", "region": "eastus" }