databasus_ruby 0.0.1

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.
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ require_relative "databasus_ruby/version"
6
+
7
+ # Ruby client for the Databasus backup-management API.
8
+ #
9
+ # client = DatabasusRuby::Client.new(api_key: ENV["DATABASUS_API_KEY"],
10
+ # url: "https://databasus.example.com/api/v1/")
11
+ # client.databases.list(workspace_id: workspace_id)
12
+ #
13
+ # See DatabasusRuby::Client for how the endpoint domains hang off the client.
14
+ module DatabasusRuby
15
+ autoload :Client, "databasus_ruby/client"
16
+ autoload :Collection, "databasus_ruby/collection"
17
+ autoload :Endpoint, "databasus_ruby/endpoint"
18
+ autoload :Object, "databasus_ruby/object"
19
+
20
+ autoload :Error, "databasus_ruby/error"
21
+ autoload :ConfigurationError, "databasus_ruby/error"
22
+ autoload :APIError, "databasus_ruby/error"
23
+ autoload :BadRequestError, "databasus_ruby/error"
24
+ autoload :AuthenticationError, "databasus_ruby/error"
25
+ autoload :ForbiddenError, "databasus_ruby/error"
26
+ autoload :NotFoundError, "databasus_ruby/error"
27
+ autoload :ConflictError, "databasus_ruby/error"
28
+ autoload :RateLimitError, "databasus_ruby/error"
29
+ autoload :ServerError, "databasus_ruby/error"
30
+
31
+ autoload :Auth, "databasus_ruby/objects/auth"
32
+ autoload :Backups, "databasus_ruby/objects/backups"
33
+ autoload :Databases, "databasus_ruby/objects/databases"
34
+ autoload :Notifiers, "databasus_ruby/objects/notifiers"
35
+ autoload :Storages, "databasus_ruby/objects/storages"
36
+ autoload :Users, "databasus_ruby/objects/users"
37
+ autoload :Workspaces, "databasus_ruby/objects/workspaces"
38
+ end
@@ -0,0 +1,285 @@
1
+ module DatabasusRuby
2
+ VERSION: String
3
+
4
+ type payload = Hash[untyped, untyped]
5
+
6
+ class Error < StandardError
7
+ end
8
+
9
+ class ConfigurationError < Error
10
+ end
11
+
12
+ class APIError < Error
13
+ STATUS_ERRORS: Hash[Integer, singleton(APIError)]
14
+
15
+ attr_reader status: Integer?
16
+ attr_reader body: untyped
17
+ attr_reader response: untyped
18
+
19
+ def initialize: (?String? message, ?status: Integer?, ?body: untyped, ?response: untyped) -> void
20
+ def self.from_response: (untyped response) -> APIError
21
+ def self.for_status: (Integer status) -> singleton(APIError)
22
+ end
23
+
24
+ class BadRequestError < APIError
25
+ end
26
+
27
+ class AuthenticationError < APIError
28
+ end
29
+
30
+ class ForbiddenError < APIError
31
+ end
32
+
33
+ class NotFoundError < APIError
34
+ end
35
+
36
+ class ConflictError < APIError
37
+ end
38
+
39
+ class RateLimitError < APIError
40
+ end
41
+
42
+ class ServerError < APIError
43
+ end
44
+
45
+ class Object
46
+ def initialize: (?payload attributes) -> void
47
+ def to_h: () -> payload
48
+ def to_hash: () -> payload
49
+ def []: (String | Symbol key) -> untyped
50
+ def key?: (String | Symbol key) -> bool
51
+ def has_key?: (String | Symbol key) -> bool
52
+ def keys: () -> Array[String]
53
+ def ==: (untyped other) -> bool
54
+ def eql?: (untyped other) -> bool
55
+ def hash: () -> Integer
56
+ def inspect: () -> String
57
+ def method_missing: (Symbol name, *untyped args) ?{ (?) -> untyped } -> untyped
58
+ def respond_to_missing?: (Symbol name, ?bool include_private) -> bool
59
+ end
60
+
61
+ class Collection
62
+ include Enumerable[Object]
63
+
64
+ attr_reader data: Array[Object]
65
+ attr_reader total: Integer
66
+ attr_reader limit: Integer?
67
+ attr_reader offset: Integer?
68
+
69
+ def initialize: (?data: Array[payload | Object], ?total: Integer?, ?limit: Integer?, ?offset: Integer?) -> void
70
+ def self.from: (untyped body, key: String) -> Collection
71
+ def each: () { (Object) -> void } -> Collection
72
+ | () -> Enumerator[Object, Array[Object]]
73
+ def size: () -> Integer
74
+ def length: () -> Integer
75
+ def empty?: () -> bool
76
+ def []: (Integer index) -> Object?
77
+ def last: () -> Object?
78
+ def paginated?: () -> bool
79
+ def next_offset: () -> Integer?
80
+ def last_page?: () -> bool
81
+ def inspect: () -> String
82
+ end
83
+
84
+ module Endpoint
85
+ attr_reader client: Client
86
+
87
+ def initialize: (Client client) -> void
88
+ def inspect: () -> String
89
+
90
+ private
91
+
92
+ def http_get: (String path, ?payload? params) -> untyped
93
+ def http_post: (String path, ?payload? body, ?params: payload?) -> untyped
94
+ def http_put: (String path, ?payload? body, ?params: payload?) -> untyped
95
+ def http_delete: (String path, ?payload? params) -> untyped
96
+ def object: (untyped response) -> Object
97
+ def collection: (untyped response, key: String) -> Collection
98
+ def acknowledged: (untyped response) -> bool
99
+ def single_value: (untyped response) -> untyped
100
+ def compact: (untyped body) -> untyped
101
+ def with_default_workspace: (payload attributes) -> payload
102
+ def escape: (untyped segment) -> String
103
+ end
104
+
105
+ class Client
106
+ attr_reader adapter: untyped
107
+ attr_reader url: String
108
+ attr_accessor api_key: String?
109
+ attr_accessor agent_id: String?
110
+ attr_accessor workspace_id: String?
111
+
112
+ def initialize: (
113
+ ?api_key: String?,
114
+ ?url: String?,
115
+ ?agent_id: String?,
116
+ ?workspace_id: String?,
117
+ ?adapter: untyped
118
+ ) -> void
119
+
120
+ def connection: () -> untyped
121
+ def auth: () -> Auth
122
+ def backups: () -> Backups
123
+ def databases: () -> Databases
124
+ def notifiers: () -> Notifiers
125
+ def storages: () -> Storages
126
+ def users: () -> Users
127
+ def workspaces: () -> Workspaces
128
+ def workspace_id!: () -> String
129
+ def agent_id!: () -> String
130
+ def request: (
131
+ Symbol method,
132
+ String path,
133
+ ?params: payload?,
134
+ ?body: untyped,
135
+ ?headers: Hash[String, String]?
136
+ ) -> untyped
137
+ def inspect: () -> String
138
+ end
139
+
140
+ class Auth < Object
141
+ include Endpoint
142
+
143
+ def signin: (email: String, password: String, ?cloudflare_turnstile_token: String?) -> Object
144
+ def signup: (email: String, name: String, password: String, ?cloudflare_turnstile_token: String?) -> Object
145
+ def github_callback: (code: String, redirect_uri: String) -> Object
146
+ def google_callback: (code: String, redirect_uri: String) -> Object
147
+ def send_reset_password_code: (email: String, ?cloudflare_turnstile_token: String?) -> Object
148
+ def reset_password: (email: String, code: String, new_password: String) -> Object
149
+ end
150
+
151
+ class Backups < Object
152
+ include Endpoint
153
+
154
+ STATUSES: Array[String]
155
+ ENCRYPTIONS: Array[String]
156
+ VERIFICATION_STATUSES: Array[String]
157
+
158
+ def list: (
159
+ database_id: String,
160
+ ?limit: Integer?,
161
+ ?offset: Integer?,
162
+ ?status: (String | Array[String])?,
163
+ ?before_date: String?,
164
+ ?pg_wal_backup_type: String?
165
+ ) -> Collection
166
+ def all: (
167
+ database_id: String,
168
+ ?limit: Integer?,
169
+ ?offset: Integer?,
170
+ ?status: (String | Array[String])?,
171
+ ?before_date: String?,
172
+ ?pg_wal_backup_type: String?
173
+ ) -> Collection
174
+ def create: (database_id: String) -> Object
175
+ def trigger: (database_id: String) -> Object
176
+ def delete: (String id) -> bool
177
+ def cancel: (String id) -> bool
178
+ def download_token: (String id) -> Object
179
+ def file: (String id, token: String) -> String
180
+ def download: (String id) -> [String, String]
181
+ end
182
+
183
+ class Databases < Object
184
+ include Endpoint
185
+
186
+ TYPES: Array[String]
187
+ HEALTH_STATUSES: Array[String]
188
+
189
+ def list: (?workspace_id: String?) -> Collection
190
+ def all: (?workspace_id: String?) -> Collection
191
+ def get: (String id) -> Object
192
+ def find: (String id) -> Object
193
+ def create: (**untyped) -> Object
194
+ def update: (**untyped) -> Object
195
+ def delete: (String id) -> bool
196
+ def copy: (String id) -> Object
197
+ def test_connection: (String id) -> bool
198
+ def test_connection_direct: (**untyped) -> bool
199
+ def create_readonly_user: (**untyped) -> Object
200
+ def create_replication_only_user: (**untyped) -> Object
201
+ def readonly: (**untyped) -> Object
202
+ def readonly?: (**untyped) -> bool
203
+ def notifier_databases_count: (String notifier_id) -> untyped
204
+ def notifier_using?: (String notifier_id) -> bool
205
+ def backups: (String id, **untyped) -> Collection
206
+ def backup: (String id) -> Object
207
+ end
208
+
209
+ class Notifiers < Object
210
+ include Endpoint
211
+
212
+ TYPES: Array[String]
213
+ NOTIFICATION_TYPES: Array[String]
214
+
215
+ def list: (?workspace_id: String?) -> Collection
216
+ def all: (?workspace_id: String?) -> Collection
217
+ def get: (String id) -> Object
218
+ def find: (String id) -> Object
219
+ def save: (**untyped) -> Object
220
+ def create: (**untyped) -> Object
221
+ def update: (**untyped) -> Object
222
+ def delete: (String id) -> bool
223
+ def test: (String id) -> bool
224
+ def direct_test: (**untyped) -> bool
225
+ def transfer: (String id, target_workspace_id: String) -> bool
226
+ end
227
+
228
+ class Storages < Object
229
+ include Endpoint
230
+
231
+ TYPES: Array[String]
232
+
233
+ def list: (?workspace_id: String?) -> Collection
234
+ def all: (?workspace_id: String?) -> Collection
235
+ def get: (String id) -> Object
236
+ def find: (String id) -> Object
237
+ def save: (**untyped) -> Object
238
+ def create: (**untyped) -> Object
239
+ def update: (**untyped) -> Object
240
+ def delete: (String id) -> bool
241
+ def test: (String id) -> bool
242
+ def direct_test: (**untyped) -> bool
243
+ def transfer: (String id, target_workspace_id: String) -> bool
244
+ end
245
+
246
+ class Users < Object
247
+ include Endpoint
248
+
249
+ ROLES: Array[String]
250
+
251
+ def me: () -> Object
252
+ def update_me: (?name: String?, ?email: String?) -> Object
253
+ def change_password: (new_password: String) -> Object
254
+ def invite: (email: String, ?intended_workspace_id: String?, ?intended_workspace_role: String?) -> Object
255
+ def list: (?limit: Integer?, ?offset: Integer?, ?before_date: String?, ?query: String?) -> Collection
256
+ def all: (?limit: Integer?, ?offset: Integer?, ?before_date: String?, ?query: String?) -> Collection
257
+ def get: (String id) -> Object
258
+ def find: (String id) -> Object
259
+ def activate: (String id) -> bool
260
+ def deactivate: (String id) -> bool
261
+ def change_role: (String id, role: String) -> bool
262
+ def settings: () -> Object
263
+ def update_settings: (**untyped) -> Object
264
+ end
265
+
266
+ class Workspaces < Object
267
+ include Endpoint
268
+
269
+ MEMBER_ROLES: Array[String]
270
+
271
+ def list: () -> Collection
272
+ def all: () -> Collection
273
+ def create: (name: String) -> Object
274
+ def get: (String id) -> Object
275
+ def find: (String id) -> Object
276
+ def update: (String id, **untyped) -> Object
277
+ def delete: (String id) -> bool
278
+ def audit_logs: (String id, ?limit: Integer?, ?offset: Integer?, ?before_date: String?) -> Collection
279
+ def members: (String id) -> Collection
280
+ def add_member: (String id, email: String, role: String) -> Object
281
+ def remove_member: (String id, String user_id) -> bool
282
+ def change_member_role: (String id, String user_id, role: String) -> bool
283
+ def transfer_ownership: (String id, new_owner_email: String) -> bool
284
+ end
285
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: databasus_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - SamuelFCorrea
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: faraday
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '2.3'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '2.3'
26
+ description: |
27
+ A Ruby wrapper around the Databasus HTTP API. Covers workspaces, databases,
28
+ logical backups, storages, notifiers, users and authentication, exposing
29
+ each domain as an endpoint object hanging off DatabasusRuby::Client.
30
+ email:
31
+ - samuelfelipecorrea@gmail.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - CHANGELOG.md
37
+ - CODE_OF_CONDUCT.md
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - lib/databasus_ruby.rb
42
+ - lib/databasus_ruby/client.rb
43
+ - lib/databasus_ruby/collection.rb
44
+ - lib/databasus_ruby/endpoint.rb
45
+ - lib/databasus_ruby/error.rb
46
+ - lib/databasus_ruby/object.rb
47
+ - lib/databasus_ruby/objects/auth.rb
48
+ - lib/databasus_ruby/objects/backups.rb
49
+ - lib/databasus_ruby/objects/databases.rb
50
+ - lib/databasus_ruby/objects/notifiers.rb
51
+ - lib/databasus_ruby/objects/storages.rb
52
+ - lib/databasus_ruby/objects/users.rb
53
+ - lib/databasus_ruby/objects/workspaces.rb
54
+ - lib/databasus_ruby/version.rb
55
+ - sig/databasus_ruby.rbs
56
+ homepage: https://github.com/SamuelFCorrea/databasus_ruby
57
+ licenses:
58
+ - MIT
59
+ metadata:
60
+ homepage_uri: https://github.com/SamuelFCorrea/databasus_ruby
61
+ source_code_uri: https://github.com/SamuelFCorrea/databasus_ruby
62
+ changelog_uri: https://github.com/SamuelFCorrea/databasus_ruby/blob/main/CHANGELOG.md
63
+ rubygems_mfa_required: 'true'
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 3.2.0
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 4.0.13
79
+ specification_version: 4
80
+ summary: Ruby client for the Databasus backup-management API
81
+ test_files: []