clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
206 stars 69 forks source link

restconf #511

Closed khromenokroman closed 3 months ago

khromenokroman commented 3 months ago

Hello, tell me when I send a get request, I get it like this.

curl -X GET http://111.11.111.11:8080/restconf/data/clixon-test:contexts/context=sample/router/static-routes -u 'sysadmin:$6$Edxj1MHJOWWrst2D$YTkLzv7EFQrSKeYWTq7BSw0Bu33qq5Teo/G.fMs2w0IcY0wwmLB25qVxa6/hHrSMhQvBrrfjaYIJ85d9D6zkj/'
{
   "clixon-test:static-routes": {
      "static": [
         {
            "ip": "0.0.0.0",
            "netmask": "0",
            "config": {
               "next-hop": [
                  {
                     "index": 1,
                     "config": {
                        "interface": "eth1",
                        "next-hop": "8.8.8.8",
                        "metric": 10
                     }
                  }
               ]
            }
         }
      ]
   }
}

And can I send a composite request if I need to, for example, filter by 2 fields, for example ip and netmask

something like that

curl -X GET 'http://example.com/api/data?month=3&year=2022'

now we have to use a hack. To receive everything and then process it on the client side, I would like to avoid this

curl -X GET "http://111.11.111.11:8080/restconf/data/clixon-test:contexts/context=sample/router/static-routes" -u 'sysadmin:$6$Edxj1MHJOWWrst2D$YTkLzv7EFQrSKeYWTq7BSw0Bu33qq5Teo/G.fMs2w0IcY0wwmLB25qVxa6/hHrSMhQvBrrfjaYIJ85d9D6zkj/' | jq '.["clixon-test:static-routes"].static[] | select(.ip == "desired_ip" and .netmask == "desired_netmask")'
khromenokroman commented 3 months ago

Hello, tell me when I send a get request, I get it like this.

curl -X GET http://111.11.111.11:8080/restconf/data/clixon-test:contexts/context=sample/router/static-routes -u 'sysadmin:$6$Edxj1MHJOWWrst2D$YTkLzv7EFQrSKeYWTq7BSw0Bu33qq5Teo/G.fMs2w0IcY0wwmLB25qVxa6/hHrSMhQvBrrfjaYIJ85d9D6zkj/'
{
   "clixon-test:static-routes": {
      "static": [
         {
            "ip": "0.0.0.0",
            "netmask": "0",
            "config": {
               "next-hop": [
                  {
                     "index": 1,
                     "config": {
                        "interface": "eth1",
                        "next-hop": "8.8.8.8",
                        "metric": 10
                     }
                  }
               ]
            }
         }
      ]
   }
}

And can I send a composite request if I need to, for example, filter by 2 fields, for example ip and netmask

something like that

curl -X GET 'http://example.com/api/data?month=3&year=2022'

now we have to use a hack. To receive everything and then process it on the client side, I would like to avoid this

curl -X GET "http://111.11.111.11:8080/restconf/data/clixon-test:contexts/context=sample/router/static-routes" -u 'sysadmin:$6$Edxj1MHJOWWrst2D$YTkLzv7EFQrSKeYWTq7BSw0Bu33qq5Teo/G.fMs2w0IcY0wwmLB25qVxa6/hHrSMhQvBrrfjaYIJ85d9D6zkj/' | jq '.["clixon-test:static-routes"].static[] | select(.ip == "desired_ip" and .netmask == "desired_netmask")'

clixon supports https://datatracker.ietf.org/doc/html/rfc8040 ?

khromenokroman commented 3 months ago

I figured it out thanks :)

curl -X GET "http://172.17.131.77:8080/restconf/data/clixon-ngfw:contexts/context=sample/router/static-routes/static=0.0.0.0,0" -u 'sysadmin:$6$Edxj1MHJOWWrst2D$YTkLzv7EFQrSKeYWTq7BSw0Bu33qq5Teo/G.fMs2w0IcY0wwmLB25qVxa6/hHrSMhQvBrrfjaYIJ85d9D6zkj/'