feat(clients): data: BigQuery, Storage media and signed URLs, Pub/Sub, Firestore, Spanner, Bigtable admin, Secret Manager, Dataplex, DLP, KMS, Datastore

Discovery generated call table (918 rows), typed services, /google/data demo.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 15:03:43 +01:00
co-authored by Claude Sonnet 5.5
parent 3db67fcf1f
commit 1af14b5d74
47 changed files with 6315 additions and 3 deletions
+110
View File
@@ -0,0 +1,110 @@
#include "google/data/dlp.h"
namespace molo::google::data {
using clients::body::Json;
namespace {
Json item(const std::string& text) {
if (text.empty() || text.size() > DataCaps::kMaxDlpItemBytes)
throw GoogleError::invalid("text must be 1.." + std::to_string(DataCaps::kMaxDlpItemBytes) +
" bytes");
Json i = Json::object();
i.set("value", Json(text));
return i;
}
} // namespace
void InspectRequest::validate() const {
item(text);
static const char* const likelihood[] = {"VERY_UNLIKELY", "UNLIKELY", "POSSIBLE", "LIKELY",
"VERY_LIKELY"};
bool ok = false;
for (const char* l : likelihood) ok = ok || min_likelihood == l;
if (!ok) throw GoogleError::invalid("min_likelihood is not a DLP likelihood");
if (max_findings < 1 || max_findings > 1000)
throw GoogleError::invalid("max_findings must be 1..1000");
if (info_types.size() > 100) throw GoogleError::invalid("at most 100 info types");
for (const auto& t : info_types) Ids::id(t, "info type");
if (!location.empty()) Ids::location(location);
}
Json InspectRequest::to_json() const {
validate();
Json config = Json::object();
if (!info_types.empty()) {
Json arr = Json::array();
for (const auto& t : info_types) {
Json o = Json::object();
o.set("name", Json(t));
arr.push(o);
}
config.set("infoTypes", arr);
}
config.set("minLikelihood", Json(min_likelihood));
config.set("includeQuote", Json(include_quote));
Json limits = Json::object();
limits.set("maxFindingsPerRequest", Json(max_findings));
config.set("limits", limits);
Json b = Json::object();
b.set("item", item(text));
b.set("inspectConfig", config);
return b;
}
std::string Dlp::parent(const std::string& location) const {
return location.empty() ? project_path() : location_path(location);
}
Json Dlp::inspect_content(const InspectRequest& r) const {
CallArgs a = on("parent", parent(r.location));
a.with_body(r.to_json());
return invoke(r.location.empty() ? "dlp.projects.content.inspect"
: "dlp.projects.locations.content.inspect",
a);
}
Json Dlp::deidentify_content(const std::string& text, const Json& config,
const std::string& location) const {
need(config.is_object() && !config.as_object().empty(), "deidentify config must be an object");
Json b = Json::object();
b.set("item", item(text));
b.set("deidentifyConfig", config);
CallArgs a = on("parent", parent(location));
a.with_body(b);
return invoke(location.empty() ? "dlp.projects.content.deidentify"
: "dlp.projects.locations.content.deidentify",
a);
}
Json Dlp::list_info_types(const std::string& language) const {
CallArgs a;
if (!language.empty()) {
need(language.size() <= 16, "language code too long");
a.q("languageCode", Json(language));
}
return invoke("dlp.infoTypes.list", a);
}
Json Dlp::list_inspect_templates(int n) const {
CallArgs a = on("parent", project_path());
a.q("pageSize", page(n));
return invoke("dlp.projects.inspectTemplates.list", a);
}
Json Dlp::list_deidentify_templates(int n) const {
CallArgs a = on("parent", project_path());
a.q("pageSize", page(n));
return invoke("dlp.projects.deidentifyTemplates.list", a);
}
Json Dlp::list_job_triggers(int n) const {
CallArgs a = on("parent", project_path());
a.q("pageSize", page(n));
return invoke("dlp.projects.jobTriggers.list", a);
}
Json Dlp::list_jobs(int n) const {
CallArgs a = on("parent", project_path());
a.q("pageSize", page(n));
return invoke("dlp.projects.dlpJobs.list", a);
}
} // namespace molo::google::data