Android-cuttlefish cvd tool
android_build_url.h
Go to the documentation of this file.
1//
2// Copyright (C) 2025 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include <ostream>
19#include <string>
20#include <string_view>
21#include <vector>
22
23namespace cuttlefish {
24
25enum class SafeLevel {
27 kSafe0,
28 kSafe1,
29 kSafe2,
31};
32
33std::string_view format_as(SafeLevel level);
34
35template <typename Sink>
36void AbslStringify(Sink& sink, SafeLevel level) {
37 sink.Append(format_as(level));
38}
39
40std::ostream& operator<<(std::ostream& os, SafeLevel level);
41
42inline constexpr SafeLevel kAllSafeLevels[] = {
48};
49
50inline constexpr char kAndroidBuildServiceUrl[] =
51 "https://androidbuild-pa.googleapis.com/v4";
52
54 public:
55 AndroidBuildUrl(std::string api_base_url, std::string api_key,
56 std::string project_id);
57
59 std::string_view branch, std::string_view target,
61 std::string GetBuildUrl(std::string_view id, std::string_view target);
62 std::string GetArtifactUrl(std::string_view id, std::string_view target,
63 const std::vector<std::string>& artifact_filenames,
64 std::string_view page_token);
65 std::string GetArtifactDownloadUrl(std::string_view id,
66 std::string_view target,
67 std::string_view artifact);
68
69 private:
70 std::string api_base_url_;
71 std::string api_key_;
72 std::string project_id_;
73};
74
75} // namespace cuttlefish
Definition: android_build_url.h:53
AndroidBuildUrl(std::string api_base_url, std::string api_key, std::string project_id)
Definition: android_build_url.cpp:131
std::string GetArtifactUrl(std::string_view id, std::string_view target, const std::vector< std::string > &artifact_filenames, std::string_view page_token)
Definition: android_build_url.cpp:161
std::string api_key_
Definition: android_build_url.h:71
std::string GetArtifactDownloadUrl(std::string_view id, std::string_view target, std::string_view artifact)
Definition: android_build_url.cpp:180
std::string api_base_url_
Definition: android_build_url.h:70
std::string GetBuildUrl(std::string_view id, std::string_view target)
Definition: android_build_url.cpp:153
std::string project_id_
Definition: android_build_url.h:72
std::string GetLatestBuildCandidateUrl(std::string_view branch, std::string_view target, SafeLevel safe_level=SafeLevel::kSafeLevelUnspecified)
Definition: android_build_url.cpp:137
Definition: alloc_driver.h:20
void AbslStringify(Sink &sink, DeviceType device_type)
Definition: device_type.h:42
constexpr char kAndroidBuildServiceUrl[]
Definition: android_build_url.h:50
constexpr SafeLevel kAllSafeLevels[]
Definition: android_build_url.h:42
std::ostream & operator<<(std::ostream &out, DeviceType device_type)
Definition: device_type.cpp:72
std::string_view format_as(DeviceType device_type)
Definition: device_type.cpp:76
SafeLevel
Definition: android_build_url.h:25