libQuotient
A Qt library for building matrix clients
device_management.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/csapi/definitions/auth_data.h>
6 #include <Quotient/csapi/definitions/client_device.h>
7 
8 #include <Quotient/jobs/basejob.h>
9 
10 namespace Quotient {
11 
12 //! \brief List registered devices for the current user
13 //!
14 //! Gets information about all devices for the current user.
15 class QUOTIENT_API GetDevicesJob : public BaseJob {
16 public:
17  explicit GetDevicesJob();
18 
19  //! \brief Construct a URL without creating a full-fledged job object
20  //!
21  //! This function can be used when a URL for GetDevicesJob
22  //! is necessary but the job itself isn't.
23  static QUrl makeRequestUrl(const HomeserverData& hsData);
24 
25  // Result properties
26 
27  //! A list of all registered devices for this user.
28  QVector<Device> devices() const { return loadFromJson<QVector<Device>>("devices"_L1); }
29 };
30 
31 inline auto collectResponse(const GetDevicesJob* job) { return job->devices(); }
32 
33 //! \brief Get a single device
34 //!
35 //! Gets information on a single device, by device id.
36 class QUOTIENT_API GetDeviceJob : public BaseJob {
37 public:
38  //! \param deviceId
39  //! The device to retrieve.
40  explicit GetDeviceJob(const QString& deviceId);
41 
42  //! \brief Construct a URL without creating a full-fledged job object
43  //!
44  //! This function can be used when a URL for GetDeviceJob
45  //! is necessary but the job itself isn't.
46  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& deviceId);
47 
48  // Result properties
49 
50  //! Device information
51  Device device() const { return fromJson<Device>(jsonData()); }
52 };
53 
54 inline auto collectResponse(const GetDeviceJob* job) { return job->device(); }
55 
56 //! \brief Update a device
57 //!
58 //! Updates the metadata on the given device.
59 class QUOTIENT_API UpdateDeviceJob : public BaseJob {
60 public:
61  //! \param deviceId
62  //! The device to update.
63  //!
64  //! \param displayName
65  //! The new display name for this device. If not given, the
66  //! display name is unchanged.
67  explicit UpdateDeviceJob(const QString& deviceId, const QString& displayName = {});
68 };
69 
70 //! \brief Delete a device
71 //!
72 //! This API endpoint uses the [User-Interactive Authentication
73 //! API](/client-server-api/#user-interactive-authentication-api).
74 //!
75 //! Deletes the given device, and invalidates any access token associated with it.
76 class QUOTIENT_API DeleteDeviceJob : public BaseJob {
77 public:
78  //! \param deviceId
79  //! The device to delete.
80  //!
81  //! \param auth
82  //! Additional authentication information for the
83  //! user-interactive authentication API.
84  explicit DeleteDeviceJob(const QString& deviceId,
85  const std::optional<AuthenticationData>& auth = std::nullopt);
86 };
87 
88 //! \brief Bulk deletion of devices
89 //!
90 //! This API endpoint uses the [User-Interactive Authentication
91 //! API](/client-server-api/#user-interactive-authentication-api).
92 //!
93 //! Deletes the given devices, and invalidates any access token associated with them.
94 class QUOTIENT_API DeleteDevicesJob : public BaseJob {
95 public:
96  //! \param devices
97  //! The list of device IDs to delete.
98  //!
99  //! \param auth
100  //! Additional authentication information for the
101  //! user-interactive authentication API.
102  explicit DeleteDevicesJob(const QStringList& devices,
103  const std::optional<AuthenticationData>& auth = std::nullopt);
104 };
105 
106 } // namespace Quotient