iron_titan 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +100 -29
  3. data/lib/iron_titan/api/core_api.rb +71 -12
  4. data/lib/iron_titan/api/images_api.rb +32 -32
  5. data/lib/iron_titan/api/jobs_api.rb +335 -75
  6. data/lib/iron_titan/api_client.rb +2 -2
  7. data/lib/iron_titan/api_error.rb +1 -1
  8. data/lib/iron_titan/models/error.rb +1 -1
  9. data/lib/iron_titan/models/error_body.rb +1 -1
  10. data/lib/iron_titan/models/id_status.rb +182 -0
  11. data/lib/iron_titan/models/image.rb +8 -8
  12. data/lib/iron_titan/models/image_wrapper.rb +1 -1
  13. data/lib/iron_titan/models/images_wrapper.rb +1 -1
  14. data/lib/iron_titan/models/job.rb +110 -103
  15. data/lib/iron_titan/models/job_wrapper.rb +1 -1
  16. data/lib/iron_titan/models/jobs_wrapper.rb +15 -5
  17. data/lib/iron_titan/models/new_job.rb +27 -50
  18. data/lib/iron_titan/models/new_job_with_image.rb +249 -0
  19. data/lib/iron_titan/models/new_jobs_wrapper.rb +2 -2
  20. data/lib/iron_titan/models/reason.rb +152 -0
  21. data/lib/iron_titan/version.rb +2 -2
  22. data/lib/iron_titan.rb +11 -9
  23. data/spec/api/core_api_spec.rb +21 -5
  24. data/spec/api/images_api_spec.rb +12 -12
  25. data/spec/api/jobs_api_spec.rb +92 -24
  26. data/spec/models/Error_spec.rb +2 -2
  27. data/spec/models/Job_spec.rb +15 -25
  28. data/spec/models/error_body_spec.rb +2 -2
  29. data/spec/models/id_status_spec.rb +56 -0
  30. data/spec/models/image_spec.rb +3 -3
  31. data/spec/models/image_wrapper_spec.rb +2 -2
  32. data/spec/models/images_wrapper_spec.rb +2 -2
  33. data/spec/models/job_wrapper_spec.rb +2 -2
  34. data/spec/models/jobs_wrapper_spec.rb +12 -2
  35. data/spec/models/log_spec.rb +1 -1
  36. data/spec/models/new_job_spec.rb +3 -33
  37. data/spec/models/new_job_with_image_spec.rb +116 -0
  38. data/spec/models/new_jobs_wrapper_spec.rb +2 -2
  39. data/spec/models/reason_spec.rb +36 -0
  40. metadata +11 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2abf37ff69c377cd77f5343af5bafc93bd9ae331
4
- data.tar.gz: d9b2a96fa1cd0e4758230d041deb916fc0e2b4a4
3
+ metadata.gz: 254c42c334e64d44981a5f724fd303695910946c
4
+ data.tar.gz: 59c3796348174db4b8fed23cf55b9255141d5ed9
5
5
  SHA512:
6
- metadata.gz: 81f587a06fc30a78c5ff91907bae6acba6e95ed371b4eb67871477723c4f783507285cf7d420c1196d190e8e4e7d0f8e214ad38469da4ffd3c53efec07fa5d01
7
- data.tar.gz: 5eb734844536527e63fbf4bf30a5c27a8b50b656892bd2c1d30ac4afd10fcb27c5bf5d9df0780166b47d0dc3a420feef98ac2b2ffedbe33e5d1300c872e13a35
6
+ metadata.gz: 9d21b88cbe11d9ceb90e67a4537dae81912e0b8d3804b3d9ca61bc3f909f80620f628515f6cfa58e48fdc28e118da27c6d181129bd0675b7c1bdc0cd5b4e9309
7
+ data.tar.gz: 680acef6b5b575a30c203b7407d0fbb327cf34335b2f8315f219446578253d395b641ee7fb99ce79e49b4fc085122f3280dc022a02deb394ca6287f88be2f99e
data/README.md CHANGED
@@ -1,46 +1,117 @@
1
+ # iron_titan
1
2
 
