GET /api/subnets
子网列表

GET /api/domains/:domain_id/subnets
域的子网列表

GET /api/locations/:location_id/subnets
每个位置的子网列表

GET /api/organizations/:organization_id/subnets
每个机构的子网列表

示例

GET /api/subnets
200
{
  "total": 7,
  "subtotal": 7,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "network": "2.3.4.0",
      "network_type": "IPv4",
      "cidr": 24,
      "mask": "255.255.255.0",
      "priority": null,
      "vlanid": 41,
      "mtu": 1500,
      "gateway": null,
      "dns_primary": null,
      "dns_secondary": null,
      "from": null,
      "to": null,
      "created_at": "2019-09-11 14:46:33 UTC",
      "updated_at": "2019-09-11 14:46:33 UTC",
      "ipam": "None",
      "boot_mode": "DHCP",
      "id": 980190962,
      "name": "one",
      "description": null,
      "network_address": "2.3.4.0/24",
      "dhcp_id": 980190962,
      "dhcp_name": "DHCP Proxy",
      "tftp_id": 298486374,
      "tftp_name": "TFTP Proxy",
      "httpboot_id": null,
      "httpboot_name": null,
      "dns_id": 113629430,
      "template_id": null,
      "template_name": null,
      "dhcp": {
        "name": "DHCP Proxy",
        "id": 980190962,
        "url": "https://somewhere.net:8443"
      },
      "tftp": {
        "name": "TFTP Proxy",
        "id": 298486374,
        "url": "http://somewhere.else"
      },
      "httpboot": null,
      "dns": {
        "name": "DNS Proxy",
        "id": 113629430,
        "url": "http://else.where:45671"
      },
      "template": null
    },
    {
      "network": "3.3.4.0",
      "network_type": "IPv4",
      "cidr": 24,
      "mask": "255.255.255.0",
      "priority": null,
      "vlanid": 42,
      "mtu": 1496,
      "gateway": null,
      "dns_primary": null,
      "dns_secondary": null,
      "from": null,
      "to": null,
      "created_at": "2019-09-11 14:46:33 UTC",
      "updated_at": "2019-09-11 14:46:33 UTC",
      "ipam": "None",
      "boot_mode": "DHCP",
      "id": 298486374,
      "name": "two",
      "description": null,
      "network_address": "3.3.4.0/24",
      "dhcp_id": 980190962,
      "dhcp_name": "DHCP Proxy",
      "tftp_id": 298486374,
      "tftp_name": "TFTP Proxy",
      "httpboot_id": null,
      "httpboot_name": null,
      "dns_id": null,
      "template_id": null,
      "template_name": null,
      "dhcp": {
        "name": "DHCP Proxy",
        "id": 980190962,
        "url": "https://somewhere.net:8443"
      },
      "tftp": {
        "name": "TFTP Proxy",
        "id": 298486374,
        "url": "http://somewhere.else"
      },
      "httpboot": null,
      "dns": null,
      "template": null
    },
    {
      "network": "3.3.4.3",
      "network_type": "IPv4",
      "cidr": 24,
      "mask": "255.255.255.0",
      "priority": null,
      "vlanid": 43,
      "mtu": 1500,
      "gateway": null,
      "dns_primary": null,
      "dns_secondary": null,
      "from": null,
      "to": null,
      "created_at": "2019-09-11 14:46:33 UTC",
      "updated_at": "2019-09-11 14:46:33 UTC",
      "ipam": "None",
      "boot_mode": "DHCP",
      "id": 113629430,
      "name": "three",
      "description": null,
      "network_address": "3.3.4.3/24",
      "dhcp_id": 980190962,
      "dhcp_name": "DHCP Proxy",
      "tftp_id": 298486374,
      "tftp_name": "TFTP Proxy",
      "httpboot_id": null,
      "httpboot_name": null,
      "dns_id": null,
      "template_id": null,
      "template_name": null,
      "dhcp": {
        "name": "DHCP Proxy",
        "id": 980190962,
        "url": "https://somewhere.net:8443"
      },
      "tftp": {
        "name": "TFTP Proxy",
        "id": 298486374,
        "url": "http://somewhere.else"
      },
      "httpboot": null,
      "dns": null,
      "template": null
    },
    {
      "network": "3.3.5.0",
      "network_type": "IPv4",
      "cidr": 24,
      "mask": "255.255.255.0",
      "priority": null,
      "vlanid": 44,
      "mtu": 9000,
      "gateway": null,
      "dns_primary": null,
      "dns_secondary": null,
      "from": null,
      "to": null,
      "created_at": "2019-09-11 14:46:33 UTC",
      "updated_at": "2019-09-11 14:46:33 UTC",
      "ipam": "None",
      "boot_mode": "DHCP",
      "id": 281110143,
      "name": "four",
      "description": null,
      "network_address": "3.3.5.0/24",
      "dhcp_id": null,
      "dhcp_name": null,
      "tftp_id": 298486374,
      "tftp_name": "TFTP Proxy",
      "httpboot_id": null,
      "httpboot_name": null,
      "dns_id": null,
      "template_id": null,
      "template_name": null,
      "dhcp": null,
      "tftp": {
        "name": "TFTP Proxy",
        "id": 298486374,
        "url": "http://somewhere.else"
      },
      "httpboot": null,
      "dns": null,
      "template": null
    },
    {
      "network": "2001:db10:7::",
      "network_type": "IPv6",
      "cidr": 64,
      "mask": "ffff:ffff:ffff:ffff::",
      "priority": null,
      "vlanid": 44,
      "mtu": 9000,
      "gateway": null,
      "dns_primary": null,
      "dns_secondary": null,
      "from": null,
      "to": null,
      "created_at": "2019-09-11 14:46:33 UTC",
      "updated_at": "2019-09-11 14:46:33 UTC",
      "ipam": "None",
      "boot_mode": "DHCP",
      "id": 374648174,
      "name": "seven",
      "description": null,
      "network_address": "2001:db10:7::/64",
      "dhcp_id": null,
      "dhcp_name": null,
      "tftp_id": null,
      "tftp_name": null,
      "httpboot_id": null,
      "httpboot_name": null,
      "dns_id": 113629430,
      "template_id": null,
      "template_name": null,
      "dhcp": null,
      "tftp": null,
      "httpboot": null,
      "dns": {
        "name": "DNS Proxy",
        "id": 113629430,
        "url": "http://else.where:45671"
      },
      "template": null
    },
    {
      "network": "2001:db10::",
      "network_type": "IPv6",
      "cidr": 64,
      "mask": "ffff:ffff:ffff:ffff::",
      "priority": null,
      "vlanid": null,
      "mtu": 1500,
      "gateway": null,
      "dns_primary": null,
      "dns_secondary": null,
      "from": null,
      "to": null,
      "created_at": "2019-09-11 14:46:33 UTC",
      "updated_at": "2019-09-11 14:46:33 UTC",
      "ipam": "None",
      "boot_mode": "DHCP",
      "id": 51848956,
      "name": "six",
      "description": null,
      "network_address": "2001:db10::/64",
      "dhcp_id": null,
      "dhcp_name": null,
      "tftp_id": null,
      "tftp_name": null,
      "httpboot_id": null,
      "httpboot_name": null,
      "dns_id": 113629430,
      "template_id": null,
      "template_name": null,
      "dhcp": null,
      "tftp": null,
      "httpboot": null,
      "dns": {
        "name": "DNS Proxy",
        "id": 113629430,
        "url": "http://else.where:45671"
      },
      "template": null
    },
    {
      "network": "10.0.0.0",
      "network_type": "IPv4",
      "cidr": 24,
      "mask": "255.255.255.0",
      "priority": null,
      "vlanid": null,
      "mtu": 1500,
      "gateway": null,
      "dns_primary": null,
      "dns_secondary": null,
      "from": null,
      "to": null,
      "created_at": "2019-09-11 14:46:33 UTC",
      "updated_at": "2019-09-11 14:46:33 UTC",
      "ipam": "None",
      "boot_mode": "DHCP",
      "id": 1018350795,
      "name": "five",
      "description": null,
      "network_address": "10.0.0.0/24",
      "dhcp_id": 980190962,
      "dhcp_name": "DHCP Proxy",
      "tftp_id": 298486374,
      "tftp_name": "TFTP Proxy",
      "httpboot_id": null,
      "httpboot_name": null,
      "dns_id": 113629430,
      "template_id": null,
      "template_name": null,
      "dhcp": {
        "name": "DHCP Proxy",
        "id": 980190962,
        "url": "https://somewhere.net:8443"
      },
      "tftp": {
        "name": "TFTP Proxy",
        "id": 298486374,
        "url": "http://somewhere.else"
      },
      "httpboot": null,
      "dns": {
        "name": "DNS Proxy",
        "id": 113629430,
        "url": "http://else.where:45671"
      },
      "template": null
    }
  ]
}

