result = (await app_facade.Get(self.name)).constraints
return vars(result) if result else result
- def get_actions(self, schema=False):
+ async def get_actions(self, schema=False):
"""Get actions defined for this application.
:param bool schema: Return the full action schema
-
+ :return dict: The charms actions, empty dict if none are defined.
"""
- raise NotImplementedError()
+ actions = {}
+ entity = [{"tag": self.tag}]
+ action_facade = client.ActionFacade.from_connection(self.connection)
+ results = (
+ await action_facade.ApplicationsCharmsActions(entity)).results
+ for result in results:
+ if result.application_tag == self.tag and result.actions:
+ actions = result.actions
+ break
+ if not schema:
+ actions = {k: v['description'] for k, v in actions.items()}
+ return actions
def get_resources(self, details=False):
"""Return resources for this application.
)
return await self.ann_facade.Set([ann])
- async def set_config(self, config, to_default=False):
+ async def set_config(self, config):
"""Set configuration options for this application.
:param config: Dict of configuration to set
- :param bool to_default: Set application options to default values
-
"""
app_facade = client.ApplicationFacade.from_connection(self.connection)
return await app_facade.Set(self.name, config)
+ async def reset_config(self, to_default):
+ """
+ Restore application config to default values.
+
+ :param list to_default: A list of config options to be reset to their default value.
+ """
+ app_facade = client.ApplicationFacade.from_connection(self.connection)
+
+ log.debug(
+ 'Restoring default config for %s: %s', self.name, to_default)
+
+ return await app_facade.Unset(self.name, to_default)
+
async def set_constraints(self, constraints):
"""Set machine constraints for this application.