---
# System prepended metadata

title: Network services APIs

---

# Network services APIs

> NOTE: Please ping me when you read it. :D

[TOC]

## Services API
### Get services
- Path
    ```POST /api/services/services ```
- Header
    ```
    Cookie: JSESSIONID=...; accessToken=...
    Content-Type: application/json
    ```
- Body
    ```
    {
       "reqData": {
          <svc-type>: [<tunnelId>]
       }
    }
    ```
    - `<svc-type>`: `spb`, `vxlan`, `l2gre`.
    - `<tunnelId>`: is `isid`/`vnid`/`vpnid` if `svc-type` is `spb`/`vxlan`/`l2gre` respectively.
    > Note: `vxlan` and `l2gre` are not supported now.

- Examples:
    - Get all `spb` services
        ```
        {
           "reqData": {
              "spb": []
           }
        }
        ```
    - Get all `spb` services having `isid` = `10` or `20`
        ```
        {
           "reqData": {
              "spb": [10, 20]
           }
        }
        ```

### Delete services
- Path:
    ``` DELETE /api/services/services```
- Header
    ```
    Cookie: JSESSIONID=...; accessToken=...
    Content-Type: application/json
    ```
- Body
    ```
    {
        "reqData": {
            <svc-type>: [
                {
                    "deviceId": <device-id>,
                    "tunnelIds": [<tunnelId>] 
                }
            ]
        }
    }
    ```
    - `<svc-type>`: `spb`, `vxlan`, `l2gre`
    - `<device-id>`: the id of device in the database. Ex: `5fbc903ae4b03d5e05617538`
    - `<tunnelId>`: is `isid`/`vnid`/`vpnid` if `svc-type` is `spb`/`vxlan`/`l2gre` respectively.
- Examples:
    - Detele all `spb` services of the device `5fbc903ae4b03d5e05617538`
        ```
        {
            "reqData": {
                "spb": [
                    {
                        "deviceId": "5fbc903ae4b03d5e05617538",
                        "tunnelIds": [] 
                    }
                ]
            }
        }
        ```
    - Delete some `spb` services of the device `5fbc903ae4b03d5e05617538`
        ```
        {
            "reqData": {
                "spb": [
                    {
                        "deviceId": "5fbc903ae4b03d5e05617538",
                        "tunnelIds": [10, 20] 
                    }
                ]
            }
        }
        ```
    - Delete `spb` services of multi devices.
        ```
        {
            "reqData": {
                "spb": [
                    {
                        "deviceId": "5fbc903ae4b03d5e05617538",
                        "tunnelIds": [] 
                    },
                    {
                        "deviceId": "5fb77442e4b07b18ef0d88dd",
                        "tunnelIds": []
                    }
                ]
            }
        }
        ```

---

        
## Services Profile API
### Create service
- Path
    ```POST /api/services/service-profile ```
- Header
    ```
    Cookie: JSESSIONID=...; accessToken=...
    Content-Type: application/json
    ```
- Body
    ``` 
    {
        "svcInfo": {
            "svcId": 4000,
            "svcType": "spb",
            "tunnelId": 4000,        
            "bVlan": 4001,
            "vlanTranslation": "YES",
            "adminState": "DOWN",
            "mCastMode": "HEADEND",
            "description": "testing from postman 111111",
            "stats": "YES",
            "l3VpnMtu": 1514,
            "removeIngressTag": "YES"
        },
        "deviceIds": {
            "added": [
                {"deviceId": "5f7592dbe4b0d79d3006cba4"}
            ]
        },
        "sapInfos": [
            {
                "description": "testing from postman",
                "outerInnerVlan": "40.20",
                "adminState": "UP",
                "stats": "YES",
                "priority": "Trusted",
                "priorityNumber": 0
            }
        ],
        "sapPorts": {
            "added": [
                {
                   "deviceId": "5f7592dbe4b0d79d3006cba4",
                   "ports": [
                       {"portId": "1006"}
                   ]
                }
            ]
        },
        "accessInterfaceInfo": {
            "vlanTranslation": "YES",
            "l2Profile": "def-access-profile",
            "description": "testing from postman"
        },
        "accessRoleMapping": {
            "accessRoleProfileId": "5f8d55e70cf20be1e28cd995"
        },
        "unpPorts": {
            "added": [
                {
                    "deviceId": "5f7592dbe4b0d79d3006cba4",
                    "ports": [
                        {"portId": "1016"}
                    ]
                }
            ]
        }, 
        "unpAccessAuthInfo": { 
            "accessAuthProfileId": "5f8813e90cf20098444230d6"
        }
    }
    ```
    
