#pragma once // SandboxEnvironmentTemplate (v1beta1): the container recipe a computer use // or shell sandbox is created from. Create, get, list, delete. #include #include #include "google/operation.h" #include "google/sandbox/sandbox_service.h" namespace molo::google::sandbox { enum class ContainerCategory { kNone, kComputerUse, kShellSandbox }; struct TemplatePort { std::string protocol = "TCP"; // TCP or UDP int port = 0; // 1..65535 }; struct CreateTemplateRequest { std::string display_name; // Required, 1..128 characters. // Exactly one of: a default container category, or a custom container image. ContainerCategory category = ContainerCategory::kNone; std::string image_uri; // customContainerEnvironment.customContainerSpec.imageUri std::vector ports; // Custom container only, at most 16. bool internet_access = false; // egressControlConfig.internetAccess std::string network_attachment; // egressControlConfig.networkAttachment bool persistent_disk = false; // persistentDiskConfig.enabled std::string disk_mount_path; // absolute path, plain characters long disk_size_gb = 0; // 1..1024 when the disk is enabled }; struct SandboxTemplate { std::string name; std::string display_name; std::string state; // ACTIVE, PROVISIONING, FAILED, ... std::string create_time; std::string update_time; ContainerCategory category = ContainerCategory::kNone; std::string image_uri; bool internet_access = false; clients::body::Json raw; // Whole document, unknown fields kept. static SandboxTemplate from_json(const clients::body::Json& doc); clients::body::Json to_json() const; }; class Templates : public SandboxService { public: explicit Templates(std::shared_ptr client, Sleeper sleeper = nullptr); SandboxTemplate create(const std::string& engine_name, const CreateTemplateRequest& request) const; SandboxTemplate get(const std::string& template_name) const; std::vector list(const std::string& engine_name, int page_size = 0) const; // Explicit delete (long-running; waited on, capped). void remove(const std::string& template_name) const; static void validate(const CreateTemplateRequest& request); static clients::body::Json create_body(const CreateTemplateRequest& request); private: Sleeper sleeper_; }; } // namespace molo::google::sandbox