3
+ IronTitan - the Ruby gem for the Titan API
4
+
5
+ The ultimate, language agnostic, container based job processing framework.
6
+
7
+ This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
8
+
9
+ - API verion: 0.2.0
10
+ - Package version: 0.2.0
11
+ - Build date: 2016-03-29T20:51:39.687Z
12
+ - Build package: class io.swagger.codegen.languages.RubyClientCodegen
2
13
 
3
14
  ## Installation
4
15
 
16
+ ### Build a gem
17
+
18
+ To build the Ruby code into a gem:
19
+
20
+ ```shell
21
+ gem build iron_titan.gemspec
5
22
  ```
6
- gem install iron_titan
23
+
24
+ Then either install the gem locally:
25
+
26
+ ```shell
27
+ gem install ./iron_titan-0.2.0.gem
7
28
  ```
8
29
 
9
- Or add `gem "iron_titan"` to your Gemfile.
30
+ or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
10
31
 
11
- ## Usage
32
+ Finally add this to the Gemfile:
12
33
 
13
- ```ruby
14
- IronTitan.configure do |config|
15
- config.host = "192.168.99.100:8080"
16
- config.scheme = "http"
17
- end
34
+ gem 'iron_titan', '~> 0.2.0'
35
+
36
+ ### Install from Git
37
+
38
+ If the Ruby gem is hosted at a git repository: https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO, then add the following in the Gemfile:
39
+
40
+ gem 'iron_titan', :git => 'https://github.com/YOUR_GIT_USERNAME/YOUR_GIT_REPO.git'
41
+
42
+ ### Include the Ruby code directly
43
+
44
+ Include the Ruby code directly using `-I` as follows:
18
45
 
19
- @titan = IronTitan::JobsApi.new
46
+ ```shell
47
+ ruby -Ilib script.rb
20
48
  ```
21
49
 
22
- Then use it:
50
+ ## Getting Started
23
51
 
52
+ Please follow the [installation](#installation) procedure and then run the following code:
24
53
  ```ruby
