clowder-common-ruby 0.2.0 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,426 @@
1
+ # This file is automatically generated by bin/json_schema_ruby
2
+ require 'ostruct'
3
+
4
+ module ClowderCommonRuby
5
+ class AppConfig < OpenStruct
6
+ attr_accessor :logging
7
+ attr_accessor :metadata
8
+ attr_accessor :kafka
9
+ attr_accessor :database
10
+ attr_accessor :objectStore
11
+ attr_accessor :inMemoryDb
12
+ attr_accessor :featureFlags
13
+ attr_accessor :endpoints
14
+ attr_accessor :privateEndpoints
15
+
16
+ def initialize(attributes)
17
+ super
18
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
19
+
20
+ attributes = attributes.each_with_object({}) do |(k, v), h|
21
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
22
+ h[k.to_sym] = v
23
+ end
24
+
25
+ @logging = LoggingConfig.new(attributes.fetch(:logging, {}))
26
+ @metadata = AppMetadata.new(attributes.fetch(:metadata, {}))
27
+ @kafka = KafkaConfig.new(attributes.fetch(:kafka, {}))
28
+ @database = DatabaseConfig.new(attributes.fetch(:database, {}))
29
+ @objectStore = ObjectStoreConfig.new(attributes.fetch(:objectStore, {}))
30
+ @inMemoryDb = InMemoryDBConfig.new(attributes.fetch(:inMemoryDb, {}))
31
+ @featureFlags = FeatureFlagsConfig.new(attributes.fetch(:featureFlags, {}))
32
+ @endpoints = []
33
+ attributes.fetch(:endpoints, []).each do |attr|
34
+ @endpoints << DependencyEndpoint.new(attr)
35
+ end
36
+ @privateEndpoints = []
37
+ attributes.fetch(:privateEndpoints, []).each do |attr|
38
+ @privateEndpoints << PrivateDependencyEndpoint.new(attr)
39
+ end
40
+ end
41
+
42
+ def valid_keys
43
+ [].tap do |keys|
44
+ keys << :privatePort
45
+ keys << :publicPort
46
+ keys << :webPort
47
+ keys << :metricsPort
48
+ keys << :metricsPath
49
+ keys << :logging
50
+ keys << :metadata
51
+ keys << :kafka
52
+ keys << :database
53
+ keys << :objectStore
54
+ keys << :inMemoryDb
55
+ keys << :featureFlags
56
+ keys << :endpoints
57
+ keys << :privateEndpoints
58
+ end
59
+ end
60
+ end
61
+
62
+ class LoggingConfig < OpenStruct
63
+ attr_accessor :cloudwatch
64
+
65
+ def initialize(attributes)
66
+ super
67
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
68
+
69
+ attributes = attributes.each_with_object({}) do |(k, v), h|
70
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
71
+ h[k.to_sym] = v
72
+ end
73
+
74
+ @cloudwatch = CloudWatchConfig.new(attributes.fetch(:cloudwatch, {}))
75
+ end
76
+
77
+ def valid_keys
78
+ [].tap do |keys|
79
+ keys << :type
80
+ keys << :cloudwatch
81
+ end
82
+ end
83
+ end
84
+
85
+ class AppMetadata < OpenStruct
86
+ attr_accessor :deployments
87
+
88
+ def initialize(attributes)
89
+ super
90
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
91
+
92
+ attributes = attributes.each_with_object({}) do |(k, v), h|
93
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
94
+ h[k.to_sym] = v
95
+ end
96
+
97
+ @deployments = []
98
+ attributes.fetch(:deployments, []).each do |attr|
99
+ @deployments << DeploymentMetadata.new(attr)
100
+ end
101
+ end
102
+
103
+ def valid_keys
104
+ [].tap do |keys|
105
+ keys << :deployments
106
+ end
107
+ end
108
+ end
109
+
110
+ class DeploymentMetadata < OpenStruct
111
+
112
+ def initialize(attributes)
113
+ super
114
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
115
+
116
+ attributes = attributes.each_with_object({}) do |(k, v), h|
117
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
118
+ h[k.to_sym] = v
119
+ end
120
+
121
+ end
122
+
123
+ def valid_keys
124
+ [].tap do |keys|
125
+ keys << :name
126
+ keys << :image
127
+ end
128
+ end
129
+ end
130
+
131
+ class CloudWatchConfig < OpenStruct
132
+
133
+ def initialize(attributes)
134
+ super
135
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
136
+
137
+ attributes = attributes.each_with_object({}) do |(k, v), h|
138
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
139
+ h[k.to_sym] = v
140
+ end
141
+
142
+ end
143
+
144
+ def valid_keys
145
+ [].tap do |keys|
146
+ keys << :accessKeyId
147
+ keys << :secretAccessKey
148
+ keys << :region
149
+ keys << :logGroup
150
+ end
151
+ end
152
+ end
153
+
154
+ class KafkaConfig < OpenStruct
155
+ attr_accessor :brokers
156
+ attr_accessor :topics
157
+
158
+ def initialize(attributes)
159
+ super
160
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
161
+
162
+ attributes = attributes.each_with_object({}) do |(k, v), h|
163
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
164
+ h[k.to_sym] = v
165
+ end
166
+
167
+ @brokers = []
168
+ attributes.fetch(:brokers, []).each do |attr|
169
+ @brokers << BrokerConfig.new(attr)
170
+ end
171
+ @topics = []
172
+ attributes.fetch(:topics, []).each do |attr|
173
+ @topics << TopicConfig.new(attr)
174
+ end
175
+ end
176
+
177
+ def valid_keys
178
+ [].tap do |keys|
179
+ keys << :brokers
180
+ keys << :topics
181
+ end
182
+ end
183
+ end
184
+
185
+ class KafkaSASLConfig < OpenStruct
186
+
187
+ def initialize(attributes)
188
+ super
189
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
190
+
191
+ attributes = attributes.each_with_object({}) do |(k, v), h|
192
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
193
+ h[k.to_sym] = v
194
+ end
195
+
196
+ end
197
+
198
+ def valid_keys
199
+ [].tap do |keys|
200
+ keys << :username
201
+ keys << :password
202
+ end
203
+ end
204
+ end
205
+
206
+ class BrokerConfig < OpenStruct
207
+ attr_accessor :sasl
208
+
209
+ def initialize(attributes)
210
+ super
211
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
212
+
213
+ attributes = attributes.each_with_object({}) do |(k, v), h|
214
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
215
+ h[k.to_sym] = v
216
+ end
217
+
218
+ @sasl = KafkaSASLConfig.new(attributes.fetch(:sasl, {}))
219
+ end
220
+
221
+ def valid_keys
222
+ [].tap do |keys|
223
+ keys << :hostname
224
+ keys << :port
225
+ keys << :cacert
226
+ keys << :authtype
227
+ keys << :sasl
228
+ end
229
+ end
230
+ end
231
+
232
+ class TopicConfig < OpenStruct
233
+
234
+ def initialize(attributes)
235
+ super
236
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
237
+
238
+ attributes = attributes.each_with_object({}) do |(k, v), h|
239
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
240
+ h[k.to_sym] = v
241
+ end
242
+
243
+ end
244
+
245
+ def valid_keys
246
+ [].tap do |keys|
247
+ keys << :requestedName
248
+ keys << :name
249
+ end
250
+ end
251
+ end
252
+
253
+ class DatabaseConfig < OpenStruct
254
+
255
+ def initialize(attributes)
256
+ super
257
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
258
+
259
+ attributes = attributes.each_with_object({}) do |(k, v), h|
260
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
261
+ h[k.to_sym] = v
262
+ end
263
+
264
+ end
265
+
266
+ def valid_keys
267
+ [].tap do |keys|
268
+ keys << :name
269
+ keys << :username
270
+ keys << :password
271
+ keys << :hostname
272
+ keys << :port
273
+ keys << :adminUsername
274
+ keys << :adminPassword
275
+ keys << :rdsCa
276
+ keys << :sslMode
277
+ end
278
+ end
279
+ end
280
+
281
+ class ObjectStoreBucket < OpenStruct
282
+
283
+ def initialize(attributes)
284
+ super
285
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
286
+
287
+ attributes = attributes.each_with_object({}) do |(k, v), h|
288
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
289
+ h[k.to_sym] = v
290
+ end
291
+
292
+ end
293
+
294
+ def valid_keys
295
+ [].tap do |keys|
296
+ keys << :accessKey
297
+ keys << :secretKey
298
+ keys << :region
299
+ keys << :requestedName
300
+ keys << :name
301
+ end
302
+ end
303
+ end
304
+
305
+ class ObjectStoreConfig < OpenStruct
306
+ attr_accessor :buckets
307
+
308
+ def initialize(attributes)
309
+ super
310
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
311
+
312
+ attributes = attributes.each_with_object({}) do |(k, v), h|
313
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
314
+ h[k.to_sym] = v
315
+ end
316
+
317
+ @buckets = []
318
+ attributes.fetch(:buckets, []).each do |attr|
319
+ @buckets << ObjectStoreBucket.new(attr)
320
+ end
321
+ end
322
+
323
+ def valid_keys
324
+ [].tap do |keys|
325
+ keys << :buckets
326
+ keys << :accessKey
327
+ keys << :secretKey
328
+ keys << :hostname
329
+ keys << :port
330
+ keys << :tls
331
+ end
332
+ end
333
+ end
334
+
335
+ class FeatureFlagsConfig < OpenStruct
336
+
337
+ def initialize(attributes)
338
+ super
339
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
340
+
341
+ attributes = attributes.each_with_object({}) do |(k, v), h|
342
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
343
+ h[k.to_sym] = v
344
+ end
345
+
346
+ end
347
+
348
+ def valid_keys
349
+ [].tap do |keys|
350
+ keys << :hostname
351
+ keys << :port
352
+ keys << :clientAccessToken
353
+ keys << :scheme
354
+ end
355
+ end
356
+ end
357
+
358
+ class InMemoryDBConfig < OpenStruct
359
+
360
+ def initialize(attributes)
361
+ super
362
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
363
+
364
+ attributes = attributes.each_with_object({}) do |(k, v), h|
365
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
366
+ h[k.to_sym] = v
367
+ end
368
+
369
+ end
370
+
371
+ def valid_keys
372
+ [].tap do |keys|
373
+ keys << :hostname
374
+ keys << :port
375
+ keys << :username
376
+ keys << :password
377
+ end
378
+ end
379
+ end
380
+
381
+ class DependencyEndpoint < OpenStruct
382
+
383
+ def initialize(attributes)
384
+ super
385
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
386
+
387
+ attributes = attributes.each_with_object({}) do |(k, v), h|
388
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
389
+ h[k.to_sym] = v
390
+ end
391
+
392
+ end
393
+
394
+ def valid_keys
395
+ [].tap do |keys|
396
+ keys << :name
397
+ keys << :hostname
398
+ keys << :port
399
+ keys << :app
400
+ end
401
+ end
402
+ end
403
+
404
+ class PrivateDependencyEndpoint < OpenStruct
405
+
406
+ def initialize(attributes)
407
+ super
408
+ raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
409
+
410
+ attributes = attributes.each_with_object({}) do |(k, v), h|
411
+ warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
412
+ h[k.to_sym] = v
413
+ end
414
+
415
+ end
416
+
417
+ def valid_keys
418
+ [].tap do |keys|
419
+ keys << :name
420
+ keys << :hostname
421
+ keys << :port
422
+ keys << :app
423
+ end
424
+ end
425
+ end
426
+ end
@@ -0,0 +1,3 @@
1
+ module ClowderCommonRuby
2
+ VERSION = '0.2.4'.freeze
3
+ end
@@ -0,0 +1,6 @@
1
+ require 'ostruct'
2
+ require 'json'
3
+
4
+ require 'clowder-common-ruby/version'
5
+ require 'clowder-common-ruby/config'
6
+ require 'clowder-common-ruby/types'
data/sync_config.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ cd bin/
3
+ wget https://raw.githubusercontent.com/RedHatInsights/clowder/master/controllers/cloud.redhat.com/config/schema.json -O schema.json
4
+ ./json_schema_ruby -o ../lib/clowder-common-ruby/types.rb schema.json
data/test.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "publicPort": 8000,
3
+ "metricsPort": 9000,
4
+ "metricsPath": "/metrics",
5
+ "logging": {
6
+ "type": "cloudwatch",
7
+ "cloudwatch": {
8
+ "accessKeyId": "ACCESS_KEY",
9
+ "secretAccessKey": "SECRET_ACCESS_KEY",
10
+ "region": "EU",
11
+ "logGroup": "base_app"
12
+ }
13
+ },
14
+ "kafka": {
15
+ "brokers": [
16
+ {
17
+ "hostname": "broker-host",
18
+ "port": 27015
19
+ }
20
+ ],
21
+ "topics": [
22
+ {
23
+ "requestedName": "originalName",
24
+ "name": "someTopic"
25
+ }
26
+ ]
27
+ },
28
+ "database": {
29
+ "name": "dBaseName",
30
+ "username": "username",
31
+ "password": "password",
32
+ "hostname": "hostname",
33
+ "port": 5432,
34
+ "pgPass": "testing",
35
+ "adminUsername": "adminusername",
36
+ "adminPassword": "adminpassword",
37
+ "rdsCa": "ca",
38
+ "sslMode": "verify-full"
39
+ },
40
+ "objectStore": {
41
+ "hostname": "endpoint",
42
+ "port" : 9292,
43
+ "accessKey": "Testing",
44
+ "secretKey": "Testing",
45
+ "tls": false,
46
+ "buckets": [
47
+ {
48
+ "accessKey": "accessKey1",
49
+ "secretKey": "secretKey1",
50
+ "requestedName": "reqname",
51
+ "name": "name"
52
+ }
53
+ ]
54
+ },
55
+ "featureFlags": {
56
+ "hostname": "ff-server.server.example.com",
57
+ "port": 4242,
58
+ "scheme": "http"
59
+ },
60
+ "endpoints": [
61
+ {
62
+ "name": "endpoint1",
63
+ "app": "app1",
64
+ "hostname": "endpoint1.svc",
65
+ "port": 8000
66
+ },
67
+ {
68
+ "name": "endpoint2",
69
+ "app": "app2",
70
+ "hostname": "endpoint2.svc",
71
+ "port": 8000
72
+ }
73
+ ],
74
+ "privateEndpoints": [
75
+ {
76
+ "name": "endpoint1",
77
+ "app": "app1",
78
+ "hostname": "endpoint1.svc",
79
+ "port": 10000
80
+ },
81
+ {
82
+ "name": "endpoint2",
83
+ "app": "app2",
84
+ "hostname": "endpoint2.svc",
85
+ "port": 10000
86
+ }
87
+ ]
88
+ }
metadata CHANGED
@@ -1,24 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clowder-common-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
- - Redhat Developers
7
+ - Red Hat Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-04 00:00:00.000000000 Z
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a ruby interface for preparing Clowder variables.
14
14
  email:
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
- files: []
18
+ files:
19
+ - LICENSE.txt
20
+ - README.md
21
+ - Rakefile
22
+ - bin/json_schema_ruby
23
+ - bin/output
24
+ - bin/ruby_class_converter.rb
25
+ - bin/schema.json
26
+ - lib/clowder-common-ruby.rb
27
+ - lib/clowder-common-ruby/config.rb
28
+ - lib/clowder-common-ruby/test.rb
29
+ - lib/clowder-common-ruby/types.rb
30
+ - lib/clowder-common-ruby/version.rb
31
+ - sync_config.sh
32
+ - test.json
19
33
  homepage: https://github.com/RedHatInsights/clowder-common-ruby
20
34
  licenses:
21
- - MIT
35
+ - Apache-2.0
22
36
  metadata: {}
23
37
  post_install_message:
24
38
  rdoc_options: []