ietf-netmod-yangietf-netconfietf-restconfnetconf

Add data if 'config false' YANG


Can i sent POST(not PUT or PATCH) command if the config statement is false? How?

module system {
  namespace "system:uri";
  prefix "sys";

  leaf id {
    config false;
    type string;
  }
}

It's possible to define the leaf as a read-only in netconf or YANG? (after POST)


Solution

  • Config false nodes are not configurable. The server implementation sets their values. You cannot directly change the value of your id leaf. You can however instruct the server to do this indirectly, if you define a custom operation with such semantics.

    rpc change-id {
      input {
        leaf new-id {
          description "Sets the value of system:id.";
          type string;
        }
      }
    }
    

    Obviously, the leaf would need to be really special to warrant something like this. You would then invoke the operation via POST:

    POST /restconf/operations/system:change-id HTTP/1.1
    Host: example.com
    Content-Type: application/yang-data+json
    {"system:input":{"new-id": "foo"}}
    

    You will of course need to define proper semantics of your operation yourself.

    P.S.: seeing that you asked a somewhat similar question here, perhaps what you really need is access control.