API: VPCs, Subnets & Security Groups

REST API endpoints for managing network resources.

API: VPCs, Subnets & Security Groups

VPC Endpoints

MethodPathDescription
POST/v1/vpcsCreate a VPC
GET/v1/vpcsList all VPCs
GET/v1/vpcs/{id}Get VPC details
DELETE/v1/vpcs/{id}Delete a VPC
### Create VPC
POST /v1/vpcs
{
  "metadata": {"name": "production"},
  "spec": {"cidr": "10.0.0.0/16"}
}

Response (201)

{
  "id": "vpc-a1b2c3",
  "metadata": {"name": "production", "created_at": "2025-01-15T10:00:00Z"},
  "spec": {"cidr": "10.0.0.0/16"},
  "status": {"state": "active", "subnet_count": 0}
}

Subnet Endpoints

MethodPathDescription
POST/v1/subnetsCreate a subnet
GET/v1/subnetsList subnets (filter by ?vpc_id=)
GET/v1/subnets/{id}Get subnet details
DELETE/v1/subnets/{id}Delete a subnet
### Create Subnet
{
  "metadata": {"name": "web-tier"},
  "spec": {
    "vpc_id": "vpc-a1b2c3",
    "cidr": "10.0.1.0/24",
    "availability_zone": "fsn1-dc14"
  }
}

Security Group Endpoints

MethodPathDescription
POST/v1/security-groupsCreate a security group
GET/v1/security-groupsList security groups
GET/v1/security-groups/{id}Get details
DELETE/v1/security-groups/{id}Delete
### Create Security Group
{
  "metadata": {"name": "web-sg"},
  "spec": {
    "vpc_id": "vpc-a1b2c3",
    "rules": [
      {"direction": "ingress", "protocol": "tcp", "port": 80, "cidr": "0.0.0.0/0"},
      {"direction": "ingress", "protocol": "tcp", "port": 443, "cidr": "0.0.0.0/0"},
      {"direction": "ingress", "protocol": "tcp", "port": 22, "cidr": "10.0.0.0/16"},
      {"direction": "egress", "protocol": "all", "port": 0, "cidr": "0.0.0.0/0"}
    ]
  }
}

Network Setup Example

# 1. Create VPC
curl -X POST $API/v1/vpcs -H "$AUTH" -H "$CT" \
  -d '{"metadata":{"name":"prod"},"spec":{"cidr":"10.0.0.0/16"}}'

2. Create Subnet

curl -X POST $API/v1/subnets -H "$AUTH" -H "$CT" \ -d '{"metadata":{"name":"web"},"spec":{"vpc_id":"vpc-abc","cidr":"10.0.1.0/24"}}'

3. Create Security Group

curl -X POST $API/v1/security-groups -H "$AUTH" -H "$CT" \ -d '{"metadata":{"name":"web-sg"},"spec":{"vpc_id":"vpc-abc","rules":[...]}}'