#pragma once // The operations methods Discovery offers on the three sandbox resources // (sandboxEnvironments, sandboxEnvironmentTemplates, sandboxEnvironmentSnapshots): // get, wait, cancel, delete (v1) and list (v1beta1 only). Lifecycle calls in // this module already poll operations internally; these are the explicit, // caller-driven forms. cancel and remove(delete) are explicit methods. #include #include #include "google/operation.h" #include "google/sandbox/sandbox_service.h" namespace molo::google::sandbox { class Operations : public SandboxService { public: explicit Operations(std::shared_ptr client); // GET {name} Operation get(const std::string& operation_name) const; // POST {name}:wait?timeout=Ns. Server-side wait of at most // SandboxCaps::kMaxOperationWaitSeconds (1..), then returns the operation as // it is (done or not). Operation wait(const std::string& operation_name, int timeout_seconds) const; // POST {name}:cancel (best effort on Google's side). void cancel(const std::string& operation_name) const; // DELETE {name}: removes the operation record, not the resource. void remove(const std::string& operation_name) const; // GET {resource}/operations (v1beta1), pages capped. std::vector list(const std::string& resource_name, int page_size = 0) const; static clients::body::Json to_json(const Operation& op); static std::string wait_query(int timeout_seconds); // "?timeout=30s" }; } // namespace molo::google::sandbox