| # Copyright 2021 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| from recipe_engine import recipe_api |
| |
| |
| class MonorailApi(recipe_api.RecipeApi): |
| """APIs for Monorail.""" |
| |
| def file_bug(self, step_name, summary, description, components=(), labels=()): |
| """File a new bug. |
| |
| Args: |
| step_name (str): Name of the step. |
| summary (str): Summary (title) of the bug. |
| description (str): Description of the bug. |
| components (seq(str)): A sequence of components to attach. |
| labels (seq(str)): A sequence of labels to attach. |
| """ |
| args = [ |
| self._monorail_tool, |
| "new-issue", |
| "-summary", |
| summary, |
| "-description", |
| description, |
| ] |
| for component in components: |
| args.extend(["-component", component]) |
| for label in labels: |
| args.extend(["-label", label]) |
| step = self.m.step( |
| step_name, |
| args, |
| stdout=self.m.json.output(), |
| step_test_data=lambda: self.m.json.test_api.output_stream({"id": 605}), |
| ) |
| link = "https://fxbug.dev/%d" % step.stdout["id"] |
| step.presentation.links["monorail link"] = link |
| return link |
| |
| @property |
| def _monorail_tool(self): |
| return self.m.ensure_tool("monorail", self.resource("tool_manifest.json")) |