2525from .charmhub import CharmHub
2626from .charmstore import CharmStore
2727from .client import client , connector
28- from .client .client import ConfigValue , Value
2928from .client .overrides import Caveat , Macaroon
3029from .constraints import parse as parse_constraints
3130from .controller import Controller , ConnectedController
@@ -2003,7 +2002,7 @@ async def get_config(self):
20032002 result = await config_facade .ModelGet ()
20042003 config = result .config
20052004 for key , value in config .items ():
2006- config [key ] = ConfigValue .from_json (value )
2005+ config [key ] = client . ConfigValue .from_json (value )
20072006 return config
20082007
20092008 async def get_constraints (self ):
@@ -2027,7 +2026,7 @@ async def get_constraints(self):
20272026 # set.
20282027 if result .constraints :
20292028 constraint_types = [a for a in dir (result .constraints )
2030- if a in Value ._toSchema .keys ()]
2029+ if a in client . Value ._toSchema .keys ()]
20312030 for constraint in constraint_types :
20322031 value = getattr (result .constraints , constraint )
20332032 if value is not None :
@@ -2121,7 +2120,7 @@ async def set_config(self, config):
21212120
21222121 new_conf = {}
21232122 for key , value in config .items ():
2124- if isinstance (value , ConfigValue ):
2123+ if isinstance (value , client . ConfigValue ):
21252124 new_conf [key ] = value .value
21262125 elif isinstance (value , str ):
21272126 new_conf [key ] = value
@@ -2134,8 +2133,12 @@ async def set_constraints(self, constraints):
21342133
21352134 :param dict config: Mapping of model constraints
21362135 """
2137- client_facade = client .ModelConfigFacade .from_connection (self .connection ())
2138- await client_facade .SetModelConstraints (
2136+ facade_cls = client .ModelConfigFacade
2137+ if facade_cls .best_facade_version (self .connection ()) <= 2 :
2138+ facade_cls = client .ClientFacade
2139+ facade = facade_cls .from_connection (self .connection ())
2140+
2141+ await facade .SetModelConstraints (
21392142 application = '' ,
21402143 constraints = constraints )
21412144
0 commit comments