iron_titan 0.0.1

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.
@@ -0,0 +1,158 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.0.1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module IronTitan
16
+ class JobWrapper
17
+ attr_accessor :job
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+
23
+ :'job' => :'job'
24
+
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'job' => :'Job'
32
+
33
+ }
34
+ end
35
+
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
41
+
42
+
43
+ if attributes[:'job']
44
+ self.job = attributes[:'job']
45
+ end
46
+
47
+ end
48
+
49
+ # Check equality by comparing each attribute.
50
+ def ==(o)
51
+ return true if self.equal?(o)
52
+ self.class == o.class &&
53
+ job == o.job
54
+ end
55
+
56
+ # @see the `==` method
57
+ def eql?(o)
58
+ self == o
59
+ end
60
+
61
+ # Calculate hash code according to all attributes.
62
+ def hash
63
+ [job].hash
64
+ end
65
+
66
+ # build the object from hash
67
+ def build_from_hash(attributes)
68
+ return nil unless attributes.is_a?(Hash)
69
+ self.class.swagger_types.each_pair do |key, type|
70
+ if type =~ /^Array<(.*)>/i
71
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
72
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
73
+ else
74
+ #TODO show warning in debug mode
75
+ end
76
+ elsif !attributes[self.class.attribute_map[key]].nil?
77
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
78
+ else
79
+ # data not found in attributes(hash), not an issue as the data can be optional
80
+ end
81
+ end
82
+
83
+ self
84
+ end
85
+
86
+ def _deserialize(type, value)
87
+ case type.to_sym
88
+ when :DateTime
89
+ DateTime.parse(value)
90
+ when :Date
91
+ Date.parse(value)
92
+ when :String
93
+ value.to_s
94
+ when :Integer
95
+ value.to_i
96
+ when :Float
97
+ value.to_f
98
+ when :BOOLEAN
99
+ if value =~ /^(true|t|yes|y|1)$/i
100
+ true
101
+ else
102
+ false
103
+ end
104
+ when /\AArray<(?<inner_type>.+)>\z/
105
+ inner_type = Regexp.last_match[:inner_type]
106
+ value.map { |v| _deserialize(inner_type, v) }
107
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
108
+ k_type = Regexp.last_match[:k_type]
109
+ v_type = Regexp.last_match[:v_type]
110
+ {}.tap do |hash|
111
+ value.each do |k, v|
112
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
113
+ end
114
+ end
115
+ else # model
116
+ _model = IronTitan.const_get(type).new
117
+ _model.build_from_hash(value)
118
+ end
119
+ end
120
+
121
+ def to_s
122
+ to_hash.to_s
123
+ end
124
+
125
+ # to_body is an alias to to_body (backward compatibility))
126
+ def to_body
127
+ to_hash
128
+ end
129
+
130
+ # return the object in the form of hash
131
+ def to_hash
132
+ hash = {}
133
+ self.class.attribute_map.each_pair do |attr, param|
134
+ value = self.send(attr)
135
+ next if value.nil?
136
+ hash[param] = _to_hash(value)
137
+ end
138
+ hash
139
+ end
140
+
141
+ # Method to output non-array value in the form of hash
142
+ # For object, use to_hash. Otherwise, just return the value
143
+ def _to_hash(value)
144
+ if value.is_a?(Array)
145
+ value.compact.map{ |v| _to_hash(v) }
146
+ elsif value.is_a?(Hash)
147
+ {}.tap do |hash|
148
+ value.each { |k, v| hash[k] = _to_hash(v) }
149
+ end
150
+ elsif value.respond_to? :to_hash
151
+ value.to_hash
152
+ else
153
+ value
154
+ end
155
+ end
156
+
157
+ end
158
+ end
@@ -0,0 +1,214 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.0.1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module IronTitan
16
+ class NewJob
17
+ # Docker image to use for job. Default is 'image'
18
+ attr_accessor :name
19
+
20
+ # Docker image to use for job.
21
+ attr_accessor :image
22
+
23
+ # Payload for the job. This is what you pass into each job to make it do something.
24
+ attr_accessor :payload
25
+
26
+ # Number of seconds to wait before starting. Default 0.
27
+ attr_accessor :delay
28
+
29
+ # Maximum runtime in seconds. If job runs for longer, it will be killed. Default 60 seconds.
30
+ attr_accessor :timeout
31
+
32
+ # Number of retries. Default 3.
33
+ attr_accessor :retries
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+
39
+ :'name' => :'name',
40
+
41
+ :'image' => :'image',
42
+
43
+ :'payload' => :'payload',
44
+
45
+ :'delay' => :'delay',
46
+
47
+ :'timeout' => :'timeout',
48
+
49
+ :'retries' => :'retries'
50
+
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.swagger_types
56
+ {
57
+ :'name' => :'String',
58
+ :'image' => :'String',
59
+ :'payload' => :'String',
60
+ :'delay' => :'Float',
61
+ :'timeout' => :'Float',
62
+ :'retries' => :'Integer'
63
+
64
+ }
65
+ end
66
+
67
+ def initialize(attributes = {})
68
+ return unless attributes.is_a?(Hash)
69
+
70
+ # convert string to symbol for hash key
71
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
72
+
73
+
74
+ if attributes[:'name']
75
+ self.name = attributes[:'name']
76
+ end
77
+
78
+ if attributes[:'image']
79
+ self.image = attributes[:'image']
80
+ end
81
+
82
+ if attributes[:'payload']
83
+ self.payload = attributes[:'payload']
84
+ end
85
+
86
+ if attributes[:'delay']
87
+ self.delay = attributes[:'delay']
88
+ end
89
+
90
+ if attributes[:'timeout']
91
+ self.timeout = attributes[:'timeout']
92
+ end
93
+
94
+ if attributes[:'retries']
95
+ self.retries = attributes[:'retries']
96
+ end
97
+
98
+ end
99
+
100
+ # Check equality by comparing each attribute.
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ name == o.name &&
105
+ image == o.image &&
106
+ payload == o.payload &&
107
+ delay == o.delay &&
108
+ timeout == o.timeout &&
109
+ retries == o.retries
110
+ end
111
+
112
+ # @see the `==` method
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculate hash code according to all attributes.
118
+ def hash
119
+ [name, image, payload, delay, timeout, retries].hash
120
+ end
121
+
122
+ # build the object from hash
123
+ def build_from_hash(attributes)
124
+ return nil unless attributes.is_a?(Hash)
125
+ self.class.swagger_types.each_pair do |key, type|
126
+ if type =~ /^Array<(.*)>/i
127
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
128
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
129
+ else
130
+ #TODO show warning in debug mode
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ else
135
+ # data not found in attributes(hash), not an issue as the data can be optional
136
+ end
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ def _deserialize(type, value)
143
+ case type.to_sym
144
+ when :DateTime
145
+ DateTime.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :BOOLEAN
155
+ if value =~ /^(true|t|yes|y|1)$/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when /\AArray<(?<inner_type>.+)>\z/
161
+ inner_type = Regexp.last_match[:inner_type]
162
+ value.map { |v| _deserialize(inner_type, v) }
163
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
164
+ k_type = Regexp.last_match[:k_type]
165
+ v_type = Regexp.last_match[:v_type]
166
+ {}.tap do |hash|
167
+ value.each do |k, v|
168
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
169
+ end
170
+ end
171
+ else # model
172
+ _model = IronTitan.const_get(type).new
173
+ _model.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_body (backward compatibility))
182
+ def to_body
183
+ to_hash
184
+ end
185
+
186
+ # return the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ next if value.nil?
192
+ hash[param] = _to_hash(value)
193
+ end
194
+ hash
195
+ end
196
+
197
+ # Method to output non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map{ |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+
213
+ end
214
+ end
@@ -0,0 +1,160 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.0.1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module IronTitan
16
+ class NewJobArray
17
+ attr_accessor :jobs
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+
23
+ :'jobs' => :'jobs'
24
+
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'jobs' => :'Array<NewJob>'
32
+
33
+ }
34
+ end
35
+
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
41
+
42
+
43
+ if attributes[:'jobs']
44
+ if (value = attributes[:'jobs']).is_a?(Array)
45
+ self.jobs = value
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ # Check equality by comparing each attribute.
52
+ def ==(o)
53
+ return true if self.equal?(o)
54
+ self.class == o.class &&
55
+ jobs == o.jobs
56
+ end
57
+
58
+ # @see the `==` method
59
+ def eql?(o)
60
+ self == o
61
+ end
62
+
63
+ # Calculate hash code according to all attributes.
64
+ def hash
65
+ [jobs].hash
66
+ end
67
+
68
+ # build the object from hash
69
+ def build_from_hash(attributes)
70
+ return nil unless attributes.is_a?(Hash)
71
+ self.class.swagger_types.each_pair do |key, type|
72
+ if type =~ /^Array<(.*)>/i
73
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
74
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
75
+ else
76
+ #TODO show warning in debug mode
77
+ end
78
+ elsif !attributes[self.class.attribute_map[key]].nil?
79
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
80
+ else
81
+ # data not found in attributes(hash), not an issue as the data can be optional
82
+ end
83
+ end
84
+
85
+ self
86
+ end
87
+
88
+ def _deserialize(type, value)
89
+ case type.to_sym
90
+ when :DateTime
91
+ DateTime.parse(value)
92
+ when :Date
93
+ Date.parse(value)
94
+ when :String
95
+ value.to_s
96
+ when :Integer
97
+ value.to_i
98
+ when :Float
99
+ value.to_f
100
+ when :BOOLEAN
101
+ if value =~ /^(true|t|yes|y|1)$/i
102
+ true
103
+ else
104
+ false
105
+ end
106
+ when /\AArray<(?<inner_type>.+)>\z/
107
+ inner_type = Regexp.last_match[:inner_type]
108
+ value.map { |v| _deserialize(inner_type, v) }
109
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
110
+ k_type = Regexp.last_match[:k_type]
111
+ v_type = Regexp.last_match[:v_type]
112
+ {}.tap do |hash|
113
+ value.each do |k, v|
114
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
115
+ end
116
+ end
117
+ else # model
118
+ _model = IronTitan.const_get(type).new
119
+ _model.build_from_hash(value)
120
+ end
121
+ end
122
+
123
+ def to_s
124
+ to_hash.to_s
125
+ end
126
+
127
+ # to_body is an alias to to_body (backward compatibility))
128
+ def to_body
129
+ to_hash
130
+ end
131
+
132
+ # return the object in the form of hash
133
+ def to_hash
134
+ hash = {}
135
+ self.class.attribute_map.each_pair do |attr, param|
136
+ value = self.send(attr)
137
+ next if value.nil?
138
+ hash[param] = _to_hash(value)
139
+ end
140
+ hash
141
+ end
142
+
143
+ # Method to output non-array value in the form of hash
144
+ # For object, use to_hash. Otherwise, just return the value
145
+ def _to_hash(value)
146
+ if value.is_a?(Array)
147
+ value.compact.map{ |v| _to_hash(v) }
148
+ elsif value.is_a?(Hash)
149
+ {}.tap do |hash|
150
+ value.each { |k, v| hash[k] = _to_hash(v) }
151
+ end
152
+ elsif value.respond_to? :to_hash
153
+ value.to_hash
154
+ else
155
+ value
156
+ end
157
+ end
158
+
159
+ end
160
+ end
@@ -0,0 +1,15 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.0.1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ module IronTitan
14
+ VERSION = "0.0.1"
15
+ end
data/lib/iron_titan.rb ADDED
@@ -0,0 +1,48 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.0.1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ # Common files
14
+ require 'iron_titan/api_client'
15
+ require 'iron_titan/api_error'
16
+ require 'iron_titan/version'
17
+ require 'iron_titan/configuration'
18
+
19
+ # Models
20
+ require 'iron_titan/models/job'
21
+ require 'iron_titan/models/new_job'
22
+ require 'iron_titan/models/new_job_array'
23
+ require 'iron_titan/models/job_array'
24
+ require 'iron_titan/models/job_wrapper'
25
+ require 'iron_titan/models/error_body'
26
+ require 'iron_titan/models/error'
27
+
28
+ # APIs
29
+ require 'iron_titan/api/jobs_api'
30
+ require 'iron_titan/api/core_api'
31
+
32
+ module IronTitan
33
+ class << self
34
+ # Customize default settings for the SDK using block.
35
+ # IronTitan.configure do |config|
36
+ # config.username = "xxx"
37
+ # config.password = "xxx"
38
+ # end
39
+ # If no block given, return the default Configuration object.
40
+ def configure
41
+ if block_given?
42
+ yield(Configuration.default)
43
+ else
44
+ Configuration.default
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,99 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.0.1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for IronTitan::CoreApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'CoreApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = IronTitan::CoreApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of CoreApi' do
30
+ it 'should create an instact of CoreApi' do
31
+ @instance.should be_a(IronTitan::CoreApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for job_id_get
36
+ # Gets job by id
37
+ # Gets a job by id.
38
+ # @param id Job id
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [JobWrapper]
41
+ describe 'job_id_get test' do
42
+ it "should work" do
43
+ # assertion here
44
+ # should be_a()
45
+ # should be_nil
46
+ # should ==
47
+ # should_not ==
48
+ end
49
+ end
50
+
51
+ # unit tests for job_id_patch
52
+ # Update a job
53
+ # Typically used to update status on error/completion. TODO: only allow &#39;status&#39; field.
54
+ # @param id Job id
55
+ # @param body Job data to post
56
+ # @param [Hash] opts the optional parameters
57
+ # @return [JobWrapper]
58
+ describe 'job_id_patch test' do
59
+ it "should work" do
60
+ # assertion here
61
+ # should be_a()
62
+ # should be_nil
63
+ # should ==
64
+ # should_not ==
65
+ end
66
+ end
67
+
68
+ # unit tests for jobs_get
69
+ # Get next job.
70
+ # Gets the next job in the queue, ready for processing.
71
+ # @param [Hash] opts the optional parameters
72
+ # @return [Array<JobArray>]
73
+ describe 'jobs_get test' do
74
+ it "should work" do
75
+ # assertion here
76
+ # should be_a()
77
+ # should be_nil
78
+ # should ==
79
+ # should_not ==
80
+ end
81
+ end
82
+
83
+ # unit tests for jobs_post
84
+ # Enqueue Job
85
+ # Enqueues a job.
86
+ # @param body Array of jobs to post.
87
+ # @param [Hash] opts the optional parameters
88
+ # @return [JobArray]
89
+ describe 'jobs_post test' do
90
+ it "should work" do
91
+ # assertion here
92
+ # should be_a()
93
+ # should be_nil
94
+ # should ==
95
+ # should_not ==
96
+ end
97
+ end
98
+
99
+ end