databasus_ruby 0.1.0 → 0.2.0

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.
@@ -9,16 +9,30 @@ module DatabasusRuby
9
9
  class ConfigurationError < Error
10
10
  end
11
11
 
12
+ class SignInCodeRequiredError < Error
13
+ attr_reader pending_sign_in_id: String
14
+ attr_reader email: String
15
+
16
+ def initialize: (pending_sign_in_id: String, email: String) -> void
17
+ end
18
+
12
19
  class APIError < Error
13
20
  STATUS_ERRORS: Hash[Integer, singleton(APIError)]
14
21
 
15
22
  attr_reader status: Integer?
16
23
  attr_reader body: untyped
17
24
  attr_reader response: untyped
25
+ attr_reader code: String?
18
26
 
19
- def initialize: (?String? message, ?status: Integer?, ?body: untyped, ?response: untyped) -> void
20
- def self.from_response: (untyped response) -> APIError
27
+ def initialize: (?String? message, ?status: Integer?, ?body: untyped, ?response: untyped, ?code: String?) -> void
28
+ def self.from_response: (untyped response, ?body: untyped) -> APIError
21
29
  def self.for_status: (Integer status) -> singleton(APIError)
30
+
31
+ private
32
+
33
+ def self.message_from: (untyped body) -> String?
34
+ def self.problem_message: (payload problem) -> String?
35
+ def self.code_from: (untyped body) -> String?
22
36
  end
23
37
 
24
38
  class BadRequestError < APIError
@@ -43,19 +57,26 @@ module DatabasusRuby
43
57
  end
44
58
 
45
59
  class Object
46
- def initialize: (?payload attributes) -> void
60
+ def initialize: (?payload? attributes) -> void
47
61
  def to_h: () -> payload
48
- def to_hash: () -> payload
62
+ alias to_hash to_h
49
63
  def []: (String | Symbol key) -> untyped
50
64
  def key?: (String | Symbol key) -> bool
51
- def has_key?: (String | Symbol key) -> bool
65
+ alias has_key? key?
52
66
  def keys: () -> Array[String]
53
67
  def ==: (untyped other) -> bool
54
- def eql?: (untyped other) -> bool
68
+ alias eql? ==
55
69
  def hash: () -> Integer
56
70
  def inspect: () -> String
57
71
  def method_missing: (Symbol name, *untyped args) ?{ (?) -> untyped } -> untyped
58
72
  def respond_to_missing?: (Symbol name, ?bool include_private) -> bool
73
+
74
+ private
75
+
76
+ def normalize: (untyped attributes) -> payload?
77
+ def fetch_attribute: (String key) -> untyped
78
+ def wrap: (untyped value) -> untyped
79
+ def camelize: (String key) -> String
59
80
  end
60
81
 
61
82
  class Record < Object
@@ -69,37 +90,39 @@ module DatabasusRuby
69
90
  end
70
91
 
71
92
  class Database < Record
72
- def backups: (**untyped) -> Collection
93
+ def backups: (**untyped filters) -> Collection
73
94
  def backup: () -> Object
74
95
  end
75
96
 
76
97
  class Collection
77
98
  include Enumerable[Object]
78
99
 
100
+ PAGE_KEYS: Array[String]
101
+
79
102
  attr_reader data: Array[Object]
80
- attr_reader total: Integer
81
- attr_reader limit: Integer?
82
- attr_reader offset: Integer?
103
+ attr_reader next_cursor: String?
104
+ attr_reader extras: Object
83
105
 
84
106
  def initialize: (
85
107
  ?data: Array[payload | Object],
86
- ?total: Integer?,
87
- ?limit: Integer?,
88
- ?offset: Integer?,
89
- ?wrap: ^(payload) -> Object | nil
108
+ ?next_cursor: String?,
109
+ ?extras: payload | Object,
110
+ ?wrap: (^(payload) -> Object)?
90
111
  ) -> void
