Skip to content

Commit

Permalink
Add readme for path (#67)
Browse files Browse the repository at this point in the history
* Add readme for path

* typo
  • Loading branch information
DanG100 authored Oct 18, 2022
1 parent f63b191 commit 6e18a40
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ Calling the generation with `--base_import_path=<somepath>/exampleoc` flag will

The ygnmi client library uses the generated code to perform schema compliant subscriptions and set gNMI RPCs.

### gNMI path to ygnmi path

ygnmi paths mimic with gNMI paths with a few transformations applied.

1. Names are CamelCased: `network-instance` -> `NetworkInstance`
2. YANG module names are omitted, and added to a root struct: `/openconfig-network-instance/network-interfaces/` -> `ocpath.Root().NetworkInstance()`
3. Lists are compressed: `network-instances/network-instance[name=DEFAULT]` -> `NetworkInstance("DEFAULT")`
4. List keys can be specified several ways:
1. Fully by specifying all keys: `protocols/protocol[identifier=BGP][name=test]` -> `Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "test")`
2. Specifying no keys: `protocols/protocol[identifier=*][name=*]` -> `ProtocolAny()`
3. Specifying some keys: `protocols/protocol[identifier=BGP][name=*]` -> `ProtocolAny().WithIdentifier(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP)`
5. State or Config are specified at the end: `interface[name=eth0]/state/name` -> `Interface("eth0").Name().State()`

Examples:

|gNMI Path|ygnmi Call|
|---------|----------|
|`/network-instances/network-instance[name=DEFAULT]/protocols/protocol[identifier=BGP][name=test]/bgp/neighbors/neighbor[neighbor-address=localhost]/state/description`|`ocpath.Root().NetworkInstance("DEFAULT").Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "test").Bgp().Neighbor("localhost").Description().State()`
| `/interfaces/interface[name=*]/config/name` | `ocpath.Root().InterfaceAny().Name().Config()`

Note: It is highly recommended to use this library with an IDE or autocomplete configured.

### Queries

The ygnmi library uses generic queries to represent a gNMI path, the value type, and schema. Queries should never be constructed directly.
Expand Down

0 comments on commit 6e18a40

Please sign in to comment.