libkazv
content-repo.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3  */
4 
5 #pragma once
6 
7 #include "basejob.hpp"
8 #include "file-desc.hpp"
9 
10 namespace Kazv::Api {
11 
15 class UploadContentJob : public BaseJob {
16 public:
17 
18 
19 
20 class JobResponse : public Response
21 {
22 
23 public:
25  bool success() const;
26 
27  // Result properties
28 
29 
30 
31 
33 std::string contentUri() const;
34 
35 };
36  static constexpr auto needsAuth() {
37  return true
38  ;
39  }
40 
41 
42 // Construction/destruction
43 
55  explicit UploadContentJob(std::string serverUrl
56  , std::string _accessToken
57  ,
58  FileDesc content , std::optional<std::string> filename = std::nullopt, std::optional<std::string> contentType = std::nullopt
59  );
60 
61 
63  std::optional<std::string> filename);
64 
65  static BaseJob::Body buildBody(FileDesc content, std::optional<std::string> filename, std::optional<std::string> contentType);
66 
67  static std::map<std::string, std::string> buildHeader(std::optional<std::string> contentType);
68 
69 
70 
73  };
75  }
76  namespace nlohmann
77  {
78  using namespace Kazv;
79  using namespace Kazv::Api;
80 
81  }
82 
83  namespace Kazv::Api
84  {
85 
89 class GetContentJob : public BaseJob {
90 public:
91 
92 
93 
94 class JobResponse : public Response
95 {
96 
97 public:
99  bool success() const;
100 
101  // Result properties
102 
104 std::optional<std::string> contentType() const
105  {
106  auto it = header->find("Content-Type");
107  if (it != header->end()) {
108  return it->second;
109  } else {
110  return std::nullopt;
111  }
112  }
113 
115 std::optional<std::string> contentDisposition() const
116  {
117  auto it = header->find("Content-Disposition");
118  if (it != header->end()) {
119  return it->second;
120  } else {
121  return std::nullopt;
122  }
123  }
124 
126  inline Body data() const
127  {
128  return body;
129  }
130 
131 
132 
133 };
134  static constexpr auto needsAuth() {
135  return
136  false;
137  }
138 
139 
140 // Construction/destruction
141 
155  explicit GetContentJob(std::string serverUrl
156 
157  ,
158  std::string serverName , std::string mediaId , bool allowRemote = true
159  , std::optional<FileDesc> downloadTo = std::nullopt);
160 
161 
162  static BaseJob::Query buildQuery(
163  bool allowRemote);
164 
165  static BaseJob::Body buildBody(std::string serverName, std::string mediaId, bool allowRemote);
166 
167 
168 
169  static const immer::array<std::string> expectedContentTypes;
170 
171  GetContentJob withData(JsonWrap j) &&;
172  GetContentJob withData(JsonWrap j) const &;
173  };
175  }
176  namespace nlohmann
177  {
178  using namespace Kazv;
179  using namespace Kazv::Api;
180 
181  }
182 
183  namespace Kazv::Api
184  {
185 
193 public:
194 
195 
196 
197 class JobResponse : public Response
198 {
199 
200 public:
202  bool success() const;
203 
204  // Result properties
205 
207 std::optional<std::string> contentType() const
208  {
209  auto it = header->find("Content-Type");
210  if (it != header->end()) {
211  return it->second;
212  } else {
213  return std::nullopt;
214  }
215  }
216 
219 std::optional<std::string> contentDisposition() const
220  {
221  auto it = header->find("Content-Disposition");
222  if (it != header->end()) {
223  return it->second;
224  } else {
225  return std::nullopt;
226  }
227  }
228 
230  inline Body data() const
231  {
232  return body;
233  }
234 
235 
236 
237 };
238  static constexpr auto needsAuth() {
239  return
240  false;
241  }
242 
243 
244 // Construction/destruction
245 
262  explicit GetContentOverrideNameJob(std::string serverUrl
263 
264  ,
265  std::string serverName , std::string mediaId , std::string fileName , bool allowRemote = true
266  , std::optional<FileDesc> downloadTo = std::nullopt);
267 
268 
269  static BaseJob::Query buildQuery(
270  bool allowRemote);
271 
272  static BaseJob::Body buildBody(std::string serverName, std::string mediaId, std::string fileName, bool allowRemote);
273 
274 
275 
276  static const immer::array<std::string> expectedContentTypes;
277 
278  GetContentOverrideNameJob withData(JsonWrap j) &&;
279  GetContentOverrideNameJob withData(JsonWrap j) const &;
280  };
282  }
283  namespace nlohmann
284  {
285  using namespace Kazv;
286  using namespace Kazv::Api;
287 
288  }
289 
290  namespace Kazv::Api
291  {
292 
299 public:
300 
301 
302 
303 class JobResponse : public Response
304 {
305 
306 public:
308  bool success() const;
309 
310  // Result properties
311 
313 std::optional<std::string> contentType() const
314  {
315  auto it = header->find("Content-Type");
316  if (it != header->end()) {
317  return it->second;
318  } else {
319  return std::nullopt;
320  }
321  }
322 
324  inline Body data() const
325  {
326  return body;
327  }
328 
329 
330 
331 };
332  static constexpr auto needsAuth() {
333  return
334  false;
335  }
336 
337 
338 // Construction/destruction
339 
365  explicit GetContentThumbnailJob(std::string serverUrl
366 
367  ,
368  std::string serverName , std::string mediaId , int width , int height , std::optional<std::string> method = std::nullopt, bool allowRemote = true
369  , std::optional<FileDesc> downloadTo = std::nullopt);
370 
371 
372  static BaseJob::Query buildQuery(
373  int width, int height, std::optional<std::string> method, bool allowRemote);
374 
375  static BaseJob::Body buildBody(std::string serverName, std::string mediaId, int width, int height, std::optional<std::string> method, bool allowRemote);
376 
377 
378 
379  static const immer::array<std::string> expectedContentTypes;
380 
381  GetContentThumbnailJob withData(JsonWrap j) &&;
382  GetContentThumbnailJob withData(JsonWrap j) const &;
383  };
385  }
386  namespace nlohmann
387  {
388  using namespace Kazv;
389  using namespace Kazv::Api;
390 
391  }
392 
393  namespace Kazv::Api
394  {
395 
407 class GetUrlPreviewJob : public BaseJob {
408 public:
409 
410 
411 
412 class JobResponse : public Response
413 {
414 
415 public:
417  bool success() const;
418 
419  // Result properties
420 
421 
422 
423 
425 std::optional<std::int_fast64_t> matrixImageSize() const;
426 
427 
429 std::optional<std::string> ogImage() const;
430 
431 };
432  static constexpr auto needsAuth() {
433  return true
434  ;
435  }
436 
437 
438 // Construction/destruction
439 
450  explicit GetUrlPreviewJob(std::string serverUrl
451  , std::string _accessToken
452  ,
453  std::string url , std::optional<std::int_fast64_t> ts = std::nullopt
454  );
455 
456 
457  static BaseJob::Query buildQuery(
458  std::string url, std::optional<std::int_fast64_t> ts);
459 
460  static BaseJob::Body buildBody(std::string url, std::optional<std::int_fast64_t> ts);
461 
462 
463 
464 
465 
466  GetUrlPreviewJob withData(JsonWrap j) &&;
467  GetUrlPreviewJob withData(JsonWrap j) const &;
468  };
470  }
471  namespace nlohmann
472  {
473  using namespace Kazv;
474  using namespace Kazv::Api;
475 
476  }
477 
478  namespace Kazv::Api
479  {
480 
494 class GetConfigJob : public BaseJob {
495 public:
496 
497 
498 
499 class JobResponse : public Response
500 {
501 
502 public:
504  bool success() const;
505 
506  // Result properties
507 
508 
509 
510 
514 std::optional<std::int_fast64_t> uploadSize() const;
515 
516 };
517  static constexpr auto needsAuth() {
518  return true
519  ;
520  }
521 
522 
523 // Construction/destruction
524 
526  explicit GetConfigJob(std::string serverUrl
527  , std::string _accessToken
528 
529 
530  );
531 
532 
533  static BaseJob::Query buildQuery(
534  );
535 
536  static BaseJob::Body buildBody();
537 
538 
539 
540 
541 
542  GetConfigJob withData(JsonWrap j) &&;
543  GetConfigJob withData(JsonWrap j) const &;
544  };
546  }
547  namespace nlohmann
548  {
549  using namespace Kazv;
550  using namespace Kazv::Api;
551 
552  }
553 
554  namespace Kazv::Api
555  {
556 
557 } // namespace Kazv::Api
Kazv::Api::UploadContentJob::buildHeader
static std::map< std::string, std::string > buildHeader(std::optional< std::string > contentType)
Definition: content-repo.cpp:14
Kazv::Api::UploadContentJob::UploadContentJob
UploadContentJob(std::string serverUrl, std::string _accessToken, FileDesc content, std::optional< std::string > filename=std::nullopt, std::optional< std::string > contentType=std::nullopt)
Upload some content to the content repository.
Definition: content-repo.cpp:46
Kazv::Api::GetContentThumbnailJob::JobResponse
Definition: content-repo.hpp:303
Kazv::Api::GetConfigJob
Get the configuration for the content repository.
Definition: content-repo.hpp:494
Kazv::Api::GetContentOverrideNameJob
Download content from the content repository overriding the file name.
Definition: content-repo.hpp:192
Kazv::Api::GetUrlPreviewJob::JobResponse
Definition: content-repo.hpp:412
Kazv::Api::GetContentThumbnailJob::needsAuth
static constexpr auto needsAuth()
Definition: content-repo.hpp:332
Kazv::Api::GetContentOverrideNameJob::JobResponse::data
Body data() const
The content that was previously uploaded.
Definition: content-repo.hpp:230
Kazv::Api::GetContentThumbnailJob::JobResponse::data
Body data() const
A thumbnail of the requested content.
Definition: content-repo.hpp:324
Kazv::Api::GetContentJob::JobResponse::data
Body data() const
The content that was previously uploaded.
Definition: content-repo.hpp:126
Kazv::Api::GetContentJob::JobResponse
Definition: content-repo.hpp:94
Kazv::Api::UploadContentJob::withData
UploadContentJob withData(JsonWrap j) &&
Definition: content-repo.cpp:68
nlohmann
Definition: location.hpp:26
Kazv::Api::GetContentOverrideNameJob::JobResponse::contentDisposition
std::optional< std::string > contentDisposition() const
The fileName requested or the name of the file that was previously uploaded, if set.
Definition: content-repo.hpp:219
file-desc.hpp
Kazv::Api::GetContentJob::needsAuth
static constexpr auto needsAuth()
Definition: content-repo.hpp:134
Kazv::Api::GetContentOverrideNameJob::expectedContentTypes
static const immer::array< std::string > expectedContentTypes
Definition: content-repo.hpp:276
Kazv::Api::GetConfigJob::needsAuth
static constexpr auto needsAuth()
Definition: content-repo.hpp:517
Kazv
Definition: location.hpp:10
Kazv::Api::GetContentOverrideNameJob::JobResponse::contentType
std::optional< std::string > contentType() const
The content type of the file that was previously uploaded.
Definition: content-repo.hpp:207
Kazv::BaseJob::Query
Definition: basejob.hpp:90
Kazv::Api::GetContentJob::JobResponse::contentType
std::optional< std::string > contentType() const
The content type of the file that was previously uploaded.
Definition: content-repo.hpp:104
Kazv::Api::GetContentThumbnailJob
Download a thumbnail of content from the content repository.
Definition: content-repo.hpp:298
Kazv::Api::UploadContentJob::JobResponse::success
bool success() const
Definition: content-repo.cpp:85
Kazv::Api::UploadContentJob::needsAuth
static constexpr auto needsAuth()
Definition: content-repo.hpp:40
Kazv::Api::GetContentJob::JobResponse::contentDisposition
std::optional< std::string > contentDisposition() const
The name of the file that was previously uploaded, if set.
Definition: content-repo.hpp:115
Kazv::Api::GetContentJob::expectedContentTypes
static const immer::array< std::string > expectedContentTypes
Definition: content-repo.hpp:169
Kazv::Api::GetContentThumbnailJob::JobResponse::contentType
std::optional< std::string > contentType() const
The content type of the thumbnail.
Definition: content-repo.hpp:313
Kazv::Api
Definition: location.hpp:10
Kazv::Api::GetConfigJob::JobResponse
Definition: content-repo.hpp:499
Kazv::Api::UploadContentJob::JobResponse::JobResponse
JobResponse(Response r)
Definition: content-repo.cpp:82
Kazv::Api::UploadContentJob::buildQuery
static BaseJob::Query buildQuery(std::optional< std::string > filename)
Definition: content-repo.cpp:24
Kazv::Api::UploadContentJob::JobResponse
Definition: content-repo.hpp:24
basejob.hpp
Kazv::Api::GetContentJob
Download content from the content repository.
Definition: content-repo.hpp:89
Kazv::Api::GetUrlPreviewJob::needsAuth
static constexpr auto needsAuth()
Definition: content-repo.hpp:432
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::Api::UploadContentJob::buildBody
static BaseJob::Body buildBody(FileDesc content, std::optional< std::string > filename, std::optional< std::string > contentType)
Definition: content-repo.cpp:33
Kazv::Api::GetContentThumbnailJob::expectedContentTypes
static const immer::array< std::string > expectedContentTypes
Definition: content-repo.hpp:379
Kazv::BaseJob
Definition: basejob.hpp:76
Kazv::Api::UploadContentJob
Upload some content to the content repository.
Definition: content-repo.hpp:17
Kazv::Api::GetContentOverrideNameJob::needsAuth
static constexpr auto needsAuth()
Definition: content-repo.hpp:238
Kazv::BaseJob::Body
::Kazv::Body Body
Definition: basejob.hpp:100
Kazv::FileDesc
Definition: file-desc.hpp:224
Kazv::Api::UploadContentJob::JobResponse::contentUri
std::string contentUri() const
The MXC URI to the uploaded content.
Definition: content-repo.cpp:96
Kazv::Api::GetContentOverrideNameJob::JobResponse
Definition: content-repo.hpp:197
Kazv::Api::GetUrlPreviewJob
Get information about a URL for a client.
Definition: content-repo.hpp:407
Kazv::Response
Definition: basejob.hpp:50