diff --git a/base/cvd/cuttlefish/host/commands/cvd/fetch/BUILD.bazel b/base/cvd/cuttlefish/host/commands/cvd/fetch/BUILD.bazel index b32d774b19e..900cfcf74fc 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/fetch/BUILD.bazel +++ b/base/cvd/cuttlefish/host/commands/cvd/fetch/BUILD.bazel @@ -14,7 +14,7 @@ cf_cc_library( "//cuttlefish/common/libs/utils:result", "//cuttlefish/host/commands/cvd/cache", "//cuttlefish/host/commands/cvd/fetch:credential_flags", - "//cuttlefish/host/libs/web:android_build_api", + "//cuttlefish/host/libs/web:android_build_url", "//cuttlefish/host/libs/web/cas:cas_flags", "//libbase", ], diff --git a/base/cvd/cuttlefish/host/commands/cvd/fetch/build_api_flags.h b/base/cvd/cuttlefish/host/commands/cvd/fetch/build_api_flags.h index f586298a79e..a356bdac1e9 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/fetch/build_api_flags.h +++ b/base/cvd/cuttlefish/host/commands/cvd/fetch/build_api_flags.h @@ -22,7 +22,7 @@ #include "cuttlefish/host/commands/cvd/cache/cache.h" #include "cuttlefish/host/commands/cvd/fetch/credential_flags.h" -#include "cuttlefish/host/libs/web/android_build_api.h" +#include "cuttlefish/host/libs/web/android_build_url.h" #include "cuttlefish/host/libs/web/cas/cas_flags.h" namespace cuttlefish { diff --git a/base/cvd/cuttlefish/host/libs/web/android_build_api.cpp b/base/cvd/cuttlefish/host/libs/web/android_build_api.cpp index 080ddc0aecb..58b95c0b5f5 100644 --- a/base/cvd/cuttlefish/host/libs/web/android_build_api.cpp +++ b/base/cvd/cuttlefish/host/libs/web/android_build_api.cpp @@ -58,7 +58,15 @@ namespace { bool StatusIsTerminal(const std::string& status) { const static std::set terminal_statuses = { - "abandoned", "complete", "error", "ABANDONED", "COMPLETE", "ERROR", + "abandoned", + "ABANDONED", + "built", + "BUILT", + // deprecated in v4, but kept around for compatibility until removed + "complete", + "COMPLETE", + "error", + "ERROR", }; return terminal_statuses.count(status) > 0; } @@ -213,8 +221,8 @@ Result AndroidBuildApi::GetBuildInfo( << no_auth_error_message); bool is_signed = false; - if (json.isMember("signed")) { - is_signed = json["signed"].asBool(); + if (HasValue(json, {"buildSigned"})) { + is_signed = CF_EXPECT(GetValue(json, {"buildSigned"})); } return AndroidBuildApi::BuildInfo{ @@ -267,6 +275,7 @@ Result> AndroidBuildApi::LatestBuildId( "Error fetching last known good build " "id for:\nbranch \"{}\", target \"{}\"", branch, target); + LOG(INFO) << "\n\n TODO CJR \n\n" << "LatestBuildId response:\n" << json; if (!json.isMember("builds")) { return std::nullopt; } diff --git a/base/cvd/cuttlefish/host/libs/web/android_build_api.h b/base/cvd/cuttlefish/host/libs/web/android_build_api.h index c6cb2c3dbf0..a0e8a6609f9 100644 --- a/base/cvd/cuttlefish/host/libs/web/android_build_api.h +++ b/base/cvd/cuttlefish/host/libs/web/android_build_api.h @@ -35,9 +35,6 @@ namespace cuttlefish { -inline constexpr char kAndroidBuildServiceUrl[] = - "https://www.googleapis.com/android/internal/build/v3"; - class AndroidBuildApi : public BuildApi { public: AndroidBuildApi() = delete; diff --git a/base/cvd/cuttlefish/host/libs/web/android_build_url.cpp b/base/cvd/cuttlefish/host/libs/web/android_build_url.cpp index 356e2d53648..6975013b57a 100644 --- a/base/cvd/cuttlefish/host/libs/web/android_build_url.cpp +++ b/base/cvd/cuttlefish/host/libs/web/android_build_url.cpp @@ -118,12 +118,12 @@ AndroidBuildUrl::AndroidBuildUrl(std::string api_base_url, std::string api_key, std::string AndroidBuildUrl::GetLatestBuildIdUrl(std::string_view branch, std::string_view target) { UrlBuilder builder = UrlBuilder::GetLatestBuildIdBaseUrl(api_base_url_); - builder.AddQueryParameter("buildAttemptStatus", "complete"); + builder.AddQueryParameter("buildAttemptStatus", "built"); builder.AddQueryParameter("buildType", "submitted"); - builder.AddQueryParameter("maxResults", "1"); + builder.AddQueryParameter("pageSize", "1"); builder.AddQueryParameter("successful", "true"); - builder.AddQueryParameter("branch", branch); - builder.AddQueryParameter("target", target); + builder.AddQueryParameter("branches", branch); + builder.AddQueryParameter("targets", target); builder.AddApiKeyAndProjectId(api_key_, project_id_); return builder.GetUrl(); @@ -143,7 +143,7 @@ std::string AndroidBuildUrl::GetArtifactUrl( std::string_view page_token) { UrlBuilder builder = UrlBuilder::GetArtifactBaseUrl(api_base_url_, id, target); - builder.AddQueryParameter("maxResults", "100"); + builder.AddQueryParameter("pageSize", "100"); // maximum value allowed by API if (!artifact_filenames.empty()) { builder.AddQueryParameter("nameRegexp", BuildNameRegexp(artifact_filenames)); diff --git a/base/cvd/cuttlefish/host/libs/web/android_build_url.h b/base/cvd/cuttlefish/host/libs/web/android_build_url.h index 7bd29805099..21098fbf7fa 100644 --- a/base/cvd/cuttlefish/host/libs/web/android_build_url.h +++ b/base/cvd/cuttlefish/host/libs/web/android_build_url.h @@ -21,6 +21,9 @@ namespace cuttlefish { +inline constexpr char kAndroidBuildServiceUrl[] = + "https://androidbuild-pa.googleapis.com/v4"; + class AndroidBuildUrl { public: AndroidBuildUrl(std::string api_base_url, std::string api_key,