blob: f73e2c2013101e71cab9dccf097e3b2893720ba6 [file] [log] [blame]
# Copyright 2023 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 IssueTrackerApi(recipe_api.RecipeApi):
"""APIs for IssueTracker."""
def file_bug(self, step_name, summary, description, component_id):
"""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.
component_id (int): A component_id to attach.
"""
args = [
self._issuetracker_tool,
"new-issue",
"-summary",
summary,
"-description",
description,
"-component-id",
component_id,
]
step = self.m.step(
step_name,
args,
stdout=self.m.json.output(),
step_test_data=lambda: self.m.json.test_api.output_stream({"issueId": 605}),
)
link = f"https://fxbug.dev/{int(step.stdout['issueId'])}"
step.presentation.links["issuetracker link"] = link
return link
@property
def _issuetracker_tool(self):
return self.m.cipd_ensure(
self.resource("cipd.ensure"),
"fuchsia/infra/issuetracker/${platform}",
)