25
- # Post a job
26
- r = @titan.jobs_post(jobs: [{
27
- image: 'treeder/echo:latest',
28
- delay: 5,
29
- payload: {input: 'Test Input'}.to_json
30
- }])
31
- input_string = "Test Input"
32
- job = r.jobs[0]
33
- p job
34
-
35
- # Get job status
36
- job = @titan.job_id_get(job.id).job
37
- puts job.status
38
-
39
- # Get logs
40
- log = @titan.job_id_log_get(r_payload.jobs[0].id).log
41
- p log
54
+ # Load the gem
55
+ require 'iron_titan'
56
+
57
+ api_instance = IronTitan::CoreApi.new
58
+
59
+ id = "id_example" # String | Job id
60
+
61
+
62
+ begin
63
+ #Delete the job.
64
+ api_instance.job_id_delete(id)
65
+ rescue IronTitan::ApiError => e
66
+ puts "Exception when calling CoreApi->job_id_delete: #{e}"
67
+ end
68
+
42
69
  ```
43
70
 
44
- ## Building/testing this Gem
71
+ ## Documentation for API Endpoints
72
+
73
+ All URIs are relative to *https://localhost:8080/v1*
74
+
75
+ Class | Method | HTTP request | Description
76
+ ------------ | ------------- | ------------- | -------------
77
+ *IronTitan::CoreApi* | [**job_id_delete**](docs/CoreApi.md#job_id_delete) | **DELETE** /job/{id} | Delete the job.
78
+ *IronTitan::CoreApi* | [**job_id_get**](docs/CoreApi.md#job_id_get) | **GET** /job/{id} | Gets job by id
79
+ *IronTitan::CoreApi* | [**jobs_consume_get**](docs/CoreApi.md#jobs_consume_get) | **GET** /jobs/consume | Get next job.
80
+ *IronTitan::CoreApi* | [**jobs_post**](docs/CoreApi.md#jobs_post) | **POST** /jobs | Enqueue Job
81
+ *IronTitan::ImagesApi* | [**image_id_get**](docs/ImagesApi.md#image_id_get) | **GET** /image/{id} | Get information for image id.
82
+ *IronTitan::ImagesApi* | [**images_get**](docs/ImagesApi.md#images_get) | **GET** /images | Get all image names.
83
+ *IronTitan::JobsApi* | [**job_id_cancel_post**](docs/JobsApi.md#job_id_cancel_post) | **POST** /job/{id}/cancel | Cancel a job.
84
+ *IronTitan::JobsApi* | [**job_id_delete**](docs/JobsApi.md#job_id_delete) | **DELETE** /job/{id} | Delete the job.
85
+ *IronTitan::JobsApi* | [**job_id_fail_post**](docs/JobsApi.md#job_id_fail_post) | **POST** /job/{id}/fail | Mark job as failed.
86
+ *IronTitan::JobsApi* | [**job_id_get**](docs/JobsApi.md#job_id_get) | **GET** /job/{id} | Gets job by id
87
+ *IronTitan::JobsApi* | [**job_id_log_get**](docs/JobsApi.md#job_id_log_get) | **GET** /job/{id}/log | Get the log of a completed job.
88
+ *IronTitan::JobsApi* | [**job_id_retry_post**](docs/JobsApi.md#job_id_retry_post) | **POST** /job/{id}/retry | Retry a job.
89
+ *IronTitan::JobsApi* | [**job_id_success_post**](docs/JobsApi.md#job_id_success_post) | **POST** /job/{id}/success | Mark job as succeeded.
90
+ *IronTitan::JobsApi* | [**job_id_touch_post**](docs/JobsApi.md#job_id_touch_post) | **POST** /job/{id}/touch | Extend job timeout.
91
+ *IronTitan::JobsApi* | [**jobs_consume_get**](docs/JobsApi.md#jobs_consume_get) | **GET** /jobs/consume | Get next job.
92
+ *IronTitan::JobsApi* | [**jobs_get**](docs/JobsApi.md#jobs_get) | **GET** /jobs | Peek at list of jobs.
93
+ *IronTitan::JobsApi* | [**jobs_name_get**](docs/JobsApi.md#jobs_name_get) | **GET** /jobs/{name} | Get job list by name.
94
+ *IronTitan::JobsApi* | [**jobs_post**](docs/JobsApi.md#jobs_post) | **POST** /jobs | Enqueue Job
95
+
96
+
97
+ ## Documentation for Models
98
+
99
+ - [IronTitan::Error](docs/Error.md)
100
+ - [IronTitan::ErrorBody](docs/ErrorBody.md)
101
+ - [IronTitan::IdStatus](docs/IdStatus.md)
102
+ - [IronTitan::Image](docs/Image.md)
103
+ - [IronTitan::ImageWrapper](docs/ImageWrapper.md)
104
+ - [IronTitan::ImagesWrapper](docs/ImagesWrapper.md)
105
+ - [IronTitan::Job](docs/Job.md)
106
+ - [IronTitan::JobWrapper](docs/JobWrapper.md)
107
+ - [IronTitan::JobsWrapper](docs/JobsWrapper.md)
108
+ - [IronTitan::NewJob](docs/NewJob.md)
109
+ - [IronTitan::NewJobWithImage](docs/NewJobWithImage.md)
110
+ - [IronTitan::NewJobsWrapper](docs/NewJobsWrapper.md)
111
+ - [IronTitan::Reason](docs/Reason.md)
112
+
113
+
114
+ ## Documentation for Authorization
115
+
116
+ All endpoints do not require authorization.
45
117
 
46
- This gem is built from the main [Titan repo](https://github.com/iron-io/titan).
@@ -3,7 +3,7 @@ Titan API
3
3
 
4
4
  The ultimate, language agnostic, container based job processing framework.
5
5
 
6
- OpenAPI spec version: 0.1.1
6
+ OpenAPI spec version: 0.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
 
@@ -20,6 +20,65 @@ module IronTitan
20
20
  @api_client = api_client
21
21
  end
22
22
 
23
+ # Delete the job.
24
+ # Delete only succeeds if job status is one of `succeeded\n| failed | cancelled`. Cancel a job if it is another state and needs to\nbe deleted. All information about the job, including the log, is\nirretrievably lost when this is invoked.
25
+ # @param id Job id
26
+ # @param [Hash] opts the optional parameters
27
+ # @return [nil]
28
+ def job_id_delete(id, opts = {})
29
+ job_id_delete_with_http_info(id, opts)
30
+ return nil
31
+ end
32
+
33
+ # Delete the job.
34
+ # Delete only succeeds if job status is one of `succeeded\n| failed | cancelled`. Cancel a job if it is another state and needs to\nbe deleted. All information about the job, including the log, is\nirretrievably lost when this is invoked.
35
+ # @param id Job id
36
+ # @param [Hash] opts the optional parameters
37
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
38
+ def job_id_delete_with_http_info(id, opts = {})
39
+ if @api_client.config.debugging
40
+ @api_client.config.logger.debug "Calling API: CoreApi#job_id_delete ..."
41
+ end
42
+
43
+ # verify the required parameter 'id' is set
44
+ fail "Missing the required parameter 'id' when calling job_id_delete" if id.nil?
45
+
46
+ # resource path
47
+ local_var_path = "/job/{id}".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)
48
+
49
+ # query parameters
50
+ query_params = {}
51
+
52
+ # header parameters
53
+ header_params = {}
54
+
55
+ # HTTP header 'Accept' (if needed)
56
+ _header_accept = ['application/json']
57
+ _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
58
+
59
+ # HTTP header 'Content-Type'
60
+ _header_content_type = ['application/json']
61
+ header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
62
+
63
+ # form parameters
64
+ form_params = {}
65
+
66
+ # http body (model)
67
+ post_body = nil
68
+
69
+ auth_names = []
70
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
71
+ :header_params => header_params,
72
+ :query_params => query_params,
73
+ :form_params => form_params,
74
+ :body => post_body,
75
+ :auth_names => auth_names)
76
+ if @api_client.config.debugging
77
+ @api_client.config.logger.debug "API called: CoreApi#job_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
78
+ end
79
+ return data, status_code, headers
80
+ end
81
+
23
82
  # Gets job by id
24
83
  # Gets a job by id.
25
84
  # @param id Job id
@@ -81,27 +140,27 @@ module IronTitan
81
140
  end
82
141
 
83
142
  # Get next job.
84
- # Gets the next job in the queue, ready for processing.
143
+ # Gets the next job in the queue, ready for processing. Titan may return <=n jobs. Consumers should start processing jobs in order. Each returned job is set to `status` \"running\" and `started_at` is set to the current time. No other consumer can retrieve this job.
85
144
  # @param [Hash] opts the optional parameters
86
- # @option opts [Integer] :n Number of jobs to return.
145
+ # @option opts [Integer] :n Number of jobs to return. (default to 1)
87
146
  # @return [JobsWrapper]
88
- def jobs_get(opts = {})
89
- data, status_code, headers = jobs_get_with_http_info(opts)
147
+ def jobs_consume_get(opts = {})
148
+ data, status_code, headers = jobs_consume_get_with_http_info(opts)
90
149
  return data
91
150
  end
92
151
 
93
152
  # Get next job.
94
- # Gets the next job in the queue, ready for processing.
153
+ # Gets the next job in the queue, ready for processing. Titan may return &lt;=n jobs. Consumers should start processing jobs in order. Each returned job is set to `status` \&quot;running\&quot; and `started_at` is set to the current time. No other consumer can retrieve this job.
95
154
  # @param [Hash] opts the optional parameters
96
155
  # @option opts [Integer] :n Number of jobs to return.
97
156
  # @return [Array<(JobsWrapper, Fixnum, Hash)>] JobsWrapper data, response status code and response headers
98
- def jobs_get_with_http_info(opts = {})
157
+ def jobs_consume_get_with_http_info(opts = {})
99
158
  if @api_client.config.debugging
100
- @api_client.config.logger.debug "Calling API: CoreApi#jobs_get ..."
159
+ @api_client.config.logger.debug "Calling API: CoreApi#jobs_consume_get ..."
101
160
  end
102
161
 
103
162
  # resource path
104
- local_var_path = "/jobs".sub('{format}','json')
163
+ local_var_path = "/jobs/consume".sub('{format}','json')
105
164
 
106
165
  # query parameters
107
166
  query_params = {}
@@ -133,13 +192,13 @@ module IronTitan
133
192
  :auth_names => auth_names,
134
193
  :return_type => 'JobsWrapper')
135
194
  if @api_client.config.debugging
136
- @api_client.config.logger.debug "API called: CoreApi#jobs_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
195
+ @api_client.config.logger.debug "API called: CoreApi#jobs_consume_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
137
196
  end
138
197
  return data, status_code, headers
139
198
  end
140
199
 
141
200
  # Enqueue Job
142
- # Enqueues a job.
201
+ # Enqueues job(s). If any of the jobs is invalid, none of the jobs are enqueued.
143
202
  # @param body Array of jobs to post.
144
203
  # @param [Hash] opts the optional parameters
145
204
  # @return [JobsWrapper]
@@ -149,7 +208,7 @@ module IronTitan
149
208
  end
150
209
 
151
210
  # Enqueue Job
152
- # Enqueues a job.
211
+ # Enqueues job(s). If any of the jobs is invalid, none of the jobs are enqueued.
153
212
  # @param body Array of jobs to post.
154
213
  # @param [Hash] opts the optional parameters
155
214
  # @return [Array<(JobsWrapper, Fixnum, Hash)>] JobsWrapper data, response status code and response headers
@@ -3,7 +3,7 @@ Titan API
3
3
 
4
4
  The ultimate, language agnostic, container based job processing framework.
5
5
 
6
- OpenAPI spec version: 0.1.1
6
+ OpenAPI spec version: 0.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
9
 
@@ -20,26 +20,31 @@ module IronTitan
20
20
  @api_client = api_client
21
21
  end
22
22
 
23
- # Get all image names.
24
- # TODO: Using images for lack of a better term. See https://github.com/iron-io/titan/issues/43 for discussion.
23
+ # Get information for image id.
24
+ # This gives more details about on image, such as the image name and other statistics.
25
+ # @param id ID of the image.
25
26
  # @param [Hash] opts the optional parameters
26
- # @return [ImagesWrapper]
27
- def images_get(opts = {})
28
- data, status_code, headers = images_get_with_http_info(opts)
27
+ # @return [ImageWrapper]
28
+ def image_id_get(id, opts = {})
29
+ data, status_code, headers = image_id_get_with_http_info(id, opts)
29
30
  return data
30
31
  end
31
32
 
32
- # Get all image names.
33
- # TODO: Using images for lack of a better term. See https://github.com/iron-io/titan/issues/43 for discussion.
33
+ # Get information for image id.
34
+ # This gives more details about on image, such as the image name and other statistics.
35
+ # @param id ID of the image.
34
36
  # @param [Hash] opts the optional parameters
35
- # @return [Array<(ImagesWrapper, Fixnum, Hash)>] ImagesWrapper data, response status code and response headers
36
- def images_get_with_http_info(opts = {})
37
+ # @return [Array<(ImageWrapper, Fixnum, Hash)>] ImageWrapper data, response status code and response headers
38
+ def image_id_get_with_http_info(id, opts = {})
37
39
  if @api_client.config.debugging
38
- @api_client.config.logger.debug "Calling API: ImagesApi#images_get ..."
40
+ @api_client.config.logger.debug "Calling API: ImagesApi#image_id_get ..."
39
41
  end
40
42
 
43
+ # verify the required parameter 'id' is set
44
+ fail "Missing the required parameter 'id' when calling image_id_get" if id.nil?
45
+
41
46
  # resource path
42
- local_var_path = "/images".sub('{format}','json')
47
+ local_var_path = "/image/{id}".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)
43
48
 
44
49
  # query parameters
45
50
  query_params = {}
@@ -68,38 +73,33 @@ module IronTitan
68
73
  :form_params => form_params,
69
74
  :body => post_body,
70
75
  :auth_names => auth_names,
71
- :return_type => 'ImagesWrapper')
76
+ :return_type => 'ImageWrapper')
72
77
  if @api_client.config.debugging
73
- @api_client.config.logger.debug "API called: ImagesApi#images_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
78
+ @api_client.config.logger.debug "API called: ImagesApi#image_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
74
79
  end
75
80
  return data, status_code, headers
76
81
  end
77
82
 
78
- # Get image by name.
79
- # NOT IMPLEMENTED YET. This gives more details about on image, such as statistics and what not.
80
- # @param name Name of the image.
83
+ # Get all image names.
84
+ # TODO: Using images for lack of a better term. See https://github.com/iron-io/titan/issues/43 for discussion.
81
85
  # @param [Hash] opts the optional parameters
82
- # @return [ImageWrapper]
83
- def images_name_get(name, opts = {})
84
- data, status_code, headers = images_name_get_with_http_info(name, opts)
86
+ # @return [ImagesWrapper]
87
+ def images_get(opts = {})
88
+ data, status_code, headers = images_get_with_http_info(opts)
85
89
  return data
86
90
  end
87
91
 
88
- # Get image by name.
89
- # NOT IMPLEMENTED YET. This gives more details about on image, such as statistics and what not.
90
- # @param name Name of the image.
92
+ # Get all image names.
93
+ # TODO: Using images for lack of a better term. See https://github.com/iron-io/titan/issues/43 for discussion.
91
94
  # @param [Hash] opts the optional parameters
92
- # @return [Array<(ImageWrapper, Fixnum, Hash)>] ImageWrapper data, response status code and response headers
93
- def images_name_get_with_http_info(name, opts = {})
95
+ # @return [Array<(ImagesWrapper, Fixnum, Hash)>] ImagesWrapper data, response status code and response headers
96
+ def images_get_with_http_info(opts = {})
94
97
  if @api_client.config.debugging
95
- @api_client.config.logger.debug "Calling API: ImagesApi#images_name_get ..."
98
+ @api_client.config.logger.debug "Calling API: ImagesApi#images_get ..."
96
99
  end
97
100
 
98
- # verify the required parameter 'name' is set
99
- fail "Missing the required parameter 'name' when calling images_name_get" if name.nil?
100
-
101
101
  # resource path
102
- local_var_path = "/images/{name}".sub('{format}','json').sub('{' + 'name' + '}', name.to_s)
102
+ local_var_path = "/images".sub('{format}','json')
103
103
 
104
104
  # query parameters
105
105
  query_params = {}
@@ -128,9 +128,9 @@ module IronTitan
128
128
  :form_params => form_params,
129
129
  :body => post_body,
130
130
  :auth_names => auth_names,
131
- :return_type => 'ImageWrapper')
131
+ :return_type => 'ImagesWrapper')
132
132
  if @api_client.config.debugging
133
- @api_client.config.logger.debug "API called: ImagesApi#images_name_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
133
+ @api_client.config.logger.debug "API called: ImagesApi#images_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
134
134
  end
135
135
  return data, status_code, headers
136
136
  end