diff --git a/docs/architecture.md b/docs/architecture.md index c7a79d3..90ad37b 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -21,7 +21,7 @@ CheckType.create("exact_match") | Stephen - This step may not be necessary at all? I would say this may come with more advanced use cases. Note: the extract data from json is specifically for getting keys and values from larger dictionaries to make it easier to compare and check specific parts/branches of the object. -Next, define a json object as reference data, as well as a JMESPATH expression to extract the value wanted and pass them to `extract_data_from_json` method. Be aware! `jdiff` works with a customized version of JMESPATH. More on that [below](#customized-jmespath). +Next, define a JSON object as reference data, as well as a JMESPath expression to extract the values wanted and pass them to `extract_data_from_json` method. Be aware! `jdiff` works with a customized version of JMESPath. More on that [below](#customized-jmespath). ```python bgp_reference_state = "./pre/bgp.json" @@ -29,7 +29,7 @@ bgp_jmspath_exp = "result[0].vrfs.default.peerList[*].[$peerAddress$,establishe bgp_reference_value = check.extract_data_from_json(bgp_reference_state, bgp_jmspath_exp) ``` -Once the pre-change values are extracted, we would need to evaluate it against our post-change value. In case of check-type `exact_match` our post-value would be another json object: +Once the pre-change values are extracted, we would need to evaluate them against our post-change value. In the case of check-type `exact_match`, our post value would be another JSON object: ```python bgp_comparison_state = "./post/bgp.json" @@ -38,7 +38,7 @@ bgp_comparison_value = check.extract_data_from_json(bgp_post_change, bgp_jmspath Each check type expects different types of arguments based on how and what they are checking. For example: check type `tolerance` needs a `tolerance` argument, whereas `parameter_match` expects a dictionary. -Now that we have pre- and post-data, we use the `evaluate` method to compare them, which will return our evaluation result. +Now that we have pre and post data, we use the `evaluate` method to compare them, which will return our evaluation result. ```python results = check.evaluate(post_value, pre_value, **evaluate_args) @@ -46,7 +46,7 @@ results = check.evaluate(post_value, pre_value, **evaluate_args) # Customized JMESPath -Since `jdiff` works with JSON objects as data inputs, JMESPATH was the obvious choice for traversing the data and extracting the value(s) to compare. However, JMESPath has a limitation where context is lost for the values it collects, in other words, for each given value that JMESPath returns, we can not be sure what key it was part of. +Since `jdiff` works with JSON objects as data inputs, JMESPath was the obvious choice for traversing the data and extracting the value(s) to compare. However, JMESPath has a limitation where context is lost for the values it collects, in other words, for each given value that JMESPath returns, we cannot be sure what key it was part of. Below is the output of `show bgp`. @@ -97,8 +97,8 @@ A JMESPath expression to extract `state` is shown below. ["Idle", "Connected"] ``` -How can we understand that `Idle` is relative to peer 7.7.7.7 and `Connected` to peer `10.1.0.0` ? -We could index the output but that would require some post-processing of the data. For that reason, `jdiff` use a customized version of JMESPATH where it is possible to define a reference key for the value(s) wanted. The reference key must be within `$` sign anchors and defined in a list, together with the value(s): +How can we understand that `Idle` is relative to peer 7.7.7.7 and `Connected` to peer `10.1.0.0`? +We could index the output, but that would require some post-processing of the data. For that reason, `jdiff` uses a customized version of JMESPath where it is possible to define a reference key for the value(s) wanted. The reference key must be within `$` sign anchors and defined in a list, together with the value(s): ```python "result[0].vrfs.default.peerList[*].[$peerAddress$,state] @@ -109,4 +109,4 @@ That would give us... ```python {"7.7.7.7": ["Idle"], "10.1.0.0": ["Connected"]} -``` \ No newline at end of file +```