droplet_kit 3.3.1 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -2
- data/lib/droplet_kit/client.rb +1 -0
- data/lib/droplet_kit/mappings/database_backup_mapping.rb +13 -0
- data/lib/droplet_kit/mappings/database_backup_restore_mapping.rb +13 -0
- data/lib/droplet_kit/mappings/database_cluster_mapping.rb +28 -0
- data/lib/droplet_kit/mappings/database_connection_mapping.rb +18 -0
- data/lib/droplet_kit/mappings/database_maintenance_window_mapping.rb +15 -0
- data/lib/droplet_kit/mappings/database_mapping.rb +12 -0
- data/lib/droplet_kit/mappings/database_user_mapping.rb +14 -0
- data/lib/droplet_kit/models/database.rb +5 -0
- data/lib/droplet_kit/models/database_backup.rb +8 -0
- data/lib/droplet_kit/models/database_cluster.rb +21 -0
- data/lib/droplet_kit/models/database_connection.rb +11 -0
- data/lib/droplet_kit/models/database_maintenance_window.rb +8 -0
- data/lib/droplet_kit/models/database_user.rb +7 -0
- data/lib/droplet_kit/resources/database_resource.rb +70 -0
- data/lib/droplet_kit/version.rb +1 -1
- data/lib/droplet_kit.rb +14 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bcc722fe43dcbe1053885290daaaa4760b68a24c0e5906a9c7a4bb5da3b76c5
|
4
|
+
data.tar.gz: a99ad56fff825502d3b22e610a3066f518e93c1a6a9dac5a323924492ad55ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2734100b49139ba6a695b23c81f86eaee262355db026e2c801334a55b3994b74f0711ea68b8c61d887f13f19ade1d21639251f1c6d6d03a97f5e8fa2ab72848d
|
7
|
+
data.tar.gz: 82ccd08bd1af12596baf0523c394aa019ec4fa00842cbfe69a145d97aa46f463ff6efef97761bec90cea8eb1e9584f8beec7b037dbe06fe20b7f4b4d8cd4bfe0
|
data/README.md
CHANGED
@@ -20,9 +20,9 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
You'll need to generate an access token in
|
23
|
+
You'll need to generate an access token in DigitalOcean's control panel at https://cloud.digitalocean.com/settings/applications
|
24
24
|
|
25
|
-
|
25
|
+
Using your access token, retrieve a client instance.
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
require 'droplet_kit'
|
@@ -125,6 +125,37 @@ Actions supported:
|
|
125
125
|
* `client.certificates.create(certificate)`
|
126
126
|
* `client.certificates.delete(id: 'id')`
|
127
127
|
|
128
|
+
## Database resource
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
client = DropletKit::Client.new(access_token: 'TOKEN')
|
132
|
+
client.databases #=> DropletKit::DatabaseResource
|
133
|
+
database_cluster = DropletKit::DatabaseCluster.new(
|
134
|
+
name: 'backend',
|
135
|
+
engine: 'pg',
|
136
|
+
version: '10',
|
137
|
+
region: 'nyc3',
|
138
|
+
size: 'db-s-2vcpu-4gb',
|
139
|
+
num_nodes: 2,
|
140
|
+
tags: ['production']
|
141
|
+
)
|
142
|
+
```
|
143
|
+
|
144
|
+
Actions supported:
|
145
|
+
|
146
|
+
* `client.databases.create_cluster(database_cluster)`
|
147
|
+
* `client.databases.find_cluster(id: 'id')`
|
148
|
+
* `client.databases.all_clusters()`
|
149
|
+
* `client.databases.resize_cluster(database_cluster, id: 'id')`
|
150
|
+
* `client.databases.migrate_cluster(database_cluster, id: 'id')`
|
151
|
+
* `client.databases.update_maintenance_window(database_maintenance_window, id: 'id')`
|
152
|
+
* `client.databases.list_backups(id: 'id')`
|
153
|
+
* `client.databases.restore_from_backup(database_backup)`
|
154
|
+
* `client.databases.delete_cluster()`
|
155
|
+
* `client.database.create_db(database, id: 'id')`
|
156
|
+
* `client.databases.find_db(id: 'id', name: 'name')`
|
157
|
+
* `client.databases.all_dbs(id: 'id')`
|
158
|
+
* `client.databases.delete_db(id: 'id', name: 'name')`
|
128
159
|
|
129
160
|
## Droplet resource
|
130
161
|
|
data/lib/droplet_kit/client.rb
CHANGED
@@ -32,6 +32,7 @@ module DropletKit
|
|
32
32
|
cdns: CDNResource,
|
33
33
|
certificates: CertificateResource,
|
34
34
|
container_registry: ContainerRegistryResource,
|
35
|
+
databases: DatabaseResource,
|
35
36
|
droplets: DropletResource,
|
36
37
|
kubernetes_clusters: KubernetesClusterResource,
|
37
38
|
kubernetes_options: KubernetesOptionsResource,
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseBackupMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping DatabaseBackup
|
7
|
+
root_key singular: 'backup', plural: 'backups', scopes: [:read]
|
8
|
+
|
9
|
+
property :created_at, scopes: [:read]
|
10
|
+
property :size_gigabytes, scopes: [:read]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseBackupRestoreMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping DatabaseBackup
|
7
|
+
root_key singular: 'backup_restore', scopes: [:read]
|
8
|
+
|
9
|
+
property :database_name, scopes: [:restore]
|
10
|
+
property :backup_created_at, scopes: [:restore]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseClusterMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping DatabaseCluster
|
7
|
+
root_key singular: 'database', plural: 'databases', scopes: [:read]
|
8
|
+
|
9
|
+
property :id, scopes: [:read]
|
10
|
+
property :name, scopes: [:read, :create, :restore]
|
11
|
+
property :engine, scopes: [:read, :create, :restore]
|
12
|
+
property :version, scopes: [:read, :create, :restore]
|
13
|
+
property :connection, scopes: [:read], include: DatabaseConnectionMapping
|
14
|
+
property :private_connection, scopes: [:read], include: DatabaseConnectionMapping
|
15
|
+
property :users, plural: true, scopes: [:read], include: DatabaseUserMapping
|
16
|
+
property :backup_restore, scopes: [:restore], include: DatabaseBackupRestoreMapping
|
17
|
+
property :num_nodes, scopes: [:read, :create, :resize, :restore]
|
18
|
+
property :size, scopes: [:read, :create, :resize, :restore]
|
19
|
+
property :db_names, plural: true, scopes: [:read]
|
20
|
+
property :region, scopes: [:read, :create, :migrate, :restore]
|
21
|
+
property :status, scopes: [:read]
|
22
|
+
property :maintenance_window, scopes: [:read], include: DatabaseMaintenanceWindowMapping
|
23
|
+
property :created_at, scopes: [:read]
|
24
|
+
property :private_network_uuid, scopes: [:read, :create]
|
25
|
+
property :tags, plural: true, scopes: [:read, :create]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseConnectionMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping DatabaseConnection
|
7
|
+
root_key singular: 'connection', plural: 'connections', scopes: [:read]
|
8
|
+
|
9
|
+
property :uri, scopes: [:read]
|
10
|
+
property :database, scopes: [:read]
|
11
|
+
property :host, scopes: [:read]
|
12
|
+
property :port, scopes: [:read]
|
13
|
+
property :user, scopes: [:read]
|
14
|
+
property :password, scopes: [:read]
|
15
|
+
property :ssl, scopes: [:read]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseMaintenanceWindowMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping DatabaseMaintenanceWindow
|
7
|
+
root_key singular: 'database_maintenance_window', plural: 'database_maintenance_windows', scopes: [:read]
|
8
|
+
|
9
|
+
property :day, scopes: [:read, :update]
|
10
|
+
property :hour, scopes: [:read, :update]
|
11
|
+
property :pending, scopes: [:read]
|
12
|
+
property :description, scopes: [:read]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseUserMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping DatabaseUser
|
7
|
+
root_key singular: 'database_user', plural: 'database_users', scopes: [:read]
|
8
|
+
|
9
|
+
property :name, scopes: [:read]
|
10
|
+
property :role, scopes: [:read, :create, :update]
|
11
|
+
property :password, scopes: [:read, :create, :update]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseCluster < BaseModel
|
3
|
+
attribute :id
|
4
|
+
attribute :name
|
5
|
+
attribute :engine
|
6
|
+
attribute :version
|
7
|
+
attribute :connection
|
8
|
+
attribute :private_connection
|
9
|
+
attribute :backup_restore
|
10
|
+
attribute :users
|
11
|
+
attribute :num_nodes
|
12
|
+
attribute :size
|
13
|
+
attribute :db_names
|
14
|
+
attribute :region
|
15
|
+
attribute :status
|
16
|
+
attribute :maintenance_window
|
17
|
+
attribute :created_at
|
18
|
+
attribute :private_network_uuid
|
19
|
+
attribute :tags
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DatabaseResource < ResourceKit::Resource
|
3
|
+
include ErrorHandlingResourcable
|
4
|
+
|
5
|
+
resources do
|
6
|
+
action :find_cluster, 'GET /v2/databases/:id' do
|
7
|
+
handler(200) { |response| DatabaseClusterMapping.extract_single(response.body, :read) }
|
8
|
+
end
|
9
|
+
|
10
|
+
action :all_clusters, 'GET /v2/databases' do
|
11
|
+
handler(200) { |response| DatabaseClusterMapping.extract_collection(response.body, :read) }
|
12
|
+
end
|
13
|
+
|
14
|
+
action :create_cluster, 'POST /v2/databases' do
|
15
|
+
body { |object| DatabaseClusterMapping.representation_for(:create, object) }
|
16
|
+
handler(202) { |response, database| DatabaseClusterMapping.extract_into_object(database, response.body, :read) }
|
17
|
+
handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
|
18
|
+
end
|
19
|
+
|
20
|
+
action :resize_cluster, 'PUT /v2/databases/:id/resize' do
|
21
|
+
body { |object| DatabaseClusterMapping.representation_for(:resize, object) }
|
22
|
+
handler(202) { |response| true }
|
23
|
+
handler(422) { |response| ErrorMapping.fail_with(FailedUpdate, response.body) }
|
24
|
+
end
|
25
|
+
|
26
|
+
action :migrate_cluster, 'PUT /v2/databases/:id/migrate' do
|
27
|
+
body { |object| DatabaseClusterMapping.representation_for(:migrate, object) }
|
28
|
+
handler(202) { |response| true }
|
29
|
+
handler(422) { |response| ErrorMapping.fail_with(FailedUpdate, response.body) }
|
30
|
+
end
|
31
|
+
|
32
|
+
action :update_maintenance_window, 'PUT /v2/databases/:id/maintenance' do
|
33
|
+
body { |object| DatabaseMaintenanceWindowMapping.representation_for(:update, object) }
|
34
|
+
handler(204) { |response| true }
|
35
|
+
end
|
36
|
+
|
37
|
+
action :list_backups, 'GET /v2/databases/:id/backups' do
|
38
|
+
handler(200) { |response| DatabaseBackupMapping.extract_collection(response.body, :read) }
|
39
|
+
end
|
40
|
+
|
41
|
+
action :restore_from_backup, 'POST /v2/databases' do
|
42
|
+
body { |object| DatabaseClusterMapping.representation_for(:restore, object) }
|
43
|
+
handler(201) { |response, database| DatabaseClusterMapping.extract_into_object(database, response.body, :read) }
|
44
|
+
handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
|
45
|
+
end
|
46
|
+
|
47
|
+
action :delete_cluster, 'DELETE /v2/databases/:id' do
|
48
|
+
handler(204) { |response| true }
|
49
|
+
end
|
50
|
+
|
51
|
+
action :create_db, 'POST /v2/databases/:id/dbs' do
|
52
|
+
body { |object| DatabaseMapping.representation_for(:create, object) }
|
53
|
+
handler(201) { |response, database| DatabaseMapping.extract_into_object(database, response.body, :read) }
|
54
|
+
handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
|
55
|
+
end
|
56
|
+
|
57
|
+
action :find_db, 'GET /v2/databases/:id/dbs/:name' do
|
58
|
+
handler(200) { |response| DatabaseMapping.extract_single(response.body, :read) }
|
59
|
+
end
|
60
|
+
|
61
|
+
action :all_dbs, 'GET /v2/databases/:id/dbs' do
|
62
|
+
handler(200) { |response| DatabaseMapping.extract_collection(response.body, :read) }
|
63
|
+
end
|
64
|
+
|
65
|
+
action :delete_db, 'DELETE /v2/databases/:id/dbs/:name' do
|
66
|
+
handler(204) { |response| true }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/droplet_kit/version.rb
CHANGED
data/lib/droplet_kit.rb
CHANGED
@@ -32,6 +32,12 @@ module DropletKit
|
|
32
32
|
autoload :TaggedDropletsResources, 'droplet_kit/models/tagged_droplets_resources'
|
33
33
|
autoload :TaggedImagesResources, 'droplet_kit/models/tagged_images_resources'
|
34
34
|
autoload :Volume, 'droplet_kit/models/volume'
|
35
|
+
autoload :Database, 'droplet_kit/models/database'
|
36
|
+
autoload :DatabaseBackup, 'droplet_kit/models/database_backup'
|
37
|
+
autoload :DatabaseCluster, 'droplet_kit/models/database_cluster'
|
38
|
+
autoload :DatabaseConnection, 'droplet_kit/models/database_connection'
|
39
|
+
autoload :DatabaseUser, 'droplet_kit/models/database_user'
|
40
|
+
autoload :DatabaseMaintenanceWindow, 'droplet_kit/models/database_maintenance_window'
|
35
41
|
autoload :LoadBalancer, 'droplet_kit/models/load_balancer'
|
36
42
|
autoload :StickySession, 'droplet_kit/models/sticky_session'
|
37
43
|
autoload :HealthCheck, 'droplet_kit/models/health_check'
|
@@ -71,6 +77,7 @@ module DropletKit
|
|
71
77
|
autoload :VolumeResource, 'droplet_kit/resources/volume_resource'
|
72
78
|
autoload :VolumeActionResource, 'droplet_kit/resources/volume_action_resource'
|
73
79
|
autoload :SnapshotResource, 'droplet_kit/resources/snapshot_resource'
|
80
|
+
autoload :DatabaseResource, 'droplet_kit/resources/database_resource'
|
74
81
|
autoload :LoadBalancerResource, 'droplet_kit/resources/load_balancer_resource'
|
75
82
|
autoload :CertificateResource, 'droplet_kit/resources/certificate_resource'
|
76
83
|
autoload :FirewallResource, 'droplet_kit/resources/firewall_resource'
|
@@ -106,6 +113,13 @@ module DropletKit
|
|
106
113
|
autoload :TaggedDropletsResourcesMapping, 'droplet_kit/mappings/tagged_droplets_resources_mapping'
|
107
114
|
autoload :TaggedImagesResourcesMapping, 'droplet_kit/mappings/tagged_images_resources_mapping'
|
108
115
|
autoload :VolumeMapping, 'droplet_kit/mappings/volume_mapping'
|
116
|
+
autoload :DatabaseMapping, 'droplet_kit/mappings/database_mapping'
|
117
|
+
autoload :DatabaseBackupMapping, 'droplet_kit/mappings/database_backup_mapping'
|
118
|
+
autoload :DatabaseBackupRestoreMapping, 'droplet_kit/mappings/database_backup_restore_mapping'
|
119
|
+
autoload :DatabaseClusterMapping, 'droplet_kit/mappings/database_cluster_mapping'
|
120
|
+
autoload :DatabaseConnectionMapping, 'droplet_kit/mappings/database_connection_mapping'
|
121
|
+
autoload :DatabaseUserMapping, 'droplet_kit/mappings/database_user_mapping'
|
122
|
+
autoload :DatabaseMaintenanceWindowMapping, 'droplet_kit/mappings/database_maintenance_window_mapping'
|
109
123
|
autoload :LoadBalancerMapping, 'droplet_kit/mappings/load_balancer_mapping'
|
110
124
|
autoload :StickySessionMapping, 'droplet_kit/mappings/sticky_session_mapping'
|
111
125
|
autoload :HealthCheckMapping, 'droplet_kit/mappings/health_check_mapping'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droplet_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Ross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -167,6 +167,13 @@ files:
|
|
167
167
|
- lib/droplet_kit/mappings/cdn_mapping.rb
|
168
168
|
- lib/droplet_kit/mappings/certificate_mapping.rb
|
169
169
|
- lib/droplet_kit/mappings/container_registry_mapping.rb
|
170
|
+
- lib/droplet_kit/mappings/database_backup_mapping.rb
|
171
|
+
- lib/droplet_kit/mappings/database_backup_restore_mapping.rb
|
172
|
+
- lib/droplet_kit/mappings/database_cluster_mapping.rb
|
173
|
+
- lib/droplet_kit/mappings/database_connection_mapping.rb
|
174
|
+
- lib/droplet_kit/mappings/database_maintenance_window_mapping.rb
|
175
|
+
- lib/droplet_kit/mappings/database_mapping.rb
|
176
|
+
- lib/droplet_kit/mappings/database_user_mapping.rb
|
170
177
|
- lib/droplet_kit/mappings/domain_mapping.rb
|
171
178
|
- lib/droplet_kit/mappings/domain_record_mapping.rb
|
172
179
|
- lib/droplet_kit/mappings/droplet_mapping.rb
|
@@ -211,6 +218,12 @@ files:
|
|
211
218
|
- lib/droplet_kit/models/cdn.rb
|
212
219
|
- lib/droplet_kit/models/certificate.rb
|
213
220
|
- lib/droplet_kit/models/container_registry.rb
|
221
|
+
- lib/droplet_kit/models/database.rb
|
222
|
+
- lib/droplet_kit/models/database_backup.rb
|
223
|
+
- lib/droplet_kit/models/database_cluster.rb
|
224
|
+
- lib/droplet_kit/models/database_connection.rb
|
225
|
+
- lib/droplet_kit/models/database_maintenance_window.rb
|
226
|
+
- lib/droplet_kit/models/database_user.rb
|
214
227
|
- lib/droplet_kit/models/domain.rb
|
215
228
|
- lib/droplet_kit/models/domain_record.rb
|
216
229
|
- lib/droplet_kit/models/droplet.rb
|
@@ -256,6 +269,7 @@ files:
|
|
256
269
|
- lib/droplet_kit/resources/cdn_resource.rb
|
257
270
|
- lib/droplet_kit/resources/certificate_resource.rb
|
258
271
|
- lib/droplet_kit/resources/container_registry_resource.rb
|
272
|
+
- lib/droplet_kit/resources/database_resource.rb
|
259
273
|
- lib/droplet_kit/resources/domain_record_resource.rb
|
260
274
|
- lib/droplet_kit/resources/domain_resource.rb
|
261
275
|
- lib/droplet_kit/resources/droplet_action_resource.rb
|
@@ -300,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
314
|
- !ruby/object:Gem::Version
|
301
315
|
version: '0'
|
302
316
|
requirements: []
|
303
|
-
rubygems_version: 3.
|
317
|
+
rubygems_version: 3.1.2
|
304
318
|
signing_key:
|
305
319
|
specification_version: 4
|
306
320
|
summary: Droplet Kit is the official Ruby library for DigitalOcean's API
|