blob: d8aac743f548c85bc09d2c8c9fda4fb4b190b462 [file] [log] [blame]
# 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 BundleFetcherApi(recipe_api.RecipeApi):
"""APIs for interacting with the bundle_fetcher tool."""
def __call__(self, *args, **kwargs):
name = kwargs.pop("name", "bundle_fetcher")
return self.m.step(
name, [self._bundle_fetcher_path] + list(args or []), **kwargs
)
@property
def _bundle_fetcher_path(self):
# Built as "tools/bundle_fetcher:host" via the host_prebuilts-x64-foo
# builders.
return self.m.ensure_tool("bundle_fetcher", self.resource("tool_manifest.json"))
def download(self, build_ids, gcs_bucket, out_dir):
"""Downloads and updates product manifests to contain the absolute URIs
and stores them in the out directory.
Args:
build_ids (list(int)): List of build ids to retrieve product manifests for.
gcs_bucket (str): Bucket from which to read the files from.
out_dir (Path): Out directory to write the product bundles manifest to.
"""
return self(
"download",
"-build_ids",
",".join(str(b) for b in build_ids),
"-bucket",
gcs_bucket,
"-out_dir",
out_dir,
)