def terminate(self): args = self.fetch_args() data = {"reason": args["reason"]} # Calling Pipeline Execute API url = get_pipeline_execute_url(args["environment"], args["enterprise_id"], args["pipeline_id"], args["execution_id"], "terminate") try: self.app.log.debug("Terminating Pipeline Execution...") response = execute_pipeline(url, args["api_key"], data) except APIException: self.app.render("ERROR in connecting to Environment!\n") return if not response.ok: self.handle_response_failure(response) return # Rendering table with populated values data = render_single_dict(response.json()) self.app.render(f"Pipeline execution Terminated! Details: \n") self.app.render(data, format=OutputFormat.TABULATED.value, headers="keys", tablefmt="plain")
def show(self): args = self.fetch_args() # Calling Pipeline Graphs API url = get_pipeline_execute_url(args["environment"], args["enterprise_id"], args["pipeline_id"], execute_id=args.get("execution_id")) try: self.app.log.debug("Listing Executions...") response = list_execute_pipeline(url, args["api_key"]) except APIException: self.app.render("ERROR in connecting to Environment!\n") return if not response.ok: self.handle_response_failure(response) return # Rendering table with populated values data = response.json().get("results") render_data = [] for execution in data: render_pipeline = { "ID": execution.get("id"), "NAME": execution.get("name"), "DESCRIPTION": execution.get("description"), "STATE": execution.get("state"), "STATUS": execution.get("status"), "REASON": execution.get("reason"), } render_data.append(render_pipeline) self.app.render(f"Listing Executions for the Pipeline! Details: \n") self.app.render(render_data, format=OutputFormat.TABULATED.value, headers="keys", tablefmt="plain")