X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=modules%2Flibjuju%2Fjuju%2Fclient%2Foverrides.py;h=49ab931b1a19ad30ab512ccd80b713182fa840db;hp=5e98e56ce8041f1f3e5a6e346dfe620ce1ea96aa;hb=refs%2Fchanges%2F94%2F6394%2F1;hpb=1a15d1c84fc826fa7996c1c9d221a324edd33432 diff --git a/modules/libjuju/juju/client/overrides.py b/modules/libjuju/juju/client/overrides.py index 5e98e56..49ab931 100644 --- a/modules/libjuju/juju/client/overrides.py +++ b/modules/libjuju/juju/client/overrides.py @@ -1,10 +1,8 @@ -from collections import namedtuple import re +from collections import namedtuple +from . import _client, _definitions from .facade import ReturnMapping, Type, TypeEncoder -from .import _client -from .import _definitions - __all__ = [ 'Delta', @@ -17,6 +15,7 @@ __all__ = [ __patches__ = [ 'ResourcesFacade', 'AllWatcherFacade', + 'ActionFacade', ] @@ -107,6 +106,42 @@ class AllWatcherFacade(Type): return result +class ActionFacade(Type): + + class _FindTagsResults(Type): + _toSchema = {'matches': 'matches'} + _toPy = {'matches': 'matches'} + + def __init__(self, matches=None, **unknown_fields): + ''' + FindTagsResults wraps the mapping between the requested prefix and the + matching tags for each requested prefix. + + Matches map[string][]Entity `json:"matches"` + ''' + self.matches = {} + matches = matches or {} + for prefix, tags in matches.items(): + self.matches[prefix] = [_definitions.Entity.from_json(r) + for r in tags] + + @ReturnMapping(_FindTagsResults) + async def FindActionTagsByPrefix(self, prefixes): + ''' + prefixes : typing.Sequence[str] + Returns -> typing.Sequence[~Entity] + ''' + # map input types to rpc msg + _params = dict() + msg = dict(type='Action', + request='FindActionTagsByPrefix', + version=2, + params=_params) + _params['prefixes'] = prefixes + reply = await self.rpc(msg) + return reply + + class Number(_definitions.Number): """ This type represents a semver string. @@ -140,14 +175,24 @@ class Number(_definitions.Number): def __str__(self): return self.serialize() + @property + def _cmp(self): + return (self.major, self.minor, self.tag, self.patch, self.build) + def __eq__(self, other): - return ( - isinstance(other, type(self)) and - other.major == self.major and - other.minor == self.minor and - other.tag == self.tag and - other.patch == self.patch and - other.build == self.build) + return isinstance(other, type(self)) and self._cmp == other._cmp + + def __lt__(self, other): + return self._cmp < other._cmp + + def __le__(self, other): + return self._cmp <= other._cmp + + def __gt__(self, other): + return self._cmp > other._cmp + + def __ge__(self, other): + return self._cmp >= other._cmp @classmethod def from_json(cls, data):