def run(self, text): alias_match = ActionAliasMatch() alias_match.command = text matches = self.client.managers['ActionAlias'].match(alias_match) return { 'alias': _format_match(matches[0]), 'representation': matches[1] }
def run(self, args, **kwargs): alias_match = ActionAliasMatch() alias_match.command = args.command_text action_alias, representation = self.manager.match(alias_match, **kwargs) execution = ActionAliasExecution() execution.name = action_alias.name execution.format = representation execution.command = args.command_text execution.source_channel = "cli" # ? execution.notification_channel = None execution.notification_route = None execution.user = args.user action_exec_mgr = self.app.client.managers["ActionAliasExecution"] execution = action_exec_mgr.create(execution, **kwargs) return execution
def run(self, args, **kwargs): alias_match = ActionAliasMatch() alias_match.command = args.command_text action_alias, representation = self.manager.match(alias_match, **kwargs) execution = ActionAliasExecution() execution.name = action_alias.name execution.format = representation execution.command = args.command_text execution.source_channel = 'cli' # ? execution.notification_channel = None execution.notification_route = None execution.user = args.user action_exec_mgr = self.app.client.managers['ActionAliasExecution'] execution = action_exec_mgr.create(execution, **kwargs) return execution
def run(self, text, source_channel=None, user=None): alias_match = ActionAliasMatch() alias_match.command = text alias, representation = self.client.managers['ActionAlias'].match( alias_match) execution = ActionAliasExecution() execution.name = alias.name execution.format = representation execution.command = text execution.source_channel = source_channel # ? execution.notification_channel = None execution.notification_route = None execution.user = user action_exec_mgr = self.client.managers['ActionAliasExecution'] execution = action_exec_mgr.create(execution) self._wait_execution_to_finish(execution.execution['id']) return execution.execution['id']
def match(self, text): auth_kwargs = self.st2auth.auth_method("st2client") auth_kwargs['debug'] = False LOG.info("Create st2 client with {} {} {}".format(self.st2config.base_url, self.st2config.api_url, auth_kwargs)) st2_client = Client(base_url=self.st2config.base_url, api_url=self.st2config.api_url, **auth_kwargs) alias_match = ActionAliasMatch() alias_match.command = text try: return st2_client.managers['ActionAlias'].match(alias_match) except HTTPError as e: if e.response is not None and e.response.status_code == 400: print("No match found") else: print("HTTPError %s" % e) return None
def run(self, args, **kwargs): alias_match = ActionAliasMatch() alias_match.command = args.match_text match, _ = self.manager.match(alias_match, **kwargs) return [match]
def run(self, text): alias_match = ActionAliasMatch() alias_match.command = text matches = self.client.managers["ActionAlias"].match(alias_match) return {"alias": _format_match(matches[0]), "representation": matches[1]}