dkron-rb 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +65 -0
  4. data/LICENSE +201 -0
  5. data/README.md +98 -0
  6. data/Rakefile +6 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/config.json +5 -0
  10. data/dkron-rb-0.0.1.gem +0 -0
  11. data/dkron-rb-0.0.2.gem +0 -0
  12. data/dkron-rb.gemspec +55 -0
  13. data/docs/Agent.md +7 -0
  14. data/docs/DefaultApi.md +131 -0
  15. data/docs/Execution.md +13 -0
  16. data/docs/ExecutionsApi.md +55 -0
  17. data/docs/InlineResponse200.md +10 -0
  18. data/docs/Job.md +24 -0
  19. data/docs/JobsApi.md +237 -0
  20. data/docs/MainApi.md +90 -0
  21. data/docs/Member.md +18 -0
  22. data/docs/MembersApi.md +49 -0
  23. data/docs/Serf.md +7 -0
  24. data/docs/Status.md +7 -0
  25. data/docs/Tags.md +7 -0
  26. data/git_push.sh +67 -0
  27. data/lib/dkron-rb.rb +47 -0
  28. data/lib/dkron-rb/api/default_api.rb +193 -0
  29. data/lib/dkron-rb/api/executions_api.rb +91 -0
  30. data/lib/dkron-rb/api/jobs_api.rb +315 -0
  31. data/lib/dkron-rb/api/members_api.rb +87 -0
  32. data/lib/dkron-rb/api_client.rb +378 -0
  33. data/lib/dkron-rb/api_error.rb +47 -0
  34. data/lib/dkron-rb/configuration.rb +207 -0
  35. data/lib/dkron-rb/cron.rb +152 -0
  36. data/lib/dkron-rb/models/agent.rb +152 -0
  37. data/lib/dkron-rb/models/execution.rb +250 -0
  38. data/lib/dkron-rb/models/inline_response_200.rb +181 -0
  39. data/lib/dkron-rb/models/job.rb +369 -0
  40. data/lib/dkron-rb/models/member.rb +301 -0
  41. data/lib/dkron-rb/models/serf.rb +152 -0
  42. data/lib/dkron-rb/models/status.rb +190 -0
  43. data/lib/dkron-rb/models/tags.rb +152 -0
  44. data/lib/dkron-rb/numeric_seconds.rb +48 -0
  45. data/lib/dkron-rb/version.rb +26 -0
  46. data/lib/dkron.rb +9 -0
  47. data/pkg/dkron-rb-0.9.2.gem +0 -0
  48. data/seeds.rb +18 -0
  49. data/spec/api/default_api_spec.rb +80 -0
  50. data/spec/api/executions_api_spec.rb +51 -0
  51. data/spec/api/jobs_api_spec.rb +114 -0
  52. data/spec/api/main_api_spec.rb +65 -0
  53. data/spec/api/members_api_spec.rb +50 -0
  54. data/spec/api_client_spec.rb +237 -0
  55. data/spec/configuration_spec.rb +53 -0
  56. data/spec/models/agent_spec.rb +36 -0
  57. data/spec/models/execution_spec.rb +96 -0
  58. data/spec/models/inline_response_200_spec.rb +66 -0
  59. data/spec/models/job_spec.rb +186 -0
  60. data/spec/models/member_spec.rb +146 -0
  61. data/spec/models/serf_spec.rb +36 -0
  62. data/spec/models/status_spec.rb +36 -0
  63. data/spec/models/tags_spec.rb +36 -0
  64. data/spec/spec_helper.rb +122 -0
  65. metadata +309 -0
