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=8b29de7534c8bd39ed5edc43f5faf2dfaa586d9f;hb=e2051cca7dac12aa09f6ed33555dcc4548c4b52b;hpb=c3e6c2ec9a1fddfc8e9bd31509b366e633b6d99e diff --git a/modules/libjuju/juju/client/overrides.py b/modules/libjuju/juju/client/overrides.py index 8b29de7..49ab931 100644 --- a/modules/libjuju/juju/client/overrides.py +++ b/modules/libjuju/juju/client/overrides.py @@ -15,6 +15,7 @@ __all__ = [ __patches__ = [ 'ResourcesFacade', 'AllWatcherFacade', + 'ActionFacade', ] @@ -105,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. @@ -138,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):