dkron-rb 0.9.2
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +65 -0
- data/LICENSE +201 -0
- data/README.md +98 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config.json +5 -0
- data/dkron-rb-0.0.1.gem +0 -0
- data/dkron-rb-0.0.2.gem +0 -0
- data/dkron-rb.gemspec +55 -0
- data/docs/Agent.md +7 -0
- data/docs/DefaultApi.md +131 -0
- data/docs/Execution.md +13 -0
- data/docs/ExecutionsApi.md +55 -0
- data/docs/InlineResponse200.md +10 -0
- data/docs/Job.md +24 -0
- data/docs/JobsApi.md +237 -0
- data/docs/MainApi.md +90 -0
- data/docs/Member.md +18 -0
- data/docs/MembersApi.md +49 -0
- data/docs/Serf.md +7 -0
- data/docs/Status.md +7 -0
- data/docs/Tags.md +7 -0
- data/git_push.sh +67 -0
- data/lib/dkron-rb.rb +47 -0
- data/lib/dkron-rb/api/default_api.rb +193 -0
- data/lib/dkron-rb/api/executions_api.rb +91 -0
- data/lib/dkron-rb/api/jobs_api.rb +315 -0
- data/lib/dkron-rb/api/members_api.rb +87 -0
- data/lib/dkron-rb/api_client.rb +378 -0
- data/lib/dkron-rb/api_error.rb +47 -0
- data/lib/dkron-rb/configuration.rb +207 -0
- data/lib/dkron-rb/cron.rb +152 -0
- data/lib/dkron-rb/models/agent.rb +152 -0
- data/lib/dkron-rb/models/execution.rb +250 -0
- data/lib/dkron-rb/models/inline_response_200.rb +181 -0
- data/lib/dkron-rb/models/job.rb +369 -0
- data/lib/dkron-rb/models/member.rb +301 -0
- data/lib/dkron-rb/models/serf.rb +152 -0
- data/lib/dkron-rb/models/status.rb +190 -0
- data/lib/dkron-rb/models/tags.rb +152 -0
- data/lib/dkron-rb/numeric_seconds.rb +48 -0
- data/lib/dkron-rb/version.rb +26 -0
- data/lib/dkron.rb +9 -0
- data/pkg/dkron-rb-0.9.2.gem +0 -0
- data/seeds.rb +18 -0
- data/spec/api/default_api_spec.rb +80 -0
- data/spec/api/executions_api_spec.rb +51 -0
- data/spec/api/jobs_api_spec.rb +114 -0
- data/spec/api/main_api_spec.rb +65 -0
- data/spec/api/members_api_spec.rb +50 -0
- data/spec/api_client_spec.rb +237 -0
- data/spec/configuration_spec.rb +53 -0
- data/spec/models/agent_spec.rb +36 -0
- data/spec/models/execution_spec.rb +96 -0
- data/spec/models/inline_response_200_spec.rb +66 -0
- data/spec/models/job_spec.rb +186 -0
- data/spec/models/member_spec.rb +146 -0
- data/spec/models/serf_spec.rb +36 -0
- data/spec/models/status_spec.rb +36 -0
- data/spec/models/tags_spec.rb +36 -0
- data/spec/spec_helper.rb +122 -0
- metadata +309 -0
@@ -0,0 +1,190 @@
|
|
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
|
+
# Status represents details about the node.
|
28
|
+
class Status
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute type mapping.
|
37
|
+
def self.swagger_types
|
38
|
+
{
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
# Initializes the object
|
43
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
44
|
+
def initialize(attributes = {})
|
45
|
+
return unless attributes.is_a?(Hash)
|
46
|
+
|
47
|
+
# convert string to symbol for hash key
|
48
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
53
|
+
# @return Array for valid properies with the reasons
|
54
|
+
def list_invalid_properties
|
55
|
+
invalid_properties = Array.new
|
56
|
+
return invalid_properties
|
57
|
+
end
|
58
|
+
|
59
|
+
# Check to see if the all the properties in the model are valid
|
60
|
+
# @return true if the model is valid
|
61
|
+
def valid?
|
62
|
+
return true
|
63
|
+
end
|
64
|
+
|
65
|
+
# Checks equality by comparing each attribute.
|
66
|
+
# @param [Object] Object to be compared
|
67
|
+
def ==(o)
|
68
|
+
return true if self.equal?(o)
|
69
|
+
self.class == o.class
|
70
|
+
end
|
71
|
+
|
72
|
+
# @see the `==` method
|
73
|
+
# @param [Object] Object to be compared
|
74
|
+
def eql?(o)
|
75
|
+
self == o
|
76
|
+
end
|
77
|
+
|
78
|
+
# Calculates hash code according to all attributes.
|
79
|
+
# @return [Fixnum] Hash code
|
80
|
+
def hash
|
81
|
+
[].hash
|
82
|
+
end
|
83
|
+
|
84
|
+
# Builds the object from hash
|
85
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
86
|
+
# @return [Object] Returns the model itself
|
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
|
+
# check to ensure the input is an array given that the the attribute
|
92
|
+
# is documented as an array but the input is not
|
93
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
94
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
95
|
+
end
|
96
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
97
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
98
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
99
|
+
end
|
100
|
+
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
# Deserializes the data based on type
|
105
|
+
# @param string type Data type
|
106
|
+
# @param string value Value to be deserialized
|
107
|
+
# @return [Object] Deserialized data
|
108
|
+
def _deserialize(type, value)
|
109
|
+
case type.to_sym
|
110
|
+
when :DateTime
|
111
|
+
DateTime.parse(value)
|
112
|
+
when :Date
|
113
|
+
Date.parse(value)
|
114
|
+
when :String
|
115
|
+
value.to_s
|
116
|
+
when :Integer
|
117
|
+
value.to_i
|
118
|
+
when :Float
|
119
|
+
value.to_f
|
120
|
+
when :BOOLEAN
|
121
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
122
|
+
true
|
123
|
+
else
|
124
|
+
false
|
125
|
+
end
|
126
|
+
when :Object
|
127
|
+
# generic object (usually a Hash), return directly
|
128
|
+
value
|
129
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
130
|
+
inner_type = Regexp.last_match[:inner_type]
|
131
|
+
value.map { |v| _deserialize(inner_type, v) }
|
132
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
133
|
+
k_type = Regexp.last_match[:k_type]
|
134
|
+
v_type = Regexp.last_match[:v_type]
|
135
|
+
{}.tap do |hash|
|
136
|
+
value.each do |k, v|
|
137
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
else # model
|
141
|
+
temp_model = Dkron.const_get(type).new
|
142
|
+
temp_model.build_from_hash(value)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Returns the string representation of the object
|
147
|
+
# @return [String] String presentation of the object
|
148
|
+
def to_s
|
149
|
+
to_hash.to_s
|
150
|
+
end
|
151
|
+
|
152
|
+
# to_body is an alias to to_hash (backward compatibility)
|
153
|
+
# @return [Hash] Returns the object in the form of hash
|
154
|
+
def to_body
|
155
|
+
to_hash
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the object in the form of hash
|
159
|
+
# @return [Hash] Returns the object in the form of hash
|
160
|
+
def to_hash
|
161
|
+
hash = {}
|
162
|
+
self.class.attribute_map.each_pair do |attr, param|
|
163
|
+
value = self.send(attr)
|
164
|
+
next if value.nil?
|
165
|
+
hash[param] = _to_hash(value)
|
166
|
+
end
|
167
|
+
hash
|
168
|
+
end
|
169
|
+
|
170
|
+
# Outputs non-array value in the form of hash
|
171
|
+
# For object, use to_hash. Otherwise, just return the value
|
172
|
+
# @param [Object] value Any valid value
|
173
|
+
# @return [Hash] Returns the value in the form of hash
|
174
|
+
def _to_hash(value)
|
175
|
+
if value.is_a?(Array)
|
176
|
+
value.compact.map{ |v| _to_hash(v) }
|
177
|
+
elsif value.is_a?(Hash)
|
178
|
+
{}.tap do |hash|
|
179
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
180
|
+
end
|
181
|
+
elsif value.respond_to? :to_hash
|
182
|
+
value.to_hash
|
183
|
+
else
|
184
|
+
value
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
@@ -0,0 +1,152 @@
|
|
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
|
+
# Tags asociated with this node
|
17
|
+
class Tags
|
18
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
+
def self.attribute_map
|
20
|
+
{
|
21
|
+
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Attribute type mapping.
|
26
|
+
def self.swagger_types
|
27
|
+
{
|
28
|
+
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(attributes = {})
|
33
|
+
return unless attributes.is_a?(Hash)
|
34
|
+
|
35
|
+
# convert string to symbol for hash key
|
36
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
# Check equality by comparing each attribute.
|
42
|
+
def ==(o)
|
43
|
+
return true if self.equal?(o)
|
44
|
+
self.class == o.class
|
45
|
+
end
|
46
|
+
|
47
|
+
# @see the `==` method
|
48
|
+
def eql?(o)
|
49
|
+
self == o
|
50
|
+
end
|
51
|
+
|
52
|
+
# Calculate hash code according to all attributes.
|
53
|
+
def hash
|
54
|
+
[].hash
|
55
|
+
end
|
56
|
+
|
57
|
+
# build the object from hash
|
58
|
+
def build_from_hash(attributes)
|
59
|
+
return nil unless attributes.is_a?(Hash)
|
60
|
+
self.class.swagger_types.each_pair do |key, type|
|
61
|
+
if type =~ /^Array<(.*)>/i
|
62
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
63
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
64
|
+
else
|
65
|
+
#TODO show warning in debug mode
|
66
|
+
end
|
67
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
68
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
69
|
+
else
|
70
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def _deserialize(type, value)
|
78
|
+
case type.to_sym
|
79
|
+
when :DateTime
|
80
|
+
DateTime.parse(value)
|
81
|
+
when :Date
|
82
|
+
Date.parse(value)
|
83
|
+
when :String
|
84
|
+
value.to_s
|
85
|
+
when :Integer
|
86
|
+
value.to_i
|
87
|
+
when :Float
|
88
|
+
value.to_f
|
89
|
+
when :BOOLEAN
|
90
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
91
|
+
true
|
92
|
+
else
|
93
|
+
false
|
94
|
+
end
|
95
|
+
when :Object
|
96
|
+
# generic object (usually a Hash), return directly
|
97
|
+
value
|
98
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
99
|
+
inner_type = Regexp.last_match[:inner_type]
|
100
|
+
value.map { |v| _deserialize(inner_type, v) }
|
101
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
102
|
+
k_type = Regexp.last_match[:k_type]
|
103
|
+
v_type = Regexp.last_match[:v_type]
|
104
|
+
{}.tap do |hash|
|
105
|
+
value.each do |k, v|
|
106
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
else # model
|
110
|
+
_model = Dkron.const_get(type).new
|
111
|
+
_model.build_from_hash(value)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_s
|
116
|
+
to_hash.to_s
|
117
|
+
end
|
118
|
+
|
119
|
+
# to_body is an alias to to_body (backward compatibility))
|
120
|
+
def to_body
|
121
|
+
to_hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# return the object in the form of hash
|
125
|
+
def to_hash
|
126
|
+
hash = {}
|
127
|
+
self.class.attribute_map.each_pair do |attr, param|
|
128
|
+
value = self.send(attr)
|
129
|
+
next if value.nil?
|
130
|
+
hash[param] = _to_hash(value)
|
131
|
+
end
|
132
|
+
hash
|
133
|
+
end
|
134
|
+
|
135
|
+
# Method to output non-array value in the form of hash
|
136
|
+
# For object, use to_hash. Otherwise, just return the value
|
137
|
+
def _to_hash(value)
|
138
|
+
if value.is_a?(Array)
|
139
|
+
value.compact.map{ |v| _to_hash(v) }
|
140
|
+
elsif value.is_a?(Hash)
|
141
|
+
{}.tap do |hash|
|
142
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
143
|
+
end
|
144
|
+
elsif value.respond_to? :to_hash
|
145
|
+
value.to_hash
|
146
|
+
else
|
147
|
+
value
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Dkron
|
2
|
+
class NumericSeconds
|
3
|
+
attr_reader :number
|
4
|
+
|
5
|
+
def self.seconds(number, units)
|
6
|
+
new(number).send(units)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(number)
|
10
|
+
@number = number.to_i
|
11
|
+
end
|
12
|
+
|
13
|
+
def seconds
|
14
|
+
number
|
15
|
+
end
|
16
|
+
alias :second :seconds
|
17
|
+
|
18
|
+
def minutes
|
19
|
+
number * 60
|
20
|
+
end
|
21
|
+
alias :minute :minutes
|
22
|
+
|
23
|
+
def hours
|
24
|
+
number * 3_600
|
25
|
+
end
|
26
|
+
alias :hour :hours
|
27
|
+
|
28
|
+
def days
|
29
|
+
number * 86_400
|
30
|
+
end
|
31
|
+
alias :day :days
|
32
|
+
|
33
|
+
def weeks
|
34
|
+
number * 604_800
|
35
|
+
end
|
36
|
+
alias :week :weeks
|
37
|
+
|
38
|
+
def months
|
39
|
+
number * 2_592_000
|
40
|
+
end
|
41
|
+
alias :month :months
|
42
|
+
|
43
|
+
def years
|
44
|
+
number * 31_557_600
|
45
|
+
end
|
46
|
+
alias :year :years
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
module Dkron
|
25
|
+
VERSION = "0.9.2"
|
26
|
+
end
|
data/lib/dkron.rb
ADDED
Binary file
|
data/seeds.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Dkron.configure do
|
2
|
+
|c| c.host = "localhost:32847"
|
3
|
+
end
|
4
|
+
|
5
|
+
5.times do |i|
|
6
|
+
j = Dkron::Job.new
|
7
|
+
j.name = "job_#{i}"
|
8
|
+
j.command = "date"
|
9
|
+
j.schedule = "@every 5s"
|
10
|
+
j.tags = {
|
11
|
+
role: "web"
|
12
|
+
}
|
13
|
+
j.disabled = false
|
14
|
+
|
15
|
+
ja = Dkron::JobsApi.new
|
16
|
+
ja.create_or_update_job(j)
|
17
|
+
end
|
18
|
+
|