# Multi-tier Network Policies

# Create multi-tier network policies

# Description

Create multi-tier network policies

# URI

POST /admin-api/global/1/layer_policy

# JSON body

{
    "name": "policy_1",
    "rules": [
        {
            "gateway": 3, // current gateway id
            "backup": 2, // backup upstream gateway id, not necessary
            "upstream": 1 // upstream gateway id
        },
        {
            "gateway": 4, // current gateway id
            "upstream": 3 // upstream gateway id
        }
    ]
}

It will create multi-tier network policy like this:

┌────────┐       ┌───────────┐  backup
│        │<──────│ gateway-2 │<---------┐
│ Source │       └───────────┘          │
│  site  │       ┌───────────┐    ┌───────────┐    ┌───────────┐
│        │<──────│ gateway-1 │<───│ gateway-3 │<───│ gateway-4 │
└────────┘       └───────────┘    └───────────┘    └───────────┘

# Example Request

# Shell

curl -X POST \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/global/1/layer_policy \
  -d '{"name":"policy_1","rules":[{"gateway":3,"backup":2,"upstream":1},{"gateway":4,"upstream":3}]}'

# Example Response

Status: 200 OK

{"status":0,"data":{"id":1}}

# Delete multi-tier network policies

# Description

Delete multi-tier network policies

# URI

DELETE /admin-api/global/1/layer_policy/{policy_id}

# Example Request

# Shell

curl -X DELETE \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/global/1/layer_policy/1

# Example Response

Status: 200 OK

{"status":0}

# Update multi-tier network policies

# Description

Update multi-tier network policies

# URI

PUT /admin-api/global/1/layer_policy/{policy_id}

# JSON body

{
    "name": "policy_2",
    "rules": [
        {
            "gateway": 3, // current gateway id
            "backup": 1, // backup upstream gateway id, not necessary
            "upstream": 2 // upstream gateway id
        }
    ]
}

# Example Request

# Shell

curl -X PUT\
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/global/1/layer_policy/1 \
  -d '{"name":"policy_2","rules":[{"gateway":3,"backup":1,"upstream":2}]}'

# Example Response

Status: 200 OK

{"status":0}

# Get multi-tier network policies

# Description

Get multi-tier network policies

# URI

GET /admin-api/global/1/layer_policy

# URI parameter

  • detail

    type: integer

    required: no

    description: Are detailed results required (default 0)

  • page

    type: integer

    required: no

    description: Results page (default 1)

  • page_size

    type: integer

    required: no

    description: Results page size (default 20)

# Example Request

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/global/1/layer_policy?detail=1

# Example Response

Status: 200 OK
{
    "status": 0,
    "data": [
        {
            "rules": [
                {
                    "backup": 1,
                    "upstream": 2,
                    "gateway": 3,
                    "id": 9
                }
            ],
            "name": "policy_2",
            "id": 5,
            "_created_unix": 1621828296.5587,
            "_modified_unix": 1621828300.1128
        }
    ]
}