cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1027
Views
35
Helpful
3
Replies

Can i call an action from restconf api

nanomatical
Level 1
Level 1

Hey everybody,

have spent all day on this. 

I have an action setup in NSO, where i give it a leaf and it spits out some data...

Can i request that same data via the API?

heres some snippits:

the action in NSO:
nso-cli: action get-impact device leaf4923

 

the yang:

container action {
    tailf:action get-impact {
      tailf:actionpoint customer-impact-action;
      input {
        leaf device {
          tailf:info "The Impacted Device";
          mandatory true;
          type leafref {
              path "/ncs:devices/ncs:device/ncs:name";
          }
        }
      }

so far this is as far as ive gotten and no luck:

https://hostname.com/restconf/data/tailf:action/get-impact
doesnt work as get or post

Where can i put the input leaf?

 

3 Replies 3

Nabsch
Spotlight
Spotlight

Hello , 

 

Here an example .You can use /restconf/operations  as well. 

admin@ncs# action get-impact device TEST-IOS-XR-3.50
result 32
admin@ncs#
admin@ncs#
nabil@DESKTOP-8ECTID4:~/ncs-run-5.5.4/packages$ curl  -X POST  -i -u admin:admin -H "Content-Type: application/yang-data+json"  http://localhost:8080/restconf/operations/action:action/get-impact -d '{ "input" : {"device" : "TEST-IOS-XR-3.50"}}'
HTTP/1.1 200 OK
Date: Tue, 22 Feb 2022 08:10:53 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Content-Length: 46
Content-Type: application/yang-data+json
X-Cisco-NSO-Trace-ID: 73e1afa0-331d-4eb8-bd28-8ca455ad24a5
Pragma: no-cache
Content-Security-Policy: default-src 'self'; block-all-mixed-content; base-uri 'self'; frame-ancestors 'none';
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

{
  "action:output": {
    "result": 32
  }
}
nabil@DESKTOP-8ECTID4:~/ncs-run-5.5.4/packages$ curl  -X POST  -i -u admin:admin -H "Content-Type: application/yang-data+json"  http://localhost:8080/restconf/data/action:action/get-impact -d '{ "input" : {"device" : "TEST-IOS-XR-3.50"}}'
HTTP/1.1 200 OK
Date: Tue, 22 Feb 2022 08:10:58 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Content-Length: 46
Content-Type: application/yang-data+json
X-Cisco-NSO-Trace-ID: 5ab05037-734a-4c42-9487-c23f11dab079
Pragma: no-cache
Content-Security-Policy: default-src 'self'; block-all-mixed-content; base-uri 'self'; frame-ancestors 'none';
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

{
  "action:output": {
    "result": 32
  }
}

 

 

richsun
Cisco Employee
Cisco Employee

This tool was made to answer questions like this one: https://gitlab.com/nso-developer/rest-api-explorer

cohult
Cisco Employee
Cisco Employee

The RESTCONF RFC 8040 is your friend here too with a description and several examples. https://datatracker.ietf.org/doc/html/rfc8040#section-3.6