Yandex Disk C++ Client 1.0.4
C++ client for Yandex.Disk REST API
Loading...
Searching...
No Matches
YandexDiskClient.h
1#ifndef YANDEX_DISK_CPP_CLIENT_YANDEXDISKCLIENT_H
2#define YANDEX_DISK_CPP_CLIENT_YANDEXDISKCLIENT_H
3
4#pragma once
5#include <string>
6#include <nlohmann/json.hpp>
7#include <filesystem>
8#include <map>
9
10#include "HttpClient.h"
11
16public:
21 explicit YandexDiskClient(const std::string& oauth_token);
22
28 nlohmann::json getQuotaInfo();
29
36 nlohmann::json getResourceList(const std::string& disk_path = "/");
37
44 std::string getResourceInfo(const std::string& disk_path);
45
52 bool publish(const std::string& path);
53
60 bool unpublish(const std::string& disk_path);
61
68 std::string getPublicDownloadLink(const std::string& disk_path);
69
78 const std::string& disk_dir,
79 const std::string& local_path);
80
89 const std::string& download_disk_path,
90 const std::string& local_dir);
91
100 const std::string& disk_path,
101 const std::string& local_path);
102
111 const std::string& disk_path,
112 const std::string& local_path);
113
120 bool deleteFileOrDir(const std::string& disk_path);
121
128 bool createDirectory(const std::string& disk_path);
129
139 const std::string& from_path,
140 const std::string& to_path,
141 bool overwrite = false
142 );
143
153 const std::string& disk_path,
154 const std::string& new_name,
155 bool overwrite = false);
156
162 bool exists(const std::string& disk_path);
163
170 nlohmann::json getTrashResourceList(const std::string& trash_path = "trash:/");
171
178 bool restoreFromTrash(const std::string& trash_path);
179
186 bool deleteFromTrash(const std::string& trash_path);
187
194
200 std::vector<std::string> findTrashPathByName(const std::string& name);
201
208 std::vector<std::string> findResourcePathByName(
209 const std::string& name,
210 const std::string& start_path = "/");
211
212private:
213 HttpClient http_;
214
215 std::string getUploadUrl(const std::string& upload_disk_path);
216
217 std::string getDownloadUrl(const std::string& download_disk_path);
218};
219#endif //YANDEX_DISK_CPP_CLIENT_YANDEXDISKCLIENT_H
nlohmann::json getQuotaInfo()
Get disk quota information (total, used, trash).
bool emptyTrash()
Empty the entire Yandex.Disk trash.
std::vector< std::string > findResourcePathByName(const std::string &name, const std::string &start_path="/")
Find all resources on disk by name (recursive).
bool exists(const std::string &disk_path)
Check if a file or directory exists on Yandex.Disk.
YandexDiskClient(const std::string &oauth_token)
Constructor.
bool downloadFile(const std::string &download_disk_path, const std::string &local_dir)
Download a file from Yandex.Disk to local directory.
nlohmann::json getResourceList(const std::string &disk_path="/")
Get list of files and folders at given path.
bool restoreFromTrash(const std::string &trash_path)
Restore a file or directory from trash to its original location.
std::string getPublicDownloadLink(const std::string &disk_path)
Get public download link for a published file or folder.
bool deleteFileOrDir(const std::string &disk_path)
Delete a file or directory from Yandex.Disk.
bool publish(const std::string &path)
Publish a file or folder (make it public).
bool downloadDirectory(const std::string &disk_path, const std::string &local_path)
Recursively download a directory from Yandex.Disk to local path.
bool uploadDirectory(const std::string &disk_path, const std::string &local_path)
Recursively upload a local directory to Yandex.Disk.
bool createDirectory(const std::string &disk_path)
Create a directory on Yandex.Disk.
bool uploadFile(const std::string &disk_dir, const std::string &local_path)
Upload a local file to Yandex.Disk.
std::vector< std::string > findTrashPathByName(const std::string &name)
Find all resources in trash by name.
bool unpublish(const std::string &disk_path)
Unpublish a file or folder (remove public access).
bool renameFileOrDir(const std::string &disk_path, const std::string &new_name, bool overwrite=false)
Rename a file or directory on Yandex.Disk.
nlohmann::json getTrashResourceList(const std::string &trash_path="trash:/")
Get list of files and folders in Yandex.Disk trash.
bool moveFileOrDir(const std::string &from_path, const std::string &to_path, bool overwrite=false)
Move or copy a file or directory on Yandex.Disk.
bool deleteFromTrash(const std::string &trash_path)
Permanently delete a file or directory from trash.
std::string getResourceInfo(const std::string &disk_path)
Get detailed information about a file or folder.