91
- def self.from: (untyped body, key: String, ?wrap: (^(payload) -> Object)?) -> Collection
112
+ def self.from: (untyped body, ?wrap: (^(payload) -> Object)?) -> Collection
92
113
  def each: () { (Object) -> void } -> Collection
93
114
  | () -> Enumerator[Object, Array[Object]]
94
115
  def size: () -> Integer
95
- def length: () -> Integer
116
+ alias length size
96
117
  def empty?: () -> bool
97
118
  def []: (Integer index) -> Object?
98
119
  def last: () -> Object?
99
- def paginated?: () -> bool
100
- def next_offset: () -> Integer?
101
120
  def last_page?: () -> bool
102
121
  def inspect: () -> String
122
+
123
+ private
124
+
125
+ def self.from_page: (payload page, (^(payload) -> Object)? wrap) -> Collection
103
126
  end
104
127
 
105
128
  module Endpoint
@@ -115,26 +138,24 @@ module DatabasusRuby
115
138
  def http_put: (String path, ?payload? body, ?params: payload?) -> untyped
116
139
  def http_delete: (String path, ?payload? params) -> untyped
117
140
  def object: (untyped response, ?as: singleton(Object)) -> Object
118
- def collection: (untyped response, key: String, ?as: singleton(Object)) -> Collection
141
+ def collection: (untyped response, ?as: singleton(Object)) -> Collection
119
142
  def build: (singleton(Object) klass, payload attributes) -> Object
120
- def acknowledged: (untyped response) -> bool
121
- def single_value: (untyped response) -> untyped
143
+ def acknowledged: (untyped response) -> true
122
144
  def compact: (untyped body) -> untyped
123
145
  def with_default_workspace: (payload attributes) -> payload
124
146
  def escape: (untyped segment) -> String
147
+ def require_id: (untyped segment) -> String
125
148
  end
126
149
 
127
150
  class Client
128
151
  attr_reader adapter: untyped
129
152
  attr_reader url: String
130
153
  attr_accessor api_key: String?
131
- attr_accessor agent_id: String?
132
154
  attr_accessor workspace_id: String?
133
155
 
134
156
  def initialize: (
135
157
  ?api_key: String?,
136
158
  ?url: String?,
137
- ?agent_id: String?,
138
159
  ?workspace_id: String?,
139
160
  ?adapter: untyped
140
161
  ) -> void
@@ -144,11 +165,11 @@ module DatabasusRuby
144
165
  def backups: () -> Backups
145
166
  def databases: () -> Databases
146
167
  def notifiers: () -> Notifiers
168
+ def restores: () -> Restores
147
169
  def storages: () -> Storages
148
170
  def users: () -> Users
149
171
  def workspaces: () -> Workspaces
150
172
  def workspace_id!: () -> String
151
- def agent_id!: () -> String
152
173
  def request: (
153
174
  Symbol method,
154
175
  String path,
@@ -156,49 +177,69 @@ module DatabasusRuby
156
177
  ?body: untyped,
157
178
  ?headers: Hash[String, String]?
158
179
  ) -> untyped
180
+ def stream: (String path, io: _Writer, ?params: payload?) -> Integer
159
181
  def inspect: () -> String
182
+
183
+ private
184
+
185
+ def prepare: (untyped req, ?params: payload?, ?headers: Hash[String, String]?) -> untyped
186
+ def request_headers: (Hash[String, String]? extra) -> Hash[String, String]
187
+ def normalize_url: (untyped url) -> String
188
+ def stringify: (payload params) -> Hash[String, untyped]
189
+
190
+ # Private constant in Ruby (private_constant :StreamSink).
191
+ class StreamSink
192
+ attr_reader written: Integer
193
+ attr_reader error_body: String
194
+
195
+ def initialize: (_Writer io) -> void
196
+ def to_proc: () -> ^(String chunk, Integer received, untyped env) -> untyped
197
+ def decoded_error_body: () -> untyped
198
+
199
+ private
200
+
201
+ def write: (String chunk, untyped env) -> untyped
202
+ end
160
203
  end
