-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tagfilter resolving and filtering #30
Conversation
This reverts commit 6ead3c2.
Converting back to a draft for now, need to set up my test env so that I can resolve issues in Python 3.7. |
This is a large PR and may take a bit to fully review. That said, it seems a lot of this code sets us up for future improvements and does not modify current behaviors unless you go out of your way to do so (ie will not break existing usage). Is that fair to say? |
Absolutely. The only modification made to axl.py was this addition in the class' self._zeep = axl_client No other includes have been added to axl.py either, so nothing additional will be run or loaded. All other modules added by this PR are currently unused unless specifically imported at runtime. And I apologize for the size of the PR. Most of the functionality is carried over from my personal fork where it was first implemented, but now modified and tested to fit the needs of this project. The bulk of it resides in wsdl.py, which is a helper library for dealing with WSDL elements.Since all 3 main enhancements of this PR use that library in some way, it was difficult to try and split it up. If there's any way I can assist, whether that be making changes, answering questions, or developing tests for this PR, please don't hesitate to ask. |
It makes it easier since it’s not really touching the main class object. I believe the wsdl helper methods will be quite useful and we might want to bring it under the |
There may actually be a couple things I could remove from wsdl.py that aren't currently used by anything in this PR. I'll try and look into what I can leave out sometime tomorrow. It can always be re-added if it's needed. |
Don’t pull anything out just yet. I think this has the helper library you showed Jeff and I that maps out the wsdl data structure. That’s really useful. If there are other helper functions that are not relevant - call them out in comments here for discussion and we can decide together whether they stay or go (if any at all). |
In wsdl.py: Line 548 These are dev tools for visualizing element structures, but aren't necessarily needed for the enhancements this PR is trying to bring. They are all basically convenience functions that wrap around the main class Line 595 This is a useful function for validating user kwargs in 'add' and 'update' AXL requests. Uses |
This PR aims to add a
@check_tagfilter
decorator that can be added to any 'get' or 'list' AXL requests. The decorator is designed to do the following:tagfilter
are valid 'returnedTags' base valuestagfilter
list/dict of base tag elements into a nested dict of all necessary child tagstagfilter
(works on lists of objects too)Below is an example of how this decorator could be implemented:
Some applications where this is beneficial are...
Resolving tags with children
Currently, supplying
{'lines': {'line': ''}}
totagfilter
will result in much of the returned line information beingNone
since none of the children of the "line" element are supplied.check_tagfilter
will look up the schema for the relevant 'returnedTags' element and add all necessary children to 'lines' intagfilter
.Without
check_tagfilter
With
check_tagfilter
('line' not needed, only parent node)Flexibility of
tagfilter
parametersYou can now use a list, dict, or tuple to define which tags you would like to use. For example, all three of these calls have the same result:
If you want to see all tags, you can set
tagfilter
asNone
,""
,{}
, or anything else with a false bool value. This ensures backwards compatibility with previous versions of ciscoaxl.Return object filtering
Instead of returning a whole bunch of
None
values for items that were not included in thetagfilter
, the returned object will have its attributes filtered and remove any non-requested items.Without
check_tagfilter
With
check_tagfilter
Lifting nested
_value_1
resultsSome returned items will contain a dict-like object that houses the actual value of the item (
_value_1
) and the UUID of the item. However, nearly all UCM entities returned as a child of returnedTags don't have any place in the AXL schema where their value can be retrieved via their UUID, making this data-point very unhelpful when compared to the annoyance of having to go down another level to reach the desired data.check_tagfilter
will automatically lift any_value_1
items and assign that value directly to the parent.Without
check_tagfilter
With
check_tagfilter
However, this feature would not be backwards compatible with previous version of ciscoaxl. Therefore, it is left disabled by a variable in
config.py
:To enable the feature, the user must run
enable_value1_resolver()
at some point in their script. This could be changed in the future, but right not it is necessary in order not to break anything.That's about it! The decorator has not been applied to any methods in
axl.py
in this PR since that will involve some refactoring those method's arguments (most 'get' methods don't havetagfilter
). That would be best for another PR down the road.wsdl.py
also paves the way for automatic doc generation. I tried to comment everything in there as best as I could, but please ask me questions if anything is confusing or not explained well enough.