参数

参数名字 描述
domain_id
选填

域 ID

Validations:

  • Must be a String

location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

search
选填

过滤结果

Validations:

  • Must be a String

order
选填

排序项和顺序,例如 ‘id DESC’

Validations:

  • Must be a String

page
选填

页号,从 1 开始

Validations:

  • Must be a number.

per_page
选填

每页中显示的返回结果数

Validations:

  • Must be a number.

搜索字段

字段名 类型 可能的值
boot_mode string
dns_primary string
dns_secondary string
domain string
gateway string
ipam string
location string
location_id integer
mask string
mtu integer
name text
network string
organization string
organization_id integer
params text
type string
vlanid integer

GET /api/subnets/:id
显示子网

示例

GET /api/subnets/1018350796-subnet237
200
{
  "network": "25.231.160.0",
  "network_type": "IPv4",
  "cidr": 24,
  "mask": "255.255.255.0",
  "priority": null,
  "vlanid": null,
  "mtu": 1500,
  "gateway": null,
  "dns_primary": null,
  "dns_secondary": null,
  "from": null,
  "to": null,
  "created_at": "2019-09-11 14:46:33 UTC",
  "updated_at": "2019-09-11 14:46:33 UTC",
  "ipam": "None",
  "boot_mode": "DHCP",
  "id": 1018350796,
  "name": "subnet237",
  "description": null,
  "network_address": "25.231.160.0/24",
  "dhcp_id": null,
  "dhcp_name": null,
  "tftp_id": null,
  "tftp_name": null,
  "httpboot_id": null,
  "httpboot_name": null,
  "dns_id": null,
  "template_id": null,
  "template_name": null,
  "dhcp": null,
  "tftp": null,
  "httpboot": null,
  "dns": null,
  "template": null,
  "domains": [],
  "interfaces": [],
  "parameters": [],
  "locations": [
    {
      "id": 255093256,
      "name": "Location 1",
      "title": "Location 1",
      "description": null
    }
  ],
  "organizations": [
    {
      "id": 447626438,
      "name": "Organization 1",
      "title": "Organization 1",
      "description": null
    }
  ]
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

show_hidden_parameters
选填

显示隐藏的参数值

Validations:

  • Must be one of: true, false, 1, 0.


POST /api/subnets
创建子网

示例

POST /api/subnets
{
  "subnet": {
    "name": "QA2",
    "network_type": "IPv4",
    "network": "10.35.2.27",
    "mask": "255.255.255.0",
    "subnet_parameters_attributes": [
      {
        "name": "foo",
        "value": "bar"
      }
    ]
  }
}
201
{
  "network": "10.35.2.27",
  "network_type": "IPv4",
  "cidr": 24,
  "mask": "255.255.255.0",
  "priority": null,
  "vlanid": null,
  "mtu": 1500,
  "gateway": null,
  "dns_primary": null,
  "dns_secondary": null,
  "from": null,
  "to": null,
  "created_at": "2019-09-11 14:46:34 UTC",
  "updated_at": "2019-09-11 14:46:34 UTC",
  "ipam": "None",
  "boot_mode": "DHCP",
  "id": 1018350798,
  "name": "QA2",
  "description": null,
  "network_address": "10.35.2.27/24",
  "dhcp_id": null,
  "dhcp_name": null,
  "tftp_id": null,
  "tftp_name": null,
  "httpboot_id": null,
  "httpboot_name": null,
  "dns_id": null,
  "template_id": null,
  "template_name": null,
  "dhcp": null,
  "tftp": null,
  "httpboot": null,
  "dns": null,
  "template": null,
  "domains": [],
  "interfaces": [],
  "parameters": [
    {
      "priority": 40,
      "created_at": "2019-09-11 14:46:34 UTC",
      "updated_at": "2019-09-11 14:46:34 UTC",
      "id": 767575241,
      "name": "foo",
      "parameter_type": null,
      "value": "bar"
    }
  ],
  "locations": [],
  "organizations": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

subnet
必填

Validations:

  • Must be a Hash

subnet[name]
必填

子网名

Validations:

  • Must be a String

subnet[description]
选填 , 允许空值

子网描述

Validations:

  • Must be a String

subnet[network_type]
选填 , 允许空值

类型或协议,值为 IPv4 或 IPv6,默认为 IPv4

Validations:

  • Must be one of: IPv4, IPv6.

subnet[network]
必填

子网网络

Validations:

  • Must be a String

subnet[mask]
必填

子网掩码

Validations:

  • Must be a String

subnet[gateway]
选填 , 允许空值

子网网关

Validations:

  • Must be a String

subnet[dns_primary]
选填 , 允许空值

这个子网的主 DNS

Validations:

  • Must be a String

subnet[dns_secondary]
选填 , 允许空值

这个子网的辅 DNS

Validations:

  • Must be a String

subnet[ipam]
选填 , 允许空值

这个子网的 IP 地址自动提示模式,有效值为 “DHCP”、“Internal DB”、“None”。

Validations:

  • Must be a String

subnet[from]
选填 , 允许空值

IP 自动提示的起始 IP 地址

Validations:

  • Must be a String

subnet[to]
选填 , 允许空值

为 IP 自动提示功能提供 IP 地址结尾

Validations:

  • Must be a String

subnet[vlanid]
选填 , 允许空值

这个子网的 VLAN ID

Validations:

  • Must be a String

subnet[mtu]
选填 , 允许空值

这个子网的 MTU

Validations:

  • Must be a Integer

subnet[domain_ids]
选填 , 允许空值

该部分子网的域名

Validations:

  • Must be an array of any type

subnet[dhcp_id]
选填 , 允许空值

要在此子网中使用的 DHCP 代理 ID

Validations:

  • Must be a number.

subnet[tftp_id]
选填 , 允许空值

要在此子网中使用的 TFTP 代理 ID

Validations:

  • Must be a number.

subnet[httpboot_id]
选填 , 允许空值

要在此子网中使用的 HTTPBoot 代理 ID

Validations:

  • Must be a number.

subnet[dns_id]
选填 , 允许空值

要在此子网中使用的 DNS 代理 ID

Validations:

  • Must be a number.

subnet[template_id]
选填 , 允许空值

要在此子网中使用的模板 HTTP 代理服务器 ID

Validations:

  • Must be a number.

subnet[boot_mode]
选填 , 允许空值

分配给这个子网接口的默认引导模式,有效值为 “Static”,“DHCP”。

Validations:

  • Must be a String

subnet[subnet_parameters_attributes]
选填 , 允许空值

参数阵列(name,value)

Validations:

  • Must be an array of any type

subnet[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

subnet[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


PUT /api/subnets/:id
更新子网

示例

PUT /api/subnets/1018350799
{
  "subnet": {
    "subnet_parameters_attributes": [
      {
        "name": "new_key",
        "value": "new_value"
      }
    ]
  }
}
200
{
  "network": "6.79.236.0",
  "network_type": "IPv4",
  "cidr": 24,
  "mask": "255.255.255.0",
  "priority": null,
  "vlanid": null,
  "mtu": 1500,
  "gateway": null,
  "dns_primary": null,
  "dns_secondary": null,
  "from": null,
  "to": null,
  "created_at": "2019-09-11 14:46:34 UTC",
  "updated_at": "2019-09-11 14:46:34 UTC",
  "ipam": "None",
  "boot_mode": "DHCP",
  "id": 1018350799,
  "name": "subnet239",
  "description": null,
  "network_address": "6.79.236.0/24",
  "dhcp_id": null,
  "dhcp_name": null,
  "tftp_id": null,
  "tftp_name": null,
  "httpboot_id": null,
  "httpboot_name": null,
  "dns_id": null,
  "template_id": null,
  "template_name": null,
  "dhcp": null,
  "tftp": null,
  "httpboot": null,
  "dns": null,
  "template": null,
  "domains": [],
  "interfaces": [],
  "parameters": [
    {
      "priority": 40,
      "created_at": "2019-09-11 14:46:34 UTC",
      "updated_at": "2019-09-11 14:46:34 UTC",
      "id": 767575243,
      "name": "new_key",
      "parameter_type": null,
      "value": "new_value"
    }
  ],
  "locations": [
    {
      "id": 255093256,
      "name": "Location 1",
      "title": "Location 1",
      "description": null
    }
  ],
  "organizations": [
    {
      "id": 447626438,
      "name": "Organization 1",
      "title": "Organization 1",
      "description": null
    }
  ]
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

子网数字识别符

Validations:

  • Must be a number.

subnet
必填

Validations:

  • Must be a Hash

subnet[name]
选填

子网名

Validations:

  • Must be a String

subnet[description]
选填 , 允许空值

子网描述

Validations:

  • Must be a String

subnet[network_type]
选填 , 允许空值

类型或协议,值为 IPv4 或 IPv6,默认为 IPv4

Validations:

  • Must be one of: IPv4, IPv6.

subnet[network]
选填

子网网络

Validations:

  • Must be a String

subnet[mask]
选填

子网掩码

Validations:

  • Must be a String

subnet[gateway]
选填 , 允许空值

子网网关

Validations:

  • Must be a String

subnet[dns_primary]
选填 , 允许空值

这个子网的主 DNS

Validations:

  • Must be a String

subnet[dns_secondary]
选填 , 允许空值

这个子网的辅 DNS

Validations:

  • Must be a String

subnet[ipam]
选填 , 允许空值

这个子网的 IP 地址自动提示模式,有效值为 “DHCP”、“Internal DB”、“None”。

Validations:

  • Must be a String

subnet[from]
选填 , 允许空值

IP 自动提示的起始 IP 地址

Validations:

  • Must be a String

subnet[to]
选填 , 允许空值

为 IP 自动提示功能提供 IP 地址结尾

Validations:

  • Must be a String

subnet[vlanid]
选填 , 允许空值

这个子网的 VLAN ID

Validations:

  • Must be a String

subnet[mtu]
选填 , 允许空值

这个子网的 MTU

Validations:

  • Must be a Integer

subnet[domain_ids]
选填 , 允许空值

该部分子网的域名

Validations:

  • Must be an array of any type

subnet[dhcp_id]
选填 , 允许空值

要在此子网中使用的 DHCP 代理 ID

Validations:

  • Must be a number.

subnet[tftp_id]
选填 , 允许空值

要在此子网中使用的 TFTP 代理 ID

Validations:

  • Must be a number.

subnet[httpboot_id]
选填 , 允许空值

要在此子网中使用的 HTTPBoot 代理 ID

Validations:

  • Must be a number.

subnet[dns_id]
选填 , 允许空值

要在此子网中使用的 DNS 代理 ID

Validations:

  • Must be a number.

subnet[template_id]
选填 , 允许空值

要在此子网中使用的模板 HTTP 代理服务器 ID

Validations:

  • Must be a number.

subnet[boot_mode]
选填 , 允许空值

分配给这个子网接口的默认引导模式,有效值为 “Static”,“DHCP”。

Validations:

  • Must be a String

subnet[subnet_parameters_attributes]
选填 , 允许空值

参数阵列(name,value)

Validations:

  • Must be an array of any type

subnet[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

subnet[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


DELETE /api/subnets/:id
删除子网

示例

DELETE /api/subnets/281110143-four
{
  "subnet": {}
}
200
{
  "id": 281110143,
  "network": "3.3.5.0",
  "mask": "255.255.255.0",
  "priority": null,
  "name": "four",
  "vlanid": 44,
  "created_at": "2019-09-11T14:46:33.538Z",
  "updated_at": "2019-09-11T14:46:33.538Z",
  "dhcp_id": null,
  "tftp_id": 298486374,
  "gateway": null,
  "dns_primary": null,
  "dns_secondary": null,
  "from": null,
  "to": null,
  "dns_id": null,
  "boot_mode": "DHCP",
  "ipam": "None",
  "description": null,
  "mtu": 9000,
  "template_id": null,
  "httpboot_id": null,
  "to_label": "four (3.3.5.0/24)",
  "type": "Subnet::Ipv4"
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

子网数字识别符

Validations:

  • Must be a number.


GET /api/subnets/:id/freeip
提供此子网中未用的 IP 地址

示例

GET /api/subnets/1018351020-subnet515/freeip
200
{
  "freeip": "192.168.2.10",
  "errors": {}
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

mac
选填

用于重复使用此主机 IP 的 MAC 地址

Validations:

  • Must be a String

excluded_ips
选填

应从建议中排除的 IP 地址

Validations:

  • Must be an array of any type