161
204
 
162
205
  class Auth < Object
163
206
  include Endpoint
164
207
 
165
208
  def signin: (email: String, password: String, ?cloudflare_turnstile_token: String?) -> Object
209
+ def verify_sign_in_code: (String pending_sign_in_id, code: String, ?cloudflare_turnstile_token: String?) -> Object
166
210
  def signup: (email: String, name: String, password: String, ?cloudflare_turnstile_token: String?) -> Object
167
- def github_callback: (code: String, redirect_uri: String) -> Object
168
- def google_callback: (code: String, redirect_uri: String) -> Object
169
- def send_reset_password_code: (email: String, ?cloudflare_turnstile_token: String?) -> Object
170
- def reset_password: (email: String, code: String, new_password: String) -> Object
211
+ def request_password_reset: (email: String, ?cloudflare_turnstile_token: String?) -> true
212
+ def reset_password: (email: String, code: String, new_password: String) -> true
213
+
214
+ private
215
+
216
+ def authorize: (Object result) -> Object
171
217
  end
172
218
 
173
219
  class Backups < Object
174
220
  include Endpoint
175
221
 
176
222
  STATUSES: Array[String]
177
- ENCRYPTIONS: Array[String]
178
223
  VERIFICATION_STATUSES: Array[String]
179
224
 
180
225
  def list: (
181
226
  database_id: String,
182
- ?limit: Integer?,
183
- ?offset: Integer?,
184
227
  ?status: (String | Array[String])?,
185
- ?before_date: String?,
186
- ?pg_wal_backup_type: String?
187
- ) -> Collection
188
- def all: (
189
- database_id: String,
228
+ ?created_before: String?,
190
229
  ?limit: Integer?,
191
- ?offset: Integer?,
192
- ?status: (String | Array[String])?,
193
- ?before_date: String?,
194
- ?pg_wal_backup_type: String?
230
+ ?after: String?
195
231
  ) -> Collection
232
+ alias all list
233
+ def get: (String id) -> Object
234
+ alias find get
196
235
  def create: (database_id: String) -> Object
197
- def trigger: (database_id: String) -> Object
198
- def delete: (String id) -> bool
199
- def cancel: (String id) -> bool
236
+ alias trigger create
237
+ def delete: (String id) -> true
238
+ def cancel: (String id) -> Object
200
239
  def download_token: (String id) -> Object
201
240
  def file: (String id, token: String) -> String
241
+ def download_to: (String id, _Writer io) -> Object
242
+ def file_to: (String id, _Writer io, token: String) -> Integer
202
243
  def download: (String id) -> [String, String]
203
244
  end
204
245
 
@@ -206,25 +247,19 @@ module DatabasusRuby
206
247
  include Endpoint
207
248
 
208
249
  TYPES: Array[String]
209
- HEALTH_STATUSES: Array[String]
210
250
 
211
- def list: (?workspace_id: String?) -> Collection
212
- def all: (?workspace_id: String?) -> Collection
251
+ def list: (?workspace_id: String?, ?notifier_id: String?, ?limit: Integer?, ?after: String?) -> Collection
252
+ alias all list
253
+ def list_all: (?workspace_id: String?, ?limit: Integer) -> Array[Database]
213
254
  def get: (String id) -> Database
214
- def find: (String id) -> Database
215
- def create: (**untyped) -> Database
216
- def update: (**untyped) -> Database
217
- def delete: (String id) -> bool
255
+ alias find get
256
+ def create: (**untyped attributes) -> Database
257
+ def update: (String id, **untyped attributes) -> Database
258
+ def delete: (String id) -> true
218
259
  def copy: (String id) -> Database
