mastodonpp  0.5.5
C++ wrapper for the Mastodon and Pleroma APIs.
api.hpp
1 /* This file is part of mastodonpp.
2  * Copyright © 2020 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODONPP_API_HPP
18 #define MASTODONPP_API_HPP
19 
20 #include <map>
21 #include <string_view>
22 #include <variant>
23 
24 namespace mastodonpp
25 {
26 
27 using std::map;
28 using std::string_view;
29 using std::variant;
30 
40 class API
41 {
42 public:
50  enum class v1
51  {
52  apps,
53  apps_verify_credentials,
54 
55  accounts,
56  accounts_verify_credentials,
57  accounts_update_credentials,
58  accounts_id,
59  accounts_id_statuses,
60  accounts_id_followers,
61  accounts_id_following,
62  accounts_id_lists,
63  accounts_id_identity_proofs,
64  accounts_id_follow,
65  accounts_id_unfollow,
66  accounts_id_block,
67  accounts_id_unblock,
68  accounts_id_mute,
69  accounts_id_unmute,
70  accounts_id_pin,
71  accounts_id_unpin,
72  accounts_relationships,
73  accounts_search,
74 
75  bookmarks,
76 
77  favourites,
78 
79  mutes,
80 
81  blocks,
82 
83  domain_blocks,
84 
85  filters,
86  filters_id,
87 
88  reports,
89 
90  follow_requests,
91  follow_requests_id_authorize,
92  follow_requests_id_reject,
93 
94  endorsements,
95 
96  featured_tags,
97  featured_tags_id,
98  featured_tags_suggestions,
99 
100  preferences,
101 
102  suggestions,
103  suggestions_account_id,
104 
105  statuses,
106  statuses_id,
107  statuses_id_context,
108  statuses_id_reblogged_by,
109  statuses_id_favourited_by,
110  statuses_id_favourite,
111  statuses_id_unfavourite,
112  statuses_id_reblog,
113  statuses_id_unreblog,
114  statuses_id_bookmark,
115  statuses_id_unbookmark,
116  statuses_id_mute,
117  statuses_id_unmute,
118  statuses_id_pin,
119  statuses_id_unpin,
120 
121  media,
122  media_id,
123 
124  polls_id,
125  polls_id_votes,
126 
127  scheduled_statuses,
128  scheduled_statuses_id,
129 
130  timelines_public,
131  timelines_tag_hashtag,
132  timelines_home,
133  timelines_list_list_id,
134 
135  conversations,
136  conversations_id,
137  conversations_id_read,
138 
139  lists,
140  lists_id,
141  lists_id_accounts,
142 
143  markers,
144 
145  streaming_health,
146  streaming_user,
147  streaming_public,
148  streaming_public_local,
149  streaming_hashtag,
150  streaming_hashtag_local,
151  streaming_list,
152  streaming_direct,
153 
154  notifications,
155  notifications_id,
156  notifications_clear,
157  notifications_id_dismiss,
158 
159  push_subscription,
160 
161  instance,
162  instance_peers,
163  instance_activity,
164 
165  trends,
166 
167  directory,
168 
169  custom_emojis,
170 
171  admin_accounts,
172  admin_accounts_id,
173  admin_accounts_account_id_action,
174  admin_accounts_id_approve,
175  admin_accounts_id_reject,
176  admin_accounts_id_enable,
177  admin_accounts_id_unsilence,
178  admin_accounts_id_unsuspend,
179  admin_reports,
180  admin_reports_id,
181  admin_reports_id_assign_to_self,
182  admin_reports_id_unassign,
183  admin_reports_id_resolve,
184  admin_reports_id_reopen,
185 
186  pleroma_notifications_read,
187  pleroma_accounts_id_subscribe,
188  pleroma_accounts_id_unsubscribe,
189  pleroma_accounts_id_favourites,
190  pleroma_accounts_update_avatar,
191  pleroma_accounts_update_banner,
192  pleroma_accounts_update_background,
193  pleroma_accounts_confirmation_resend,
194  pleroma_mascot,
195  pleroma_conversations_id_statuses,
196  pleroma_conversations_id,
197  pleroma_conversations_id_read,
198  pleroma_accounts_id_scrobbles,
199  pleroma_scrobble,
200  pleroma_statuses_id_reactions_emoji,
201  pleroma_statuses_id_reactions,
202  };
203 
211  enum class v2
212  {
213  search
214  };
215 
223  enum class oauth
224  {
225  authorize,
226  token,
227  revoke
228  };
229 
239  enum class other
240  {
241  proofs,
242  oembed
243  };
244 
252  enum class pleroma
253  {
254  admin_users,
255  admin_users_follow,
256  admin_users_unfollow,
257  admin_users_nickname_toggle_activation,
258  admin_users_tag,
259  admin_users_nickname_permission_group,
260  admin_users_nickname_permission_group_permission_group,
261  admin_users_permission_group_permission_group,
262  admin_users_activate,
263  admin_users_deactivate,
264  admin_users_nickname_or_id,
265  admin_users_nickname_or_id_statuses,
266  admin_instances_instance_statuses,
267  admin_statuses,
268  admin_relay,
269  admin_users_invite_token,
270  admin_users_invites,
271  admin_users_revoke_invite,
272  admin_users_email_invite,
273  admin_users_nickname_password_reset,
274  admin_users_nickname_update_credentials,
275  admin_users_force_password_reset,
276  admin_reports,
277  admin_grouped_reports,
278  admin_reports_id,
279  admin_reports_id_notes,
280  admin_reports_report_id_notes_id,
281  admin_statuses_id,
282  admin_restart,
283  admin_config,
284  admin_config_descriptions,
285  admin_moderation_log,
286  admin_reload_emoji,
287  admin_users_confirm_email,
288  admin_users_resend_confirm_email,
289  admin_stats,
290 
291  // No longer documented for Pleroma 2.0.0.
292  admin_users_nickname,
293  admin_users_nickname_activation_status,
294  admin_reports_id_respond,
295  admin_config_migrate_to_db,
296  admin_config_migrate_from_db,
297 
298  emoji,
299  follow_import,
300  captcha,
301  delete_account,
302  disable_account,
303  notification_settings,
304  healthcheck,
305  change_email,
306  emoji_packs,
307  emoji_packs_name,
308  emoji_packs_name_update_file,
309  emoji_packs_name_update_metadata,
310  emoji_packs_download_from,
311  emoji_packs_list_from,
312  emoji_packs_name_download_shared,
313 
314  // No longer documented for Pleroma 2.0.0.
315  account_register,
316 
317  };
318 
325  using endpoint_type = variant<v1, v2, oauth, other, pleroma>;
326 
335  explicit API(const endpoint_type &endpoint);
336 
342  [[nodiscard]] inline string_view to_string_view() const
343  {
344  return _endpoint_map.at(_endpoint);
345  }
346 
347 private:
348  const endpoint_type _endpoint;
349  static const map<endpoint_type, string_view> _endpoint_map;
350 };
351 
352 } // namespace mastodonpp
353 
354 #endif // MASTODONPP_API_HPP
mastodonpp::API::v2
v2
An enumeration of all v2 API endpoints.
Definition: api.hpp:211
mastodonpp::API::oauth
oauth
An enumeration of all oauth API endpoints.
Definition: api.hpp:223
mastodonpp::API::to_string_view
string_view to_string_view() const
Convert endpoint_type to std::string_view.
Definition: api.hpp:342
mastodonpp
C++ wrapper for the Mastodon API.
Definition: api.hpp:24
mastodonpp::API
Holds API endpoints.
Definition: api.hpp:40
mastodonpp::API::pleroma
pleroma
An enumeration of all pleroma API endpoints.
Definition: api.hpp:252
mastodonpp::API::endpoint_type
variant< v1, v2, oauth, other, pleroma > endpoint_type
Type for endpoints. Can be API::v1, API::v2, API::oauth, API::other or API::pleroma.
Definition: api.hpp:325
mastodonpp::API::v1
v1
An enumeration of all v1 API endpoints.
Definition: api.hpp:50
mastodonpp::API::other
other
An enumeration of all other API endpoints.
Definition: api.hpp:239
mastodonpp::API::API
API(const endpoint_type &endpoint)
Constructs an API object. You should never need this.
Definition: api.cpp:22