edgebase_admin 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +176 -0
- data/lib/edgebase_admin/admin_auth.rb +98 -0
- data/lib/edgebase_admin/admin_client.rb +135 -0
- data/lib/edgebase_admin/analytics_client.rb +61 -0
- data/lib/edgebase_admin/d1_client.rb +26 -0
- data/lib/edgebase_admin/functions_client.rb +46 -0
- data/lib/edgebase_admin/generated/admin_api_core.rb +503 -0
- data/lib/edgebase_admin/kv_client.rb +44 -0
- data/lib/edgebase_admin/push_client.rb +58 -0
- data/lib/edgebase_admin/vectorize_client.rb +58 -0
- data/lib/edgebase_admin.rb +5 -0
- data/llms.txt +117 -0
- metadata +75 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Auto-generated admin API Core — DO NOT EDIT.
|
|
4
|
+
#
|
|
5
|
+
# Regenerate: npx tsx tools/sdk-codegen/generate.ts
|
|
6
|
+
# Source: openapi.json (0.1.0)
|
|
7
|
+
|
|
8
|
+
require "cgi"
|
|
9
|
+
|
|
10
|
+
module EdgebaseAdmin
|
|
11
|
+
class GeneratedAdminApi
|
|
12
|
+
# Generated API methods — calls HttpClient internally.
|
|
13
|
+
|
|
14
|
+
def initialize(http)
|
|
15
|
+
@http = http
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Get user by ID — GET /api/auth/admin/users/{id}
|
|
19
|
+
def admin_auth_get_user(id)
|
|
20
|
+
@http.get("/auth/admin/users/#{CGI.escape(id).gsub('+', '%20')}")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Update user by ID — PATCH /api/auth/admin/users/{id}
|
|
24
|
+
def admin_auth_update_user(id, body = nil)
|
|
25
|
+
@http.patch("/auth/admin/users/#{CGI.escape(id).gsub('+', '%20')}", body)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Delete user by ID — DELETE /api/auth/admin/users/{id}
|
|
29
|
+
def admin_auth_delete_user(id)
|
|
30
|
+
@http.delete("/auth/admin/users/#{CGI.escape(id).gsub('+', '%20')}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# List users — GET /api/auth/admin/users
|
|
34
|
+
def admin_auth_list_users(query: nil)
|
|
35
|
+
@http.get("/auth/admin/users", params: query)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Create a new user — POST /api/auth/admin/users
|
|
39
|
+
def admin_auth_create_user(body = nil)
|
|
40
|
+
@http.post("/auth/admin/users", body)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Delete user MFA — DELETE /api/auth/admin/users/{id}/mfa
|
|
44
|
+
def admin_auth_delete_user_mfa(id)
|
|
45
|
+
@http.delete("/auth/admin/users/#{CGI.escape(id).gsub('+', '%20')}/mfa")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Set custom claims for user — PUT /api/auth/admin/users/{id}/claims
|
|
49
|
+
def admin_auth_set_claims(id, body = nil)
|
|
50
|
+
@http.put("/auth/admin/users/#{CGI.escape(id).gsub('+', '%20')}/claims", body)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Revoke all sessions for user — POST /api/auth/admin/users/{id}/revoke
|
|
54
|
+
def admin_auth_revoke_user_sessions(id)
|
|
55
|
+
@http.post("/auth/admin/users/#{CGI.escape(id).gsub('+', '%20')}/revoke")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Batch import users — POST /api/auth/admin/users/import
|
|
59
|
+
def admin_auth_import_users(body = nil)
|
|
60
|
+
@http.post("/auth/admin/users/import", body)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Broadcast to database live channel — POST /api/db/broadcast
|
|
64
|
+
def database_live_broadcast(body = nil)
|
|
65
|
+
@http.post("/db/broadcast", body)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Execute SQL via DatabaseDO — POST /api/sql
|
|
69
|
+
def execute_sql(body = nil)
|
|
70
|
+
@http.post("/sql", body)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Execute KV operation — POST /api/kv/{namespace}
|
|
74
|
+
def kv_operation(namespace, body = nil)
|
|
75
|
+
@http.post("/kv/#{CGI.escape(namespace).gsub('+', '%20')}", body)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Execute raw SQL on D1 database — POST /api/d1/{database}
|
|
79
|
+
def execute_d1_query(database, body = nil)
|
|
80
|
+
@http.post("/d1/#{CGI.escape(database).gsub('+', '%20')}", body)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Execute Vectorize operation — POST /api/vectorize/{index}
|
|
84
|
+
def vectorize_operation(index, body = nil)
|
|
85
|
+
@http.post("/vectorize/#{CGI.escape(index).gsub('+', '%20')}", body)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Send push notification to user — POST /api/push/send
|
|
89
|
+
def push_send(body = nil)
|
|
90
|
+
@http.post("/push/send", body)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Send push to multiple users — POST /api/push/send-many
|
|
94
|
+
def push_send_many(body = nil)
|
|
95
|
+
@http.post("/push/send-many", body)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Send push to specific token — POST /api/push/send-to-token
|
|
99
|
+
def push_send_to_token(body = nil)
|
|
100
|
+
@http.post("/push/send-to-token", body)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Send push to topic — POST /api/push/send-to-topic
|
|
104
|
+
def push_send_to_topic(body = nil)
|
|
105
|
+
@http.post("/push/send-to-topic", body)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Broadcast push to all devices — POST /api/push/broadcast
|
|
109
|
+
def push_broadcast(body = nil)
|
|
110
|
+
@http.post("/push/broadcast", body)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Get push notification logs — GET /api/push/logs
|
|
114
|
+
def get_push_logs(query: nil)
|
|
115
|
+
@http.get("/push/logs", params: query)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Get registered push tokens — GET /api/push/tokens
|
|
119
|
+
def get_push_tokens(query: nil)
|
|
120
|
+
@http.get("/push/tokens", params: query)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Upsert a device token — PUT /api/push/tokens
|
|
124
|
+
def put_push_tokens(body = nil)
|
|
125
|
+
@http.put("/push/tokens", body)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Update device metadata — PATCH /api/push/tokens
|
|
129
|
+
def patch_push_tokens(body = nil)
|
|
130
|
+
@http.patch("/push/tokens", body)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Query request log metrics — GET /api/analytics/query
|
|
134
|
+
def query_analytics(query: nil)
|
|
135
|
+
@http.get("/analytics/query", params: query)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Query custom events — GET /api/analytics/events
|
|
139
|
+
def query_custom_events(query: nil)
|
|
140
|
+
@http.get("/analytics/events", params: query)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Check if admin setup is needed — GET /admin/api/setup/status
|
|
144
|
+
def admin_setup_status()
|
|
145
|
+
@http.get("/admin/api/setup/status")
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Create the first admin account — POST /admin/api/setup
|
|
149
|
+
def admin_setup(body = nil)
|
|
150
|
+
@http.post("/admin/api/setup", body)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Admin login — POST /admin/api/auth/login
|
|
154
|
+
def admin_login(body = nil)
|
|
155
|
+
@http.post("/admin/api/auth/login", body)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Rotate admin token — POST /admin/api/auth/refresh
|
|
159
|
+
def admin_refresh(body = nil)
|
|
160
|
+
@http.post("/admin/api/auth/refresh", body)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Reset admin password (Service Key required) — POST /admin/api/internal/reset-password
|
|
164
|
+
def admin_reset_password(body = nil)
|
|
165
|
+
@http.post("/admin/api/internal/reset-password", body)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# List all tables from config — GET /admin/api/data/tables
|
|
169
|
+
def admin_list_tables()
|
|
170
|
+
@http.get("/admin/api/data/tables")
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# List table records with pagination — GET /admin/api/data/tables/{name}/records
|
|
174
|
+
def admin_get_table_records(name)
|
|
175
|
+
@http.get("/admin/api/data/tables/#{CGI.escape(name).gsub('+', '%20')}/records")
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Create a table record — POST /admin/api/data/tables/{name}/records
|
|
179
|
+
def admin_create_table_record(name, body = nil)
|
|
180
|
+
@http.post("/admin/api/data/tables/#{CGI.escape(name).gsub('+', '%20')}/records", body)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Update a table record — PUT /admin/api/data/tables/{name}/records/{id}
|
|
184
|
+
def admin_update_table_record(name, id, body = nil)
|
|
185
|
+
@http.put("/admin/api/data/tables/#{CGI.escape(name).gsub('+', '%20')}/records/#{CGI.escape(id).gsub('+', '%20')}", body)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Delete a table record — DELETE /admin/api/data/tables/{name}/records/{id}
|
|
189
|
+
def admin_delete_table_record(name, id)
|
|
190
|
+
@http.delete("/admin/api/data/tables/#{CGI.escape(name).gsub('+', '%20')}/records/#{CGI.escape(id).gsub('+', '%20')}")
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# List users via D1 index — GET /admin/api/data/users
|
|
194
|
+
def admin_list_users()
|
|
195
|
+
@http.get("/admin/api/data/users")
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Create a new user — POST /admin/api/data/users
|
|
199
|
+
def admin_create_user(body = nil)
|
|
200
|
+
@http.post("/admin/api/data/users", body)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Fetch a single user by ID — GET /admin/api/data/users/{id}
|
|
204
|
+
def admin_get_user(id)
|
|
205
|
+
@http.get("/admin/api/data/users/#{CGI.escape(id).gsub('+', '%20')}")
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Update user status or role — PUT /admin/api/data/users/{id}
|
|
209
|
+
def admin_update_user(id, body = nil)
|
|
210
|
+
@http.put("/admin/api/data/users/#{CGI.escape(id).gsub('+', '%20')}", body)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Delete a user completely — DELETE /admin/api/data/users/{id}
|
|
214
|
+
def admin_delete_user(id)
|
|
215
|
+
@http.delete("/admin/api/data/users/#{CGI.escape(id).gsub('+', '%20')}")
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Fetch user profile with cache — GET /admin/api/data/users/{id}/profile
|
|
219
|
+
def admin_get_user_profile(id)
|
|
220
|
+
@http.get("/admin/api/data/users/#{CGI.escape(id).gsub('+', '%20')}/profile")
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Revoke all user sessions — DELETE /admin/api/data/users/{id}/sessions
|
|
224
|
+
def admin_delete_user_sessions(id)
|
|
225
|
+
@http.delete("/admin/api/data/users/#{CGI.escape(id).gsub('+', '%20')}/sessions")
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Cleanup anonymous user index — POST /admin/api/data/cleanup-anon
|
|
229
|
+
def admin_cleanup_anon()
|
|
230
|
+
@http.post("/admin/api/data/cleanup-anon")
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# List configured storage buckets — GET /admin/api/data/storage/buckets
|
|
234
|
+
def admin_list_buckets()
|
|
235
|
+
@http.get("/admin/api/data/storage/buckets")
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# List objects in a storage bucket — GET /admin/api/data/storage/buckets/{name}/objects
|
|
239
|
+
def admin_list_bucket_objects(name)
|
|
240
|
+
@http.get("/admin/api/data/storage/buckets/#{CGI.escape(name).gsub('+', '%20')}/objects")
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Get a storage object content — GET /admin/api/data/storage/buckets/{name}/objects/{key}
|
|
244
|
+
def admin_get_bucket_object(name, key)
|
|
245
|
+
@http.get("/admin/api/data/storage/buckets/#{CGI.escape(name).gsub('+', '%20')}/objects/#{CGI.escape(key).gsub('+', '%20')}")
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Delete a storage object — DELETE /admin/api/data/storage/buckets/{name}/objects/{key}
|
|
249
|
+
def admin_delete_bucket_object(name, key)
|
|
250
|
+
@http.delete("/admin/api/data/storage/buckets/#{CGI.escape(name).gsub('+', '%20')}/objects/#{CGI.escape(key).gsub('+', '%20')}")
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Get bucket statistics (total objects and size) — GET /admin/api/data/storage/buckets/{name}/stats
|
|
254
|
+
def admin_get_bucket_stats(name)
|
|
255
|
+
@http.get("/admin/api/data/storage/buckets/#{CGI.escape(name).gsub('+', '%20')}/stats")
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Create a signed download URL for a storage object — POST /admin/api/data/storage/buckets/{name}/signed-url
|
|
259
|
+
def admin_create_signed_url(name, body = nil)
|
|
260
|
+
@http.post("/admin/api/data/storage/buckets/#{CGI.escape(name).gsub('+', '%20')}/signed-url", body)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Get full schema structure from config — GET /admin/api/data/schema
|
|
264
|
+
def admin_get_schema()
|
|
265
|
+
@http.get("/admin/api/data/schema")
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Export table data as JSON — GET /admin/api/data/tables/{name}/export
|
|
269
|
+
def admin_export_table(name)
|
|
270
|
+
@http.get("/admin/api/data/tables/#{CGI.escape(name).gsub('+', '%20')}/export")
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Get request logs — GET /admin/api/data/logs
|
|
274
|
+
def admin_get_logs()
|
|
275
|
+
@http.get("/admin/api/data/logs")
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
# Get realtime monitoring stats — GET /admin/api/data/monitoring
|
|
279
|
+
def admin_get_monitoring()
|
|
280
|
+
@http.get("/admin/api/data/monitoring")
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Get analytics dashboard data — GET /admin/api/data/analytics
|
|
284
|
+
def admin_get_analytics()
|
|
285
|
+
@http.get("/admin/api/data/analytics")
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
# Query analytics events for admin dashboard — GET /admin/api/data/analytics/events
|
|
289
|
+
def admin_get_analytics_events()
|
|
290
|
+
@http.get("/admin/api/data/analytics/events")
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# Get project overview for dashboard home — GET /admin/api/data/overview
|
|
294
|
+
def admin_get_overview()
|
|
295
|
+
@http.get("/admin/api/data/overview")
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Get dev mode status and sidecar port — GET /admin/api/data/dev-info
|
|
299
|
+
def admin_get_dev_info()
|
|
300
|
+
@http.get("/admin/api/data/dev-info")
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Execute raw SQL query — POST /admin/api/data/sql
|
|
304
|
+
def admin_execute_sql(body = nil)
|
|
305
|
+
@http.post("/admin/api/data/sql", body)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# Batch import records into a table — POST /admin/api/data/tables/{name}/import
|
|
309
|
+
def admin_import_table(name, body = nil)
|
|
310
|
+
@http.post("/admin/api/data/tables/#{CGI.escape(name).gsub('+', '%20')}/import", body)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Evaluate access rules with simulated auth context — POST /admin/api/data/rules-test
|
|
314
|
+
def admin_rules_test(body = nil)
|
|
315
|
+
@http.post("/admin/api/data/rules-test", body)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# List registered functions from config — GET /admin/api/data/functions
|
|
319
|
+
def admin_list_functions()
|
|
320
|
+
@http.get("/admin/api/data/functions")
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Get environment and config overview — GET /admin/api/data/config-info
|
|
324
|
+
def admin_get_config_info()
|
|
325
|
+
@http.get("/admin/api/data/config-info")
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
# Get recent request logs with filtering — GET /admin/api/data/logs/recent
|
|
329
|
+
def admin_get_recent_logs()
|
|
330
|
+
@http.get("/admin/api/data/logs/recent")
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# Get OAuth provider config — GET /admin/api/data/auth/settings
|
|
334
|
+
def admin_get_auth_settings()
|
|
335
|
+
@http.get("/admin/api/data/auth/settings")
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# Get email template and subject config — GET /admin/api/data/email/templates
|
|
339
|
+
def admin_get_email_templates()
|
|
340
|
+
@http.get("/admin/api/data/email/templates")
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Disable MFA for a user — DELETE /admin/api/data/users/{id}/mfa
|
|
344
|
+
def admin_delete_user_mfa(id)
|
|
345
|
+
@http.delete("/admin/api/data/users/#{CGI.escape(id).gsub('+', '%20')}/mfa")
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
# Send password reset email for a user — POST /admin/api/data/users/{id}/send-password-reset
|
|
349
|
+
def admin_send_password_reset(id)
|
|
350
|
+
@http.post("/admin/api/data/users/#{CGI.escape(id).gsub('+', '%20')}/send-password-reset")
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# Upload file to R2 storage — POST /admin/api/data/storage/buckets/{name}/upload
|
|
354
|
+
def admin_upload_file(name, body = nil)
|
|
355
|
+
@http.post("/admin/api/data/storage/buckets/#{CGI.escape(name).gsub('+', '%20')}/upload", body)
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# List push tokens for a user — GET /admin/api/data/push/tokens
|
|
359
|
+
def admin_get_push_tokens()
|
|
360
|
+
@http.get("/admin/api/data/push/tokens")
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
# Get push notification logs — GET /admin/api/data/push/logs
|
|
364
|
+
def admin_get_push_logs()
|
|
365
|
+
@http.get("/admin/api/data/push/logs")
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
# Test send push notification — POST /admin/api/data/push/test-send
|
|
369
|
+
def admin_test_push_send(body = nil)
|
|
370
|
+
@http.post("/admin/api/data/push/test-send", body)
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
# List Durable Objects for backup — POST /admin/api/data/backup/list-dos
|
|
374
|
+
def admin_backup_list_dos()
|
|
375
|
+
@http.post("/admin/api/data/backup/list-dos")
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# Dump a Durable Object for backup — POST /admin/api/data/backup/dump-do
|
|
379
|
+
def admin_backup_dump_do(body = nil)
|
|
380
|
+
@http.post("/admin/api/data/backup/dump-do", body)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
# Restore a Durable Object from backup — POST /admin/api/data/backup/restore-do
|
|
384
|
+
def admin_backup_restore_do(body = nil)
|
|
385
|
+
@http.post("/admin/api/data/backup/restore-do", body)
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# Dump D1 database for backup — POST /admin/api/data/backup/dump-d1
|
|
389
|
+
def admin_backup_dump_d1()
|
|
390
|
+
@http.post("/admin/api/data/backup/dump-d1")
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# Restore D1 database from backup — POST /admin/api/data/backup/restore-d1
|
|
394
|
+
def admin_backup_restore_d1(body = nil)
|
|
395
|
+
@http.post("/admin/api/data/backup/restore-d1", body)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
# Get backup config — GET /admin/api/data/backup/config
|
|
399
|
+
def admin_backup_get_config()
|
|
400
|
+
@http.get("/admin/api/data/backup/config")
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
# List admin accounts — GET /admin/api/data/admins
|
|
404
|
+
def admin_list_admins()
|
|
405
|
+
@http.get("/admin/api/data/admins")
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# Create an admin account — POST /admin/api/data/admins
|
|
409
|
+
def admin_create_admin(body = nil)
|
|
410
|
+
@http.post("/admin/api/data/admins", body)
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
# Delete an admin account — DELETE /admin/api/data/admins/{id}
|
|
414
|
+
def admin_delete_admin(id)
|
|
415
|
+
@http.delete("/admin/api/data/admins/#{CGI.escape(id).gsub('+', '%20')}")
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# Change admin password — PUT /admin/api/data/admins/{id}/password
|
|
419
|
+
def admin_change_password(id, body = nil)
|
|
420
|
+
@http.put("/admin/api/data/admins/#{CGI.escape(id).gsub('+', '%20')}/password", body)
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
# List all DO instances — POST /admin/api/backup/list-dos
|
|
424
|
+
def backup_list_dos(body = nil)
|
|
425
|
+
@http.post("/admin/api/backup/list-dos", body)
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# Return parsed config snapshot — GET /admin/api/backup/config
|
|
429
|
+
def backup_get_config()
|
|
430
|
+
@http.get("/admin/api/backup/config")
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
# Remove plugin-prefixed tables and migration metadata — POST /admin/api/backup/cleanup-plugin
|
|
434
|
+
def backup_cleanup_plugin(body = nil)
|
|
435
|
+
@http.post("/admin/api/backup/cleanup-plugin", body)
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
# Wipe a specific DO's data — POST /admin/api/backup/wipe-do
|
|
439
|
+
def backup_wipe_do(body = nil)
|
|
440
|
+
@http.post("/admin/api/backup/wipe-do", body)
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
# Dump a specific DO's data — POST /admin/api/backup/dump-do
|
|
444
|
+
def backup_dump_do(body = nil)
|
|
445
|
+
@http.post("/admin/api/backup/dump-do", body)
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
# Restore a specific DO's data — POST /admin/api/backup/restore-do
|
|
449
|
+
def backup_restore_do(body = nil)
|
|
450
|
+
@http.post("/admin/api/backup/restore-do", body)
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# Dump auth database tables — POST /admin/api/backup/dump-d1
|
|
454
|
+
def backup_dump_d1()
|
|
455
|
+
@http.post("/admin/api/backup/dump-d1")
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
# Restore auth database tables — POST /admin/api/backup/restore-d1
|
|
459
|
+
def backup_restore_d1(body = nil)
|
|
460
|
+
@http.post("/admin/api/backup/restore-d1", body)
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
# Dump control-plane D1 tables — POST /admin/api/backup/dump-control-d1
|
|
464
|
+
def backup_dump_control_d1()
|
|
465
|
+
@http.post("/admin/api/backup/dump-control-d1")
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
# Restore control-plane D1 tables — POST /admin/api/backup/restore-control-d1
|
|
469
|
+
def backup_restore_control_d1(body = nil)
|
|
470
|
+
@http.post("/admin/api/backup/restore-control-d1", body)
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
# Dump all tables from a data namespace — POST /admin/api/backup/dump-data
|
|
474
|
+
def backup_dump_data(body = nil)
|
|
475
|
+
@http.post("/admin/api/backup/dump-data", body)
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
# Restore all tables into a data namespace — POST /admin/api/backup/restore-data
|
|
479
|
+
def backup_restore_data(body = nil)
|
|
480
|
+
@http.post("/admin/api/backup/restore-data", body)
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
# Dump R2 storage (list or download) — POST /admin/api/backup/dump-storage
|
|
484
|
+
def backup_dump_storage(query: nil)
|
|
485
|
+
@http.get("/admin/api/backup/dump-storage", params: query)
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
# Restore R2 storage (wipe or upload) — POST /admin/api/backup/restore-storage
|
|
489
|
+
def backup_restore_storage(query: nil)
|
|
490
|
+
@http.get("/admin/api/backup/restore-storage", params: query)
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
# Resync _users_public from _users in AUTH_DB D1 — POST /admin/api/backup/resync-users-public
|
|
494
|
+
def backup_resync_users_public()
|
|
495
|
+
@http.post("/admin/api/backup/resync-users-public")
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# Export a single table as JSON — GET /admin/api/backup/export/{name}
|
|
499
|
+
def backup_export_table(name, query: nil)
|
|
500
|
+
@http.get("/admin/api/backup/export/#{CGI.escape(name).gsub('+', '%20')}", params: query)
|
|
501
|
+
end
|
|
502
|
+
end
|
|
503
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "edgebase_core"
|
|
4
|
+
|
|
5
|
+
module EdgebaseAdmin
|
|
6
|
+
# Client for a user-defined KV namespace.
|
|
7
|
+
#
|
|
8
|
+
# admin.kv("cache").set("key", "value", ttl: 300)
|
|
9
|
+
# val = admin.kv("cache").get("key")
|
|
10
|
+
class KvClient
|
|
11
|
+
def initialize(http_client, namespace)
|
|
12
|
+
@http = http_client
|
|
13
|
+
@admin_core = EdgebaseAdmin::GeneratedAdminApi.new(http_client)
|
|
14
|
+
@namespace = namespace
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Get a value by key. Returns nil if not found.
|
|
18
|
+
def get(key)
|
|
19
|
+
res = @admin_core.kv_operation(@namespace, { "action" => "get", "key" => key })
|
|
20
|
+
res["value"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Set a key-value pair with optional TTL in seconds.
|
|
24
|
+
def set(key, value, ttl: nil)
|
|
25
|
+
body = { "action" => "set", "key" => key, "value" => value }
|
|
26
|
+
body["ttl"] = ttl if ttl
|
|
27
|
+
@admin_core.kv_operation(@namespace, body)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Delete a key.
|
|
31
|
+
def delete(key)
|
|
32
|
+
@admin_core.kv_operation(@namespace, { "action" => "delete", "key" => key })
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# List keys with optional prefix, limit, and cursor.
|
|
36
|
+
def list(prefix: nil, limit: nil, cursor: nil)
|
|
37
|
+
body = { "action" => "list" }
|
|
38
|
+
body["prefix"] = prefix if prefix
|
|
39
|
+
body["limit"] = limit if limit
|
|
40
|
+
body["cursor"] = cursor if cursor
|
|
41
|
+
@admin_core.kv_operation(@namespace, body)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "edgebase_core"
|
|
4
|
+
|
|
5
|
+
module EdgebaseAdmin
|
|
6
|
+
# Client for push notification operations.
|
|
7
|
+
#
|
|
8
|
+
# result = admin.push.send("userId", { "title" => "Hello", "body" => "World" })
|
|
9
|
+
# result = admin.push.send_many(["u1", "u2"], { "title" => "News" })
|
|
10
|
+
# logs = admin.push.get_logs("userId")
|
|
11
|
+
class PushClient
|
|
12
|
+
def initialize(http_client)
|
|
13
|
+
@http = http_client
|
|
14
|
+
@admin_core = EdgebaseAdmin::GeneratedAdminApi.new(http_client)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Send a push notification to a single user's devices.
|
|
18
|
+
def send(user_id, payload)
|
|
19
|
+
@admin_core.push_send({ "userId" => user_id, "payload" => payload })
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Send a push notification to multiple users.
|
|
23
|
+
def send_many(user_ids, payload)
|
|
24
|
+
@admin_core.push_send_many({ "userIds" => user_ids, "payload" => payload })
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Send a push notification directly to a specific FCM token.
|
|
28
|
+
def send_to_token(token, payload, platform: nil)
|
|
29
|
+
body = { "token" => token, "payload" => payload }
|
|
30
|
+
body["platform"] = platform if platform
|
|
31
|
+
@admin_core.push_send_to_token(body)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Get registered device tokens for a user.
|
|
35
|
+
def get_tokens(user_id)
|
|
36
|
+
res = @admin_core.get_push_tokens(query: { "userId" => user_id })
|
|
37
|
+
res.is_a?(Hash) ? (res["items"] || []) : []
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Get push send logs for a user (last 24 hours).
|
|
41
|
+
def get_logs(user_id, limit: nil)
|
|
42
|
+
params = { "userId" => user_id }
|
|
43
|
+
params["limit"] = limit.to_s if limit
|
|
44
|
+
res = @admin_core.get_push_logs(query: params)
|
|
45
|
+
res.is_a?(Hash) ? (res["items"] || []) : []
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Send a push notification to an FCM topic.
|
|
49
|
+
def send_to_topic(topic, payload)
|
|
50
|
+
@admin_core.push_send_to_topic({ "topic" => topic, "payload" => payload })
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Broadcast a push notification to all devices via /topics/all.
|
|
54
|
+
def broadcast(payload)
|
|
55
|
+
@admin_core.push_broadcast({ "payload" => payload })
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "edgebase_core"
|
|
4
|
+
|
|
5
|
+
module EdgebaseAdmin
|
|
6
|
+
# Client for a user-defined Vectorize index.
|
|
7
|
+
#
|
|
8
|
+
# admin.vector("embeddings").upsert([{ "id" => "doc-1", "values" => [0.1, 0.2] }])
|
|
9
|
+
# results = admin.vector("embeddings").search([0.1, 0.2], top_k: 10)
|
|
10
|
+
class VectorizeClient
|
|
11
|
+
def initialize(http_client, index)
|
|
12
|
+
@http = http_client
|
|
13
|
+
@admin_core = EdgebaseAdmin::GeneratedAdminApi.new(http_client)
|
|
14
|
+
@index = index
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def upsert(vectors)
|
|
18
|
+
@admin_core.vectorize_operation(@index, { "action" => "upsert", "vectors" => vectors })
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def insert(vectors)
|
|
22
|
+
@admin_core.vectorize_operation(@index, { "action" => "insert", "vectors" => vectors })
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def search(vector, top_k: 10, filter: nil, namespace: nil, return_values: nil, return_metadata: nil)
|
|
26
|
+
body = { "action" => "search", "vector" => vector, "topK" => top_k }
|
|
27
|
+
body["filter"] = filter if filter
|
|
28
|
+
body["namespace"] = namespace if namespace
|
|
29
|
+
body["returnValues"] = return_values unless return_values.nil?
|
|
30
|
+
body["returnMetadata"] = return_metadata if return_metadata
|
|
31
|
+
res = @admin_core.vectorize_operation(@index, body)
|
|
32
|
+
res["matches"] || []
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def query_by_id(vector_id, top_k: 10, filter: nil, namespace: nil, return_values: nil, return_metadata: nil)
|
|
36
|
+
body = { "action" => "queryById", "vectorId" => vector_id, "topK" => top_k }
|
|
37
|
+
body["filter"] = filter if filter
|
|
38
|
+
body["namespace"] = namespace if namespace
|
|
39
|
+
body["returnValues"] = return_values unless return_values.nil?
|
|
40
|
+
body["returnMetadata"] = return_metadata if return_metadata
|
|
41
|
+
res = @admin_core.vectorize_operation(@index, body)
|
|
42
|
+
res["matches"] || []
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def get_by_ids(ids)
|
|
46
|
+
res = @admin_core.vectorize_operation(@index, { "action" => "getByIds", "ids" => ids })
|
|
47
|
+
res["vectors"] || []
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def delete(ids)
|
|
51
|
+
@admin_core.vectorize_operation(@index, { "action" => "delete", "ids" => ids })
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def describe
|
|
55
|
+
@admin_core.vectorize_operation(@index, { "action" => "describe" })
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|