| 236 | } |
| 237 | |
| 238 | std::string CmdListRemoteAppIds(const std::string& provider, const std::string& accountId) { |
| 239 | std::string tokenPath = GetTokenPath(provider); |
| 240 | if (tokenPath.empty()) { |
| 241 | return JsonError("Cannot determine config directory"); |
| 242 | } |
| 243 | |
| 244 | auto prov = CreateCloudProvider(provider); |
| 245 | if (!prov) { |
| 246 | return JsonError("Unknown provider: " + provider); |
| 247 | } |
| 248 | |
| 249 | if (!prov->Init(tokenPath)) { |
| 250 | return JsonError("Failed to initialize provider"); |
| 251 | } |
| 252 | |
| 253 | if (!prov->IsAuthenticated()) { |
| 254 | prov->Shutdown(); |
| 255 | return JsonError("Not authenticated"); |
| 256 | } |
| 257 | |
| 258 | std::string prefix = accountId + "/"; |
| 259 | auto folders = prov->ListSubfolders(prefix); |
| 260 | prov->Shutdown(); |
| 261 | |
| 262 | // Build JSON array of app IDs |
| 263 | std::ostringstream ids; |
| 264 | ids << "["; |
| 265 | bool first = true; |
| 266 | for (const auto& name : folders) { |
| 267 | if (!first) ids << ","; |
| 268 | ids << JsonString(name); |
| 269 | first = false; |
| 270 | } |
| 271 | ids << "]"; |
| 272 | |
| 273 | return JsonObject({ |
| 274 | {"success", JsonBool(true)}, |
| 275 | {"app_ids", ids.str()} |
| 276 | }); |
| 277 | } |
| 278 | |
| 279 | std::string CmdListRemoteAppFiles(const std::string& provider, const std::string& accountId, const std::string& appId) { |
| 280 | std::string tokenPath = GetTokenPath(provider); |
no test coverage detected