@@ -0,0 +1,181 @@
1
+ =begin
2
+ Dkron REST API
3
+
4
+ You can communicate with Dkron using a RESTful JSON API over HTTP. Dkron nodes usually listen on port `8080` for API requests. All examples in this section assume that you've found a running leader at `localhost:8080`.\n\nDkron implements a RESTful JSON API over HTTP to communicate with software clients. Dkron listens in port `8080` by default. All examples in this section assume that you're using the default port.\n\nDefault API responses are unformatted JSON add the `pretty=true` param to format the response.\n
5
+
6
+ OpenAPI spec version: 0.7.2
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Dkron
16
+ class InlineResponse200
17
+ attr_accessor :agent
18
+
19
+ attr_accessor :serf
20
+
21
+ attr_accessor :tags
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+
27
+ :'agent' => :'agent',
28
+
29
+ :'serf' => :'serf',
30
+
31
+ :'tags' => :'tags'
32
+
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.swagger_types
38
+ {
39
+ :'agent' => :'Agent',
40
+ :'serf' => :'Serf',
41
+ :'tags' => :'Tags'
42
+
43
+ }
44
+ end
45
+
46
+ def initialize(attributes = {})
47
+ return unless attributes.is_a?(Hash)
48
+
49
+ # convert string to symbol for hash key
50
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
51
+
52
+
53
+ if attributes[:'agent']
54
+ self.agent = attributes[:'agent']
55
+ end
56
+
57
+ if attributes[:'serf']
58
+ self.serf = attributes[:'serf']
59
+ end
60
+
61
+ if attributes[:'tags']
62
+ self.tags = attributes[:'tags']
63
+ end
64
+
65
+ end
66
+
67
+ # Check equality by comparing each attribute.
68
+ def ==(o)
69
+ return true if self.equal?(o)
70
+ self.class == o.class &&
71
+ agent == o.agent &&
72
+ serf == o.serf &&
73
+ tags == o.tags
74
+ end
75
+
76
+ # @see the `==` method
77
+ def eql?(o)
78
+ self == o
79
+ end
80
+
81
+ # Calculate hash code according to all attributes.
82
+ def hash
83
+ [agent, serf, tags].hash
84
+ end
85
+
86
+ # build the object from hash
87
+ def build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ self.class.swagger_types.each_pair do |key, type|
90
+ if type =~ /^Array<(.*)>/i
91
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
92
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
93
+ else
94
+ #TODO show warning in debug mode
95
+ end
96
+ elsif !attributes[self.class.attribute_map[key]].nil?
97
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
98
+ else
99
+ # data not found in attributes(hash), not an issue as the data can be optional
100
+ end
101
+ end
102
+
103
+ self
104
+ end
105
+
106
+ def _deserialize(type, value)
107
+ case type.to_sym
108
+ when :DateTime
109
+ DateTime.parse(value)
110
+ when :Date
111
+ Date.parse(value)
112
+ when :String
113
+ value.to_s
114
+ when :Integer
115
+ value.to_i
116
+ when :Float
117
+ value.to_f
118
+ when :BOOLEAN
119
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
120
+ true
121
+ else
122
+ false
123
+ end
124
+ when :Object
125
+ # generic object (usually a Hash), return directly
126
+ value
127
+ when /\AArray<(?<inner_type>.+)>\z/
128
+ inner_type = Regexp.last_match[:inner_type]
129
+ value.map { |v| _deserialize(inner_type, v) }
130
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
131
+ k_type = Regexp.last_match[:k_type]
132
+ v_type = Regexp.last_match[:v_type]
133
+ {}.tap do |hash|
134
+ value.each do |k, v|
135
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
136
+ end
137
+ end
138
+ else # model
139
+ _model = Dkron.const_get(type).new
140
+ _model.build_from_hash(value)
141
+ end
142
+ end
143
+
144
+ def to_s
145
+ to_hash.to_s
146
+ end
147
+
148
+ # to_body is an alias to to_body (backward compatibility))
149
+ def to_body
150
+ to_hash
151
+ end
152
+
153
+ # return the object in the form of hash
154
+ def to_hash
155
+ hash = {}
156
+ self.class.attribute_map.each_pair do |attr, param|
157
+ value = self.send(attr)
158
+ next if value.nil?
159
+ hash[param] = _to_hash(value)
160
+ end
161
+ hash
162
+ end
163
+
164
+ # Method to output non-array value in the form of hash
165
+ # For object, use to_hash. Otherwise, just return the value
166
+ def _to_hash(value)
167
+ if value.is_a?(Array)
168
+ value.compact.map{ |v| _to_hash(v) }
169
+ elsif value.is_a?(Hash)
170
+ {}.tap do |hash|
171
+ value.each { |k, v| hash[k] = _to_hash(v) }
172
+ end
173
+ elsif value.respond_to? :to_hash
174
+ value.to_hash
175
+ else
176
+ value
177
+ end
178
+ end
179
+
180
+ end
181
+ end
@@ -0,0 +1,369 @@
1
+ =begin
2
+ #Dkron REST API
3
+
4
+ #You can communicate with Dkron using a RESTful JSON API over HTTP. Dkron nodes usually listen on port `8080` for API requests. All examples in this section assume that you've found a running leader at `localhost:8080`. Dkron implements a RESTful JSON API over HTTP to communicate with software clients. Dkron listens in port `8080` by default. All examples in this section assume that you're using the default port. Default API responses are unformatted JSON add the `pretty=true` param to format the response.
5
+
6
+ OpenAPI spec version: 0.9.2
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module Dkron
27
+ # A Job represents a scheduled task to execute.
28
+ class Job
29
+ # Name for the job.
30
+ attr_accessor :name
31
+
32
+ # Cron expression for the job.
33
+ attr_accessor :schedule
34
+
35
+ # Command to run.
36
+ attr_accessor :command
37
+
38
+ # Use shell to run the command
39
+ attr_accessor :shell
40
+
41
+ # Owner of the job
42
+ attr_accessor :owner
43
+
44
+ # Email of the owner
45
+ attr_accessor :owner_email
46
+
47
+ # Number of successful executions
48
+ attr_accessor :success_count
49
+
50
+ # Number of failed executions
51
+ attr_accessor :error_count
52
+
53
+ # Last time this job executed successfully
54
+ attr_accessor :last_success
55
+
56
+ # Last time this job failed
57
+ attr_accessor :last_error
58
+
59
+ # Disabled state of the job
60
+ attr_accessor :disabled
61
+
62
+ # Target nodes tags of this job
63
+ attr_accessor :tags
64
+
65
+ # Number of times to retry a failed job execution
66
+ attr_accessor :retries
67
+
68
+ # The name/id of the job that will trigger the execution of this job
69
+ attr_accessor :parent_job
70
+
71
+ # Array containing the jobs that depends on this one
72
+ attr_accessor :dependent_jobs
73
+
74
+ # Processor plugins used to process executions results of this job
75
+ attr_accessor :processors
76
+
77
+ # Concurrency policy for the job allow/forbid
78
+ attr_accessor :concurrency
79
+
80
+
81
+ # Attribute mapping from ruby-style variable name to JSON key.
82
+ def self.attribute_map
83
+ {
84
+ :'name' => :'name',
85
+ :'schedule' => :'schedule',
86
+ :'command' => :'command',
87
+ :'shell' => :'shell',
88
+ :'owner' => :'owner',
89
+ :'owner_email' => :'owner_email',
90
+ :'success_count' => :'success_count',
91
+ :'error_count' => :'error_count',
92
+ :'last_success' => :'last_success',
93
+ :'last_error' => :'last_error',
94
+ :'disabled' => :'disabled',
95
+ :'tags' => :'tags',
96
+ :'retries' => :'retries',
97
+ :'parent_job' => :'parent_job',
98
+ :'dependent_jobs' => :'dependent_jobs',
99
+ :'processors' => :'processors',
100
+ :'concurrency' => :'concurrency'
101
+ }
102
+ end
103
+
104
+ # Attribute type mapping.
105
+ def self.swagger_types
106
+ {
107
+ :'name' => :'String',
108
+ :'schedule' => :'String',
109
+ :'command' => :'String',
110
+ :'shell' => :'BOOLEAN',
111
+ :'owner' => :'String',
112
+ :'owner_email' => :'String',
113
+ :'success_count' => :'Integer',
114
+ :'error_count' => :'Integer',
115
+ :'last_success' => :'DateTime',
116
+ :'last_error' => :'DateTime',
117
+ :'disabled' => :'BOOLEAN',
118
+ :'tags' => :'Hash<String, String>',
119
+ :'retries' => :'Integer',
120
+ :'parent_job' => :'String',
121
+ :'dependent_jobs' => :'Array<null>',
122
+ :'processors' => :'Hash<String, String>',
123
+ :'concurrency' => :'String'
124
+ }
125
+ end
126
+
127
+ # Initializes the object
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ def initialize(attributes = {})
130
+ return unless attributes.is_a?(Hash)
131
+
132
+ # convert string to symbol for hash key
133
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
134
+
135
+ if attributes.has_key?(:'name')
136
+ self.name = attributes[:'name']
137
+ end
138
+
139
+ if attributes.has_key?(:'schedule')
140
+ self.schedule = attributes[:'schedule']
141
+ end
142
+
143
+ if attributes.has_key?(:'command')
144
+ self.command = attributes[:'command']
145
+ end
146
+
147
+ if attributes.has_key?(:'shell')
148
+ self.shell = attributes[:'shell']
149
+ end
150
+
151
+ if attributes.has_key?(:'owner')
152
+ self.owner = attributes[:'owner']
153
+ end
154
+
155
+ if attributes.has_key?(:'owner_email')
156
+ self.owner_email = attributes[:'owner_email']
157
+ end
158
+
159
+ if attributes.has_key?(:'success_count')
160
+ self.success_count = attributes[:'success_count']
161
+ end
162
+
163
+ if attributes.has_key?(:'error_count')
164
+ self.error_count = attributes[:'error_count']
165
+ end
166
+
167
+ if attributes.has_key?(:'last_success')
168
+ self.last_success = attributes[:'last_success']
169
+ end
170
+
171
+ if attributes.has_key?(:'last_error')
172
+ self.last_error = attributes[:'last_error']
173
+ end
174
+
175
+ if attributes.has_key?(:'disabled')
176
+ self.disabled = attributes[:'disabled']
177
+ end
178
+
179
+ if attributes.has_key?(:'tags')
180
+ if (value = attributes[:'tags']).is_a?(Array)
181
+ self.tags = value
182
+ end
183
+ end
184
+
185
+ if attributes.has_key?(:'retries')
186
+ self.retries = attributes[:'retries']
187
+ end
188
+
189
+ if attributes.has_key?(:'parent_job')
190
+ self.parent_job = attributes[:'parent_job']
191
+ end
192
+
193
+ if attributes.has_key?(:'dependent_jobs')
194
+ if (value = attributes[:'dependent_jobs']).is_a?(Array)
195
+ self.dependent_jobs = value
196
+ end
197
+ end
198
+
199
+ if attributes.has_key?(:'processors')
200
+ if (value = attributes[:'processors']).is_a?(Array)
201
+ self.processors = value
202
+ end
203
+ end
204
+
205
+ if attributes.has_key?(:'concurrency')
206
+ self.concurrency = attributes[:'concurrency']
207
+ end
208
+
209
+ end
210
+
211
+ # Show invalid properties with the reasons. Usually used together with valid?
212
+ # @return Array for valid properies with the reasons
213
+ def list_invalid_properties
214
+ invalid_properties = Array.new
215
+ return invalid_properties
216
+ end
217
+
218
+ # Check to see if the all the properties in the model are valid
219
+ # @return true if the model is valid
220
+ def valid?
221
+ return false if @name.nil?
222
+ return false if @schedule.nil?
223
+ return false if @command.nil?
224
+ return true
225
+ end
226
+
227
+ # Checks equality by comparing each attribute.
228
+ # @param [Object] Object to be compared
229
+ def ==(o)
230
+ return true if self.equal?(o)
231
+ self.class == o.class &&
232
+ name == o.name &&
233
+ schedule == o.schedule &&
234
+ command == o.command &&
235
+ shell == o.shell &&
236
+ owner == o.owner &&
237
+ owner_email == o.owner_email &&
238
+ success_count == o.success_count &&
239
+ error_count == o.error_count &&
240
+ last_success == o.last_success &&
241
+ last_error == o.last_error &&
242
+ disabled == o.disabled &&
243
+ tags == o.tags &&
244
+ retries == o.retries &&
245
+ parent_job == o.parent_job &&
246
+ dependent_jobs == o.dependent_jobs &&
247
+ processors == o.processors &&
248
+ concurrency == o.concurrency
249
+ end
250
+
251
+ # @see the `==` method
252
+ # @param [Object] Object to be compared
253
+ def eql?(o)
254
+ self == o
255
+ end
256
+
257
+ # Calculates hash code according to all attributes.
258
+ # @return [Fixnum] Hash code
259
+ def hash
260
+ [name, schedule, command, shell, owner, owner_email, success_count, error_count, last_success, last_error, disabled, tags, retries, parent_job, dependent_jobs, processors, concurrency].hash
261
+ end
262
+
263
+ # Builds the object from hash
264
+ # @param [Hash] attributes Model attributes in the form of hash
265
+ # @return [Object] Returns the model itself
266
+ def build_from_hash(attributes)
267
+ return nil unless attributes.is_a?(Hash)
268
+ self.class.swagger_types.each_pair do |key, type|
269
+ if type =~ /^Array<(.*)>/i
270
+ # check to ensure the input is an array given that the the attribute
271
+ # is documented as an array but the input is not
272
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
273
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
274
+ end
275
+ elsif !attributes[self.class.attribute_map[key]].nil?
276
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
277
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
278
+ end
279
+
280
+ self
281
+ end
282
+
283
+ # Deserializes the data based on type
284
+ # @param string type Data type
285
+ # @param string value Value to be deserialized
286
+ # @return [Object] Deserialized data
287
+ def _deserialize(type, value)
288
+ case type.to_sym
289
+ when :DateTime
290
+ DateTime.parse(value)
291
+ when :Date
292
+ Date.parse(value)
293
+ when :String
294
+ value.to_s
295
+ when :Integer
296
+ value.to_i
297
+ when :Float
298
+ value.to_f
299
+ when :BOOLEAN
300
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
301
+ true
302
+ else
303
+ false
304
+ end
305
+ when :Object
306
+ # generic object (usually a Hash), return directly
307
+ value
308
+ when /\AArray<(?<inner_type>.+)>\z/
309
+ inner_type = Regexp.last_match[:inner_type]
310
+ value.map { |v| _deserialize(inner_type, v) }
311
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
312
+ k_type = Regexp.last_match[:k_type]
313
+ v_type = Regexp.last_match[:v_type]
314
+ {}.tap do |hash|
315
+ value.each do |k, v|
316
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
317
+ end
318
+ end
319
+ else # model
320
+ temp_model = Dkron.const_get(type).new
321
+ temp_model.build_from_hash(value)
322
+ end
323
+ end
324
+
325
+ # Returns the string representation of the object
326
+ # @return [String] String presentation of the object
327
+ def to_s
328
+ to_hash.to_s
329
+ end
330
+
331
+ # to_body is an alias to to_hash (backward compatibility)
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_body
334
+ to_hash
335
+ end
336
+
337
+ # Returns the object in the form of hash
338
+ # @return [Hash] Returns the object in the form of hash
339
+ def to_hash
340
+ hash = {}
341
+ self.class.attribute_map.each_pair do |attr, param|
342
+ value = self.send(attr)
343
+ next if value.nil?
344
+ hash[param] = _to_hash(value)
345
+ end
346
+ hash
347
+ end
348
+
349
+ # Outputs non-array value in the form of hash
350
+ # For object, use to_hash. Otherwise, just return the value
351
+ # @param [Object] value Any valid value
352
+ # @return [Hash] Returns the value in the form of hash
353
+ def _to_hash(value)
354
+ if value.is_a?(Array)
355
+ value.compact.map{ |v| _to_hash(v) }
356
+ elsif value.is_a?(Hash)
357
+ {}.tap do |hash|
358
+ value.each { |k, v| hash[k] = _to_hash(v) }
359
+ end
360
+ elsif value.respond_to? :to_hash
361
+ value.to_hash
362
+ else
363
+ value
364
+ end
365
+ end
366
+
367
+ end
368
+
369
+ end