219
- def test_connection: (String id) -> bool
220
- def test_connection_direct: (**untyped) -> bool
221
- def create_readonly_user: (**untyped) -> Object
222
- def create_replication_only_user: (**untyped) -> Object
223
- def readonly: (**untyped) -> Object
224
- def readonly?: (**untyped) -> bool
225
- def notifier_databases_count: (String notifier_id) -> untyped
226
- def notifier_using?: (String notifier_id) -> bool
227
- def backups: (String id, **untyped) -> Collection
260
+ def test: (String id) -> Object
261
+ def connected?: (String id) -> bool
262
+ def backups: (String id, **untyped filters) -> Collection
228
263
  def backup: (String id) -> Object
229
264
  end
230
265
 
@@ -232,19 +267,45 @@ module DatabasusRuby
232
267
  include Endpoint
233
268
 
234
269
  TYPES: Array[String]
235
- NOTIFICATION_TYPES: Array[String]
236
270
 
237
- def list: (?workspace_id: String?) -> Collection
238
- def all: (?workspace_id: String?) -> Collection
271
+ def list: (?workspace_id: String?, ?limit: Integer?, ?after: String?) -> Collection
272
+ alias all list
273
+ def get: (String id) -> Object
274
+ alias find get
275
+ def create: (**untyped attributes) -> Object
276
+ def update: (String id, **untyped attributes) -> Object
277
+ def delete: (String id) -> true
278
+ def test: (String id) -> Object
279
+ def transfer: (String id, target_workspace_id: String) -> Object
280
+ end
281
+
282
+ class Restores < Object
283
+ include Endpoint
284
+
285
+ STATUSES: Array[String]
286
+ SSL_MODES: Array[String]
287
+
288
+ def self.postgresql_target: (
289
+ host: String,
290
+ port: Integer,
291
+ username: String,
292
+ password: String,
293
+ database: String,
294
+ ?ssl_mode: String,
295
+ ?cpu_count: Integer,
296
+ ?exclude_extensions: bool,
297
+ ?restore_ownership: bool,
298
+ ?restore_privileges: bool,
299
+ ?ssh_tunnel: payload?
300
+ ) -> Hash[Symbol, untyped]
301
+
302
+ def list: (backup_id: String, ?limit: Integer?, ?after: String?) -> Collection
303
+ alias all list
304
+ def start: (backup_id: String, target: payload) -> Object
305
+ alias create start
239
306
  def get: (String id) -> Object
240
- def find: (String id) -> Object
241
- def save: (**untyped) -> Object
242
- def create: (**untyped) -> Object
243
- def update: (**untyped) -> Object
244
- def delete: (String id) -> bool
245
- def test: (String id) -> bool
246
- def direct_test: (**untyped) -> bool
247
- def transfer: (String id, target_workspace_id: String) -> bool
307
+ alias find get
308
+ def cancel: (String id) -> Object
248
309
  end
249
310
 
250
311
  class Storages < Object
@@ -252,17 +313,16 @@ module DatabasusRuby
252
313
 
253
314
  TYPES: Array[String]
254
315
 
255
- def list: (?workspace_id: String?) -> Collection
256
- def all: (?workspace_id: String?) -> Collection
316
+ def list: (?workspace_id: String?, ?limit: Integer?, ?after: String?) -> Collection
317
+ alias all list
257
318
  def get: (String id) -> Object
258
- def find: (String id) -> Object
259
- def save: (**untyped) -> Object
260
- def create: (**untyped) -> Object
261
- def update: (**untyped) -> Object
262
- def delete: (String id) -> bool
263
- def test: (String id) -> bool
264
- def direct_test: (**untyped) -> bool
265
- def transfer: (String id, target_workspace_id: String) -> bool
319
+ alias find get
320
+ def create: (**untyped attributes) -> Object
321
+ def update: (String id, **untyped attributes) -> Object
322
+ def delete: (String id) -> true
323
+ def backup_usage: (String id) -> Object
324
+ def test: (String id) -> Object
325
+ def transfer: (String id, target_workspace_id: String) -> Object
266
326
  end
