droplet_kit 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 953e00f1928e2b046ce82fb398ae9748878a14a278dd72a954d8fc4b3d29f746
4
- data.tar.gz: d816967003f3304e06f1fb0e8391025012cbc8ea7996a6f90c0a2616d7bb6487
3
+ metadata.gz: e99b935a43e66664681fa592d617cfd75b2d1a418dc9183230604983d8ccee21
4
+ data.tar.gz: c2a8fe830a6f42eeb21d2b26d02b6c7ca9843256e1f384dda50e24f168553182
5
5
  SHA512:
6
- metadata.gz: '069a463110c700fd4a06a6ecf0d2c6ed09fb11e1b8c8cc5af5b0bdf2347fabfb364e010848094fd996dacf56e212af1abb67e60e4129db86654c6d7d40cce860'
7
- data.tar.gz: 384560837a422364d01f56d0fa7514e726ffefd40a1cd3bcefb42a3bb4159e41fe42a218d7c2727fd177b0f2d5574d75468671ee77fab619d11a83ffc2dd8948
6
+ metadata.gz: d2df61948aae39fca4d5632770a9dffcbea2612d492352761081e2dc187980aa575e5145b2203a1b0f7988f614cd4ae5a33c50719f5ff6d979ea75c93633297c
7
+ data.tar.gz: b2a3dd53c71095114cd4b0d53c9dade7f6c17598aec10bc539a724ed77906602ac07d4dc4a89e6a87557120ae1b7e8ee071ddc7d74a605b831815f8f1a7f00c7
data/README.md CHANGED
@@ -143,19 +143,38 @@ database_cluster = DropletKit::DatabaseCluster.new(
143
143
 
144
144
  Actions supported:
145
145
 
146
- * `client.databases.create_cluster(database_cluster)`
147
146
  * `client.databases.find_cluster(id: 'id')`
148
147
  * `client.databases.all_clusters()`
148
+ * `client.databases.create_cluster(database_cluster)`
149
149
  * `client.databases.resize_cluster(database_cluster, id: 'id')`
150
150
  * `client.databases.migrate_cluster(database_cluster, id: 'id')`
151
+ * `client.databases.set_maintenance_window(database_maintenance_window, id: 'id')`
151
152
  * `client.databases.update_maintenance_window(database_maintenance_window, id: 'id')`
152
153
  * `client.databases.list_backups(id: 'id')`
153
154
  * `client.databases.restore_from_backup(database_backup)`
154
- * `client.databases.delete_cluster()`
155
+ * `client.databases.delete_cluster(id: 'id')`
155
156
  * `client.database.create_db(database, id: 'id')`
156
157
  * `client.databases.find_db(id: 'id', name: 'name')`
157
158
  * `client.databases.all_dbs(id: 'id')`
158
159
  * `client.databases.delete_db(id: 'id', name: 'name')`
160
+ * `client.databases.list_firewall_rules(id: 'id')`
161
+ * `client.databases.set_firewall_rules(database_firewall_rules, id: 'id')`
162
+ * `client.databases.create_read_only_replica(database_read_only_replica, id: 'id')`
163
+ * `client.databases.find_read_only_replica(id: 'id', name: 'name')`
164
+ * `client.databases.list_read_only_replicas(id: 'id')`
165
+ * `client.databases.delete_read_only_replica(id: 'id', name: 'name')`
166
+ * `client.databases.create_database_user(database_user, id: 'id')`
167
+ * `client.databases.find_database_user(id: 'id', name: 'name')`
168
+ * `client.databases.list_database_users(id: 'id')`
169
+ * `client.databases.delete_database_user(id: 'id', name: 'name')`
170
+ * `client.databases.create_connection_pool(database_connection_pool, id: 'id')`
171
+ * `client.databases.find_connection_pool(id: 'id', name: 'name')`
172
+ * `client.databases.list_connection_pools(id: 'id')`
173
+ * `client.databases.delete_connection_pool(id: 'id', name: 'name')`
174
+ * `client.databases.set_eviction_policy(database_eviction_policy, id: 'id')`
175
+ * `client.databases.get_eviction_policy(id: 'id')`
176
+ * `client.databases.set_sql_mode(database_sql_mode, id: 'id')`
177
+ * `client.databases.get_sql_mode(id: 'id')`
159
178
 
160
179
  ## Droplet resource
161
180
 
@@ -35,9 +35,14 @@ module DropletKit
35
35
  autoload :Database, 'droplet_kit/models/database'
36
36
  autoload :DatabaseBackup, 'droplet_kit/models/database_backup'
37
37
  autoload :DatabaseCluster, 'droplet_kit/models/database_cluster'
38
+ autoload :DatabaseConnectionPool, 'droplet_kit/models/database_connection_pool'
38
39
  autoload :DatabaseConnection, 'droplet_kit/models/database_connection'
39
- autoload :DatabaseUser, 'droplet_kit/models/database_user'
40
+ autoload :DatabaseEvictionPolicy, 'droplet_kit/models/database_eviction_policy'
41
+ autoload :DatabaseFirewallRule, 'droplet_kit/models/database_firewall_rule'
40
42
  autoload :DatabaseMaintenanceWindow, 'droplet_kit/models/database_maintenance_window'
43
+ autoload :DatabaseReplica, 'droplet_kit/models/database_replica'
44
+ autoload :DatabaseSQLMode, 'droplet_kit/models/database_sql_mode'
45
+ autoload :DatabaseUser, 'droplet_kit/models/database_user'
41
46
  autoload :LoadBalancer, 'droplet_kit/models/load_balancer'
42
47
  autoload :StickySession, 'droplet_kit/models/sticky_session'
43
48
  autoload :HealthCheck, 'droplet_kit/models/health_check'
@@ -117,9 +122,14 @@ module DropletKit
117
122
  autoload :DatabaseBackupMapping, 'droplet_kit/mappings/database_backup_mapping'
118
123
  autoload :DatabaseBackupRestoreMapping, 'droplet_kit/mappings/database_backup_restore_mapping'
119
124
  autoload :DatabaseClusterMapping, 'droplet_kit/mappings/database_cluster_mapping'
125
+ autoload :DatabaseConnectionPoolMapping, 'droplet_kit/mappings/database_connection_pool_mapping'
120
126
  autoload :DatabaseConnectionMapping, 'droplet_kit/mappings/database_connection_mapping'
121
- autoload :DatabaseUserMapping, 'droplet_kit/mappings/database_user_mapping'
127
+ autoload :DatabaseEvictionPolicyMapping, 'droplet_kit/mappings/database_eviction_policy_mapping'
128
+ autoload :DatabaseFirewallRuleMapping, 'droplet_kit/mappings/database_firewall_rule_mapping'
122
129
  autoload :DatabaseMaintenanceWindowMapping, 'droplet_kit/mappings/database_maintenance_window_mapping'
130
+ autoload :DatabaseReplicaMapping, 'droplet_kit/mappings/database_replica_mapping'
131
+ autoload :DatabaseSQLModeMapping, 'droplet_kit/mappings/database_sql_mode_mapping'
132
+ autoload :DatabaseUserMapping, 'droplet_kit/mappings/database_user_mapping'
123
133
  autoload :LoadBalancerMapping, 'droplet_kit/mappings/load_balancer_mapping'
124
134
  autoload :StickySessionMapping, 'droplet_kit/mappings/sticky_session_mapping'
125
135
  autoload :HealthCheckMapping, 'droplet_kit/mappings/health_check_mapping'
@@ -0,0 +1,17 @@
1
+ module DropletKit
2
+ class DatabaseConnectionPoolMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping DatabaseConnectionPool
7
+ root_key singular: 'pool', plural: 'pools', scopes: [:read]
8
+
9
+ property :name, scopes: [:read, :create]
10
+ property :mode, scopes: [:read, :create]
11
+ property :size, scopes: [:read, :create]
12
+ property :db, scopes: [:read, :create]
13
+ property :user, scopes: [:read, :create]
14
+ property :connection, scopes: [:read], include: DatabaseConnectionMapping
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module DropletKit
2
+ class DatabaseEvictionPolicyMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping DatabaseEvictionPolicy
7
+
8
+ property :eviction_policy, scopes: [:read, :update]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module DropletKit
2
+ class DatabaseFirewallRuleMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping DatabaseFirewallRule
7
+ root_key plural: 'rules', scopes: [:read, :update]
8
+
9
+ property :type, scopes: [:read, :update]
10
+ property :value, scopes: [:read, :update]
11
+ property :uuid, scopes: [:read]
12
+ property :cluster_uuid, scopes: [:read]
13
+ property :created_at, scopes: [:read]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ module DropletKit
2
+ class DatabaseReplicaMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping DatabaseReplica
7
+
8
+ property :replicas, scopes: [:read], plural: true, include: DatabaseClusterMapping
9
+ property :replica, scopes: [:read], plural: false, include: DatabaseClusterMapping
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module DropletKit
2
+ class DatabaseSQLModeMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping DatabaseSQLMode
7
+
8
+ property :sql_mode, scopes: [:read, :create]
9
+ end
10
+ end
11
+ end
@@ -4,11 +4,11 @@ module DropletKit
4
4
 
5
5
  kartograph do
6
6
  mapping DatabaseUser
7
- root_key singular: 'database_user', plural: 'database_users', scopes: [:read]
7
+ root_key singular: 'user', plural: 'users', scopes: [:read]
8
8
 
9
9
  property :name, scopes: [:read]
10
- property :role, scopes: [:read, :create, :update]
11
- property :password, scopes: [:read, :create, :update]
10
+ property :role, scopes: [:read, :create]
11
+ property :password, scopes: [:read, :create]
12
12
  end
13
13
  end
14
14
  end
@@ -0,0 +1,10 @@
1
+ module DropletKit
2
+ class DatabaseConnectionPool < BaseModel
3
+ attribute :name
4
+ attribute :mode
5
+ attribute :size
6
+ attribute :db
7
+ attribute :user
8
+ attribute :connection
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module DropletKit
2
+ class DatabaseEvictionPolicy < BaseModel
3
+ attribute :eviction_policy
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module DropletKit
2
+ class DatabaseFirewallRule < BaseModel
3
+ attribute :type
4
+ attribute :value
5
+ attribute :uuid
6
+ attribute :cluster_uuid
7
+ attribute :created_at
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ module DropletKit
2
+ class DatabaseReplica < BaseModel
3
+ attribute :replicas
4
+ attribute :replica
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module DropletKit
2
+ class DatabaseSQLMode < BaseModel
3
+ attribute :sql_mode
4
+ end
5
+ end
@@ -8,6 +8,7 @@ module DropletKit
8
8
  end
9
9
 
10
10
  action :all_clusters, 'GET /v2/databases' do
11
+ query_keys :per_page, :page
11
12
  handler(200) { |response| DatabaseClusterMapping.extract_collection(response.body, :read) }
12
13
  end
13
14
 
@@ -19,13 +20,13 @@ module DropletKit
19
20
 
20
21
  action :resize_cluster, 'PUT /v2/databases/:id/resize' do
21
22
  body { |object| DatabaseClusterMapping.representation_for(:resize, object) }
22
- handler(202) { |response| true }
23
+ handler(201) { |response| true }
23
24
  handler(422) { |response| ErrorMapping.fail_with(FailedUpdate, response.body) }
24
25
  end
25
26
 
26
27
  action :migrate_cluster, 'PUT /v2/databases/:id/migrate' do
27
28
  body { |object| DatabaseClusterMapping.representation_for(:migrate, object) }
28
- handler(202) { |response| true }
29
+ handler(201) { |response| true }
29
30
  handler(422) { |response| ErrorMapping.fail_with(FailedUpdate, response.body) }
30
31
  end
31
32
 
@@ -65,6 +66,101 @@ module DropletKit
65
66
  action :delete_db, 'DELETE /v2/databases/:id/dbs/:name' do
66
67
  handler(204) { |response| true }
67
68
  end
69
+
70
+ action :set_maintenance_window, 'PUT /v2/databases/:id/maintenance' do
71
+ body { |object| DatabaseMaintenanceWindowMapping.representation_for(:update, object) }
72
+ handler(204) { |response| true }
73
+ handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
74
+ end
75
+
76
+ action :list_firewall_rules, 'GET /v2/databases/:id/firewall' do
77
+ handler(200) { |response| DatabaseFirewallRuleMapping.extract_collection(response.body, :read) }
78
+ end
79
+
80
+ action :set_firewall_rules, 'PUT /v2/databases/:id/firewall' do
81
+ body { |object| DatabaseFirewallRuleMapping.represent_collection_for(:update, object) }
82
+ handler(204) { |response| true }
83
+ handler(422) { |response| ErrorMapping.fail_with(FailedUpdate, response.body) }
84
+ end
85
+
86
+ action :create_read_only_replica, 'POST /v2/databases/:id/replicas' do
87
+ body { |object| DatabaseClusterMapping.representation_for(:create, object) }
88
+ handler(201) { |response| DatabaseReplicaMapping.extract_single(response.body, :read) }
89
+ handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
90
+ end
91
+
92
+ action :find_read_only_replica, 'GET /v2/databases/:id/replicas/:name' do
93
+ handler(200) { |response| DatabaseReplicaMapping.extract_single(response.body, :read) }
94
+ end
95
+
96
+ action :list_read_only_replicas, 'GET /v2/databases/:id/replicas' do
97
+ handler(200) { |response| DatabaseReplicaMapping.extract_single(response.body, :read) }
98
+ end
99
+
100
+ action :delete_read_only_replica, 'DELETE /v2/databases/:id/replicas/:name' do
101
+ handler(204) { |response| true }
102
+ end
103
+
104
+ # Next up!
105
+ action :create_database_user, 'POST /v2/databases/:id/users' do
106
+ body { |object| DatabaseUserMapping.representation_for(:create, object) }
107
+ handler(201) { |response| DatabaseUserMapping.extract_single(response.body, :read) }
108
+ handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
109
+ end
110
+
111
+ action :find_database_user, 'GET /v2/databases/:id/users/:name' do
112
+ handler(200) { |response| DatabaseUserMapping.extract_single(response.body, :read) }
113
+ end
114
+
115
+ action :list_database_users, 'GET /v2/databases/:id/users' do
116
+ handler(200) { |response| DatabaseUserMapping.extract_collection(response.body, :read) }
117
+ end
118
+
119
+ action :delete_database_user, 'DELETE /v2/databases/:id/users/:name' do
120
+ handler(204) { |response| true }
121
+ end
122
+
123
+ action :create_connection_pool, 'POST /v2/databases/:id/pools' do
124
+ body { |object| DatabaseConnectionPoolMapping.representation_for(:create, object) }
125
+ handler(201) { |response| DatabaseConnectionPoolMapping.extract_single(response.body, :read) }
126
+ handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
127
+ end
128
+
129
+ action :find_connection_pool, 'GET /v2/databases/:id/pools/:name' do
130
+ handler(200) { |response| DatabaseConnectionPoolMapping.extract_single(response.body, :read) }
131
+ end
132
+
133
+ action :list_connection_pools, 'GET /v2/databases/:id/pools' do
134
+ handler(200) { |response| DatabaseConnectionPoolMapping.extract_collection(response.body, :read) }
135
+ end
136
+
137
+ action :delete_connection_pool, 'DELETE /v2/databases/:id/pools/:name' do
138
+ handler(204) { |response| true }
139
+ end
140
+
141
+ action :set_eviction_policy, 'PUT /v2/databases/:id/eviction_policy' do
142
+ body { |object| DatabaseEvictionPolicyMapping.representation_for(:update, object) }
143
+ handler(204) { |response| true }
144
+ handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
145
+ end
146
+
147
+ action :get_eviction_policy, 'GET /v2/databases/:id/eviction_policy' do
148
+ handler(200) { |response| DatabaseEvictionPolicyMapping.extract_single(response.body, :read) }
149
+ end
150
+
151
+ action :set_sql_mode, 'PUT /v2/databases/:id/sql_mode' do
152
+ body { |object| DatabaseSQLModeMapping.representation_for(:update, object) }
153
+ handler(204) { |response| true }
154
+ handler(422) { |response| ErrorMapping.fail_with(FailedCreate, response.body) }
155
+ end
156
+
157
+ action :get_sql_mode, 'GET /v2/databases/:id/sql_mode' do
158
+ handler(200) { |response| DatabaseSQLModeMapping.extract_single(response.body, :read) }
159
+ end
160
+ end
161
+
162
+ def all(*args)
163
+ PaginatedResource.new(action(:all), self, *args)
68
164
  end
69
165
  end
70
166
  end
@@ -1,3 +1,3 @@
1
1
  module DropletKit
2
- VERSION = "3.4.1"
2
+ VERSION = "3.5.0"
3
3
  end
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.1
4
+ version: 3.5.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: 2020-01-13 00:00:00.000000000 Z
11
+ date: 2020-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -171,8 +171,13 @@ files:
171
171
  - lib/droplet_kit/mappings/database_backup_restore_mapping.rb
172
172
  - lib/droplet_kit/mappings/database_cluster_mapping.rb
173
173
  - lib/droplet_kit/mappings/database_connection_mapping.rb
174
+ - lib/droplet_kit/mappings/database_connection_pool_mapping.rb
175
+ - lib/droplet_kit/mappings/database_eviction_policy_mapping.rb
176
+ - lib/droplet_kit/mappings/database_firewall_rule_mapping.rb
174
177
  - lib/droplet_kit/mappings/database_maintenance_window_mapping.rb
175
178
  - lib/droplet_kit/mappings/database_mapping.rb
179
+ - lib/droplet_kit/mappings/database_replica_mapping.rb
180
+ - lib/droplet_kit/mappings/database_sql_mode_mapping.rb
176
181
  - lib/droplet_kit/mappings/database_user_mapping.rb
177
182
  - lib/droplet_kit/mappings/domain_mapping.rb
178
183
  - lib/droplet_kit/mappings/domain_record_mapping.rb
@@ -222,7 +227,12 @@ files:
222
227
  - lib/droplet_kit/models/database_backup.rb
223
228
  - lib/droplet_kit/models/database_cluster.rb
224
229
  - lib/droplet_kit/models/database_connection.rb
230
+ - lib/droplet_kit/models/database_connection_pool.rb
231
+ - lib/droplet_kit/models/database_eviction_policy.rb
232
+ - lib/droplet_kit/models/database_firewall_rule.rb
225
233
  - lib/droplet_kit/models/database_maintenance_window.rb
234
+ - lib/droplet_kit/models/database_replica.rb
235
+ - lib/droplet_kit/models/database_sql_mode.rb
226
236
  - lib/droplet_kit/models/database_user.rb
227
237
  - lib/droplet_kit/models/domain.rb
228
238
  - lib/droplet_kit/models/domain_record.rb