// Copyright Epic Games, Inc. All Rights Reserved. #include "cache.h" #include #include #include #include #include ZEN_THIRD_PARTY_INCLUDES_START #include ZEN_THIRD_PARTY_INCLUDES_END DropCommand::DropCommand() { m_Options.add_options()("h,help", "Print help"); m_Options.add_option("", "n", "namespace", "Namnspace name", cxxopts::value(m_NamespaceName), ""); m_Options.add_option("", "b", "bucket", "Bucket name", cxxopts::value(m_BucketName), ""); } DropCommand::~DropCommand() = default; int DropCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { ZEN_UNUSED(GlobalOptions, argc, argv); m_Options.parse_positional({"namespace", "bucket"}); m_Options.parse(argc, argv); if (m_NamespaceName.empty()) { throw cxxopts::OptionParseException("Drop command requires a namespace"); } cpr::Session Session; if (m_BucketName.empty()) { ZEN_CONSOLE("Dropping cache namespace '{}' from '{}'", m_NamespaceName, m_HostName); Session.SetUrl({fmt::format("{}/z$/{}", m_HostName, m_NamespaceName)}); } else { ZEN_CONSOLE("Dropping cache bucket '{}/{}' from '{}'", m_NamespaceName, m_BucketName, m_HostName); Session.SetUrl({fmt::format("{}/z$/{}/{}", m_HostName, m_NamespaceName, m_BucketName)}); } cpr::Response Result = Session.Delete(); if (zen::IsHttpSuccessCode(Result.status_code)) { ZEN_CONSOLE("OK: drop succeeded"); return 0; } if (Result.status_code) { ZEN_ERROR("Drop failed: {}: {} ({})", Result.status_code, Result.reason, Result.text); } else { ZEN_ERROR("Drop failed: {}", Result.error.message); } return 1; }