### Edit single service or Edit multiple service with same tunnelId
- Path:
    ``` PUT /api/services/services```
- Header
    ```
    Cookie: JSESSIONID=...; accessToken=...
    Content-Type: application/json
    ```
- Body
    ```
    {
        "svcInfo": {
            "svcId": 4000,
            "svcType": "spb",
            "tunnelId": 4000,           
            "bVlan": 4001,
            "vlanTranslation": "YES",
            "adminState": "DOWN",
            "mCastMode": "HEADEND",
            "description": "testing from postman abc",
            "stats": "YES",
            "l3VpnMtu": 1514,
            "removeIngressTag": "YES"
        },
        "deviceIds": {
            "added": [
                {"deviceId": "5f7592dbe4b0d79d3006cba4"}
            ],
            "selected": [
                {"deviceId": "5fb77442e4b07b18ef0d88dd"}
            ]
        },
        "sapInfos": [
            {
                "description": "testing from postman",
                "outerInnerVlan": "40.10",
                "adminState": "UP",
                "stats": "YES",
                "priority": "Trusted",
                "priorityNumber": 0
            }
        ],
        "sapPorts": {
            "selected": [
                {
                    "deviceId": "5f7592dbe4b0d79d3006cba4",
                    "ports": [
                        {"portId": "1006", "outerInnerVlan": "40.20"}
                    ]
                }

            ],
            "added": [
                {
                    "deviceId": "5f7592dbe4b0d79d3006cba4",
                    "ports": [
                        {"portId": "1006"}
                    ]
                }
            ],
            "removed": [
                {
                    "deviceId": "5f7592dbe4b0d79d3006cba4",
                    "ports": [
                        {"portId": "1006", "outerInnerVlan": "40.20"}
                    ]
                }
            ]
        },
        "accessInterfaceInfo": {
            "vlanTranslation": "YES",
            "l2Profile": "l2-switch",
            "description": "testing from postman"
        },
        "unpPorts": {
            "added": [
                {
                    "deviceId": "device-id-3",
                    "ports": [
                        {"portId": "1003"}, 
                        {"portId": "1004"}
                    ]
                }
            ]
        }
    }
    ```

### Edit multiple service with different tunnelId
- Path:
    ``` PUT /api/services/services```
- Header
    ```
    Cookie: JSESSIONID=...; accessToken=...
    Content-Type: application/json
    ```
- Body
    ```
    {
       "svcInfo": {         
            "svcId": 4200,                                          
            "svcType": "spb",
            "tunnelId": 4200,
            "bVlan": 4001,
            "vlanTranslation": "YES",
            "adminState": "DOWN",
            "mCastMode": "HEADEND",
            "description": "testing from postman 33333",
            "stats": "YES",
            "l3VpnMtu": 1700,
            "removeIngressTag": "YES"
        },
        "deviceIds":{
            "removed": [
                {"deviceId": "5f75866be4b0d79d3006be3c"},    
                { "deviceId": "5f7592cde4b0d79d3006ca9e", "tunnelIds": [4100, 4200]}  
            ]
            "selected":[
                { "deviceId": "5f7592dbe4b0d79d3006cba4", "tunnelIds": [4100, 4200]}, 
                { "deviceId": "5f75866be4b0d79d3006be3c"}   
            ],
            "added": [
                {"deviceId": "5f75866be4b0d79d3006be3c"}  
            ]
        },
        "sapPorts": {
            "selected": [
                {
                    "deviceId": "5f7592dbe4b0d79d3006cba4",
                    "tunnelId": 4100,  
                    "ports": [
                        {"portId": "1006", "outerInnerVlan": "40.20"}
                    ]
                }

            ],
            "added": [
                {
                    "deviceId": "5f7592dbe4b0d79d3006cba4",
                    "ports": [
                        {"portId": "1006"}
                    ]
                }
            ],
            "removed": [
                {
                    "deviceId": "5f7592dbe4b0d79d3006cba4",
                    "tunnelId": 4200,      
                    "ports": [
                        {"portId": "1006", "outerInnerVlan": "40.20"}
                    ]
                }
            ]
        },
        "patchSvcInfo": {                   
            "description": "patched description 2"
        }
    }
    ```
    


    