267
327
 
268
328
  class Users < Object
@@ -270,19 +330,17 @@ module DatabasusRuby
270
330
 
271
331
  ROLES: Array[String]
272
332
 
273
- def me: () -> Object
274
- def update_me: (?name: String?, ?email: String?) -> Object
275
- def change_password: (new_password: String) -> Object
276
- def invite: (email: String, ?intended_workspace_id: String?, ?intended_workspace_role: String?) -> Object
277
- def list: (?limit: Integer?, ?offset: Integer?, ?before_date: String?, ?query: String?) -> Collection
278
- def all: (?limit: Integer?, ?offset: Integer?, ?before_date: String?, ?query: String?) -> Collection
333
+ def list: (?query: String?, ?limit: Integer?, ?after: String?) -> Collection
334
+ alias all list
279
335
  def get: (String id) -> Object
280
- def find: (String id) -> Object
281
- def activate: (String id) -> bool
282
- def deactivate: (String id) -> bool
283
- def change_role: (String id, role: String) -> bool
336
+ alias find get
337
+ def update: (String id, name: String, email: String) -> Object
338
+ def change_password: (String id, new_password: String) -> true
339
+ def activate: (String id) -> true
340
+ def deactivate: (String id) -> true
341
+ def change_role: (String id, role: String) -> true
284
342
  def settings: () -> Object
285
- def update_settings: (**untyped) -> Object
343
+ def update_settings: (**untyped attributes) -> Object
286
344
  end
287
345
 
288
346
  class Workspaces < Object
@@ -290,18 +348,18 @@ module DatabasusRuby
290
348
 
291
349
  MEMBER_ROLES: Array[String]
292
350
 
293
- def list: () -> Collection
294
- def all: () -> Collection
351
+ def list: (?limit: Integer?, ?after: String?) -> Collection
352
+ alias all list
295
353
  def create: (name: String) -> Object
296
354
  def get: (String id) -> Object
297
- def find: (String id) -> Object
298
- def update: (String id, **untyped) -> Object
299
- def delete: (String id) -> bool
300
- def audit_logs: (String id, ?limit: Integer?, ?offset: Integer?, ?before_date: String?) -> Collection
301
- def members: (String id) -> Collection
355
+ alias find get
356
+ def update: (String id, name: String) -> Object
357
+ def delete: (String id) -> true
358
+ def transfer_ownership: (String id, new_owner_member_id: String) -> true
359
+ def audit_events: (String id, ?author_user_id: String?, ?limit: Integer?, ?after: String?) -> Collection
360
+ def members: (String id, ?limit: Integer?, ?after: String?) -> Collection
302
361
  def add_member: (String id, email: String, role: String) -> Object
303
- def remove_member: (String id, String user_id) -> bool
304
- def change_member_role: (String id, String user_id, role: String) -> bool
305
- def transfer_ownership: (String id, new_owner_email: String) -> bool
362
+ def remove_member: (String member_id) -> true
363
+ def change_member_role: (String member_id, role: String) -> Object
306
364
  end
307
365
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: databasus_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelFCorrea
@@ -48,6 +48,7 @@ files:
48
48
  - lib/databasus_ruby/objects/backups.rb
49
49
  - lib/databasus_ruby/objects/databases.rb
50
50
  - lib/databasus_ruby/objects/notifiers.rb
51
+ - lib/databasus_ruby/objects/restores.rb
51
52
  - lib/databasus_ruby/objects/storages.rb
52
53
  - lib/databasus_ruby/objects/users.rb
53
54
  - lib/databasus_ruby/objects/workspaces.rb
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  - !ruby/object:Gem::Version
78
79
  version: '0'
79
80
  requirements: []
80
- rubygems_version: 4.0.13
81
+ rubygems_version: 4.0.20
81
82
  specification_version: 4
82
83
  summary: Ruby client for the Databasus backup-management API
83
84
  test_files: []