batchly_api 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,196 @@
1
+ # This file was automatically generated for support.batchly.net by APIMATIC BETA v2.0 on 11/18/2015
2
+
3
+ module BatchlyApi
4
+ class ProjectController
5
+
6
+ # TODO: type endpoint description here
7
+ # @return Array<ProjectModel> response from the API call
8
+ def list_projects
9
+ # the base uri for api requests
10
+ query_builder = Configuration.BASE_URI.dup
11
+
12
+ # prepare query string for API call
13
+ query_builder << "/Project"
14
+
15
+ # validate and preprocess url
16
+ query_url = APIHelper.clean_url query_builder
17
+
18
+ # prepare headers
19
+ headers = {
20
+ "user-agent" => "batchly/0.5.1",
21
+ "accept" => "application/json"
22
+ }
23
+
24
+ # append custom auth authorization
25
+ CustomAuthUtility.append_custom_auth_params query_url, "GET", headers
26
+
27
+ # invoke the API call request to fetch the response
28
+ response = Unirest.get query_url, headers:headers
29
+
30
+ #Error handling using HTTP status codes
31
+ if !(response.code.between?(200,206)) # [200,206] = HTTP OK
32
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
33
+ end
34
+
35
+ response.body
36
+ end
37
+
38
+ # TODO: type endpoint description here
39
+ # @param [CreateProjectRequest] request Required parameter: TODO: type description here
40
+ # @return ProjectModel response from the API call
41
+ def add_project request
42
+ # the base uri for api requests
43
+ query_builder = Configuration.BASE_URI.dup
44
+
45
+ # prepare query string for API call
46
+ query_builder << "/Project"
47
+
48
+ # validate and preprocess url
49
+ query_url = APIHelper.clean_url query_builder
50
+
51
+ # prepare headers
52
+ headers = {
53
+ "user-agent" => "batchly/0.5.1",
54
+ "accept" => "application/json",
55
+ "content-type" => "application/json; charset=utf-8"
56
+ }
57
+
58
+ # append custom auth authorization
59
+ CustomAuthUtility.append_custom_auth_params query_url, "POST", headers
60
+
61
+ # invoke the API call request to fetch the response
62
+ response = Unirest.post query_url, headers:headers, parameters:request.to_json
63
+
64
+ # Error handling using HTTP status codes
65
+ if response.code == 400
66
+ raise APIException.new "BadRequest", 400, response.raw_body
67
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
68
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
69
+ end
70
+
71
+ response.body
72
+ end
73
+
74
+ # TODO: type endpoint description here
75
+ # @param [String] id Required parameter: TODO: type description here
76
+ # @return ProjectModel response from the API call
77
+ def describe_project id
78
+ # the base uri for api requests
79
+ query_builder = Configuration.BASE_URI.dup
80
+
81
+ # prepare query string for API call
82
+ query_builder << "/Project/{id}"
83
+
84
+ # process optional query parameters
85
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
86
+ "id" => id,
87
+ }
88
+
89
+ # validate and preprocess url
90
+ query_url = APIHelper.clean_url query_builder
91
+
92
+ # prepare headers
93
+ headers = {
94
+ "user-agent" => "batchly/0.5.1",
95
+ "accept" => "application/json"
96
+ }
97
+
98
+ # append custom auth authorization
99
+ CustomAuthUtility.append_custom_auth_params query_url, "GET", headers
100
+
101
+ # invoke the API call request to fetch the response
102
+ response = Unirest.get query_url, headers:headers
103
+
104
+ # Error handling using HTTP status codes
105
+ if response.code == 404
106
+ raise APIException.new "NotFound", 404, response.raw_body
107
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
108
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
109
+ end
110
+
111
+ response.body
112
+ end
113
+
114
+ # TODO: type endpoint description here
115
+ # @param [String] id Required parameter: TODO: type description here
116
+ # @param [UpdateProjectRequest] request Required parameter: TODO: type description here
117
+ # @return ProjectModel response from the API call
118
+ def update_project id, request
119
+ # the base uri for api requests
120
+ query_builder = Configuration.BASE_URI.dup
121
+
122
+ # prepare query string for API call
123
+ query_builder << "/Project/{id}"
124
+
125
+ # process optional query parameters
126
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
127
+ "id" => id,
128
+ }
129
+
130
+ # validate and preprocess url
131
+ query_url = APIHelper.clean_url query_builder
132
+
133
+ # prepare headers
134
+ headers = {
135
+ "user-agent" => "batchly/0.5.1",
136
+ "accept" => "application/json",
137
+ "content-type" => "application/json; charset=utf-8"
138
+ }
139
+
140
+ # append custom auth authorization
141
+ CustomAuthUtility.append_custom_auth_params query_url, "PUT", headers
142
+
143
+ # invoke the API call request to fetch the response
144
+ response = Unirest.put query_url, headers:headers, parameters:request.to_json
145
+
146
+ # Error handling using HTTP status codes
147
+ if response.code == 400
148
+ raise APIException.new "BadRequest", 400, response.raw_body
149
+ elsif response.code == 404
150
+ raise APIException.new "NotFound", 404, response.raw_body
151
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
152
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
153
+ end
154
+
155
+ response.body
156
+ end
157
+
158
+ # TODO: type endpoint description here
159
+ # @param [String] id Required parameter: TODO: type description here
160
+ # @return void response from the API call
161
+ def delete_project id
162
+ # the base uri for api requests
163
+ query_builder = Configuration.BASE_URI.dup
164
+
165
+ # prepare query string for API call
166
+ query_builder << "/Project/{id}"
167
+
168
+ # process optional query parameters
169
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
170
+ "id" => id,
171
+ }
172
+
173
+ # validate and preprocess url
174
+ query_url = APIHelper.clean_url query_builder
175
+
176
+ # prepare headers
177
+ headers = {
178
+ "user-agent" => "batchly/0.5.1"
179
+ }
180
+
181
+ # append custom auth authorization
182
+ CustomAuthUtility.append_custom_auth_params query_url, "DELETE", headers
183
+
184
+ # invoke the API call request to fetch the response
185
+ response = Unirest.delete query_url, headers:headers
186
+
187
+ # Error handling using HTTP status codes
188
+ if response.code == 404
189
+ raise APIException.new "NotFound", 404, response.raw_body
190
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
191
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
192
+ end
193
+ end
194
+
195
+ end
196
+ end
@@ -0,0 +1,191 @@
1
+ # This file was automatically generated for support.batchly.net by APIMATIC BETA v2.0 on 11/18/2015
2
+
3
+ module BatchlyApi
4
+ class RunController
5
+
6
+ # TODO: type endpoint description here
7
+ # @return Array<RunModel> response from the API call
8
+ def list_runs
9
+ # the base uri for api requests
10
+ query_builder = Configuration.BASE_URI.dup
11
+
12
+ # prepare query string for API call
13
+ query_builder << "/Run"
14
+
15
+ # validate and preprocess url
16
+ query_url = APIHelper.clean_url query_builder
17
+
18
+ # prepare headers
19
+ headers = {
20
+ "user-agent" => "batchly/0.5.1",
21
+ "accept" => "application/json"
22
+ }
23
+
24
+ # append custom auth authorization
25
+ CustomAuthUtility.append_custom_auth_params query_url, "GET", headers
26
+
27
+ # invoke the API call request to fetch the response
28
+ response = Unirest.get query_url, headers:headers
29
+
30
+ #Error handling using HTTP status codes
31
+ if !(response.code.between?(200,206)) # [200,206] = HTTP OK
32
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
33
+ end
34
+
35
+ response.body
36
+ end
37
+
38
+ # TODO: type endpoint description here
39
+ # @param [ExecuteJobRequest] request Required parameter: TODO: type description here
40
+ # @return RunModel response from the API call
41
+ def add_run request
42
+ # the base uri for api requests
43
+ query_builder = Configuration.BASE_URI.dup
44
+
45
+ # prepare query string for API call
46
+ query_builder << "/Run"
47
+
48
+ # validate and preprocess url
49
+ query_url = APIHelper.clean_url query_builder
50
+
51
+ # prepare headers
52
+ headers = {
53
+ "user-agent" => "batchly/0.5.1",
54
+ "accept" => "application/json",
55
+ "content-type" => "application/json; charset=utf-8"
56
+ }
57
+
58
+ # append custom auth authorization
59
+ CustomAuthUtility.append_custom_auth_params query_url, "POST", headers
60
+
61
+ # invoke the API call request to fetch the response
62
+ response = Unirest.post query_url, headers:headers, parameters:request.to_json
63
+
64
+ # Error handling using HTTP status codes
65
+ if response.code == 400
66
+ raise APIException.new "BadRequest", 400, response.raw_body
67
+ elsif response.code == 409
68
+ raise APIException.new "Conflict", 409, response.raw_body
69
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
70
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
71
+ end
72
+
73
+ response.body
74
+ end
75
+
76
+ # TODO: type endpoint description here
77
+ # @param [String] id Required parameter: TODO: type description here
78
+ # @return RunModel response from the API call
79
+ def describe_run id
80
+ # the base uri for api requests
81
+ query_builder = Configuration.BASE_URI.dup
82
+
83
+ # prepare query string for API call
84
+ query_builder << "/Run/{id}"
85
+
86
+ # process optional query parameters
87
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
88
+ "id" => id,
89
+ }
90
+
91
+ # validate and preprocess url
92
+ query_url = APIHelper.clean_url query_builder
93
+
94
+ # prepare headers
95
+ headers = {
96
+ "user-agent" => "batchly/0.5.1",
97
+ "accept" => "application/json"
98
+ }
99
+
100
+ # append custom auth authorization
101
+ CustomAuthUtility.append_custom_auth_params query_url, "GET", headers
102
+
103
+ # invoke the API call request to fetch the response
104
+ response = Unirest.get query_url, headers:headers
105
+
106
+ # Error handling using HTTP status codes
107
+ if response.code == 404
108
+ raise APIException.new "NotFound", 404, response.raw_body
109
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
110
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
111
+ end
112
+
113
+ response.body
114
+ end
115
+
116
+ # TODO: type endpoint description here
117
+ # @param [String] id Required parameter: TODO: type description here
118
+ # @return void response from the API call
119
+ def stop_run id
120
+ # the base uri for api requests
121
+ query_builder = Configuration.BASE_URI.dup
122
+
123
+ # prepare query string for API call
124
+ query_builder << "/Run/{id}"
125
+
126
+ # process optional query parameters
127
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
128
+ "id" => id,
129
+ }
130
+
131
+ # validate and preprocess url
132
+ query_url = APIHelper.clean_url query_builder
133
+
134
+ # prepare headers
135
+ headers = {
136
+ "user-agent" => "batchly/0.5.1"
137
+ }
138
+
139
+ # append custom auth authorization
140
+ CustomAuthUtility.append_custom_auth_params query_url, "PUT", headers
141
+
142
+ # invoke the API call request to fetch the response
143
+ response = Unirest.put query_url, headers:headers
144
+
145
+ # Error handling using HTTP status codes
146
+ if response.code == 404
147
+ raise APIException.new "NotFound", 404, response.raw_body
148
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
149
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
150
+ end
151
+ end
152
+
153
+ # TODO: type endpoint description here
154
+ # @param [String] id Required parameter: TODO: type description here
155
+ # @return void response from the API call
156
+ def delete_run id
157
+ # the base uri for api requests
158
+ query_builder = Configuration.BASE_URI.dup
159
+
160
+ # prepare query string for API call
161
+ query_builder << "/Run/{id}"
162
+
163
+ # process optional query parameters
164
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
165
+ "id" => id,
166
+ }
167
+
168
+ # validate and preprocess url
169
+ query_url = APIHelper.clean_url query_builder
170
+
171
+ # prepare headers
172
+ headers = {
173
+ "user-agent" => "batchly/0.5.1"
174
+ }
175
+
176
+ # append custom auth authorization
177
+ CustomAuthUtility.append_custom_auth_params query_url, "DELETE", headers
178
+
179
+ # invoke the API call request to fetch the response
180
+ response = Unirest.delete query_url, headers:headers
181
+
182
+ # Error handling using HTTP status codes
183
+ if response.code == 404
184
+ raise APIException.new "NotFound", 404, response.raw_body
185
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
186
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
187
+ end
188
+ end
189
+
190
+ end
191
+ end
@@ -0,0 +1,62 @@
1
+ # This file was automatically generated for support.batchly.net by APIMATIC BETA v2.0 on 11/18/2015
2
+
3
+ module BatchlyApi
4
+ class CustomAuthUtility
5
+
6
+ HEADER_AUTHORIZATION = "Authorization"
7
+ HMAC_TEMPLATE = "Hmac %s"
8
+ HEADER_NONCE = "Nonce"
9
+ HEADER_TIMESTAMP = "Timestamp"
10
+ HEADER_API_KEY = "Api-Key"
11
+
12
+ def self.percent_encode( string )
13
+ URI.escape( string, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]") ).gsub('*', '%2A')
14
+ end
15
+
16
+ def self.query_string(params)
17
+ pairs = []
18
+ params.sort.each { | key, val |
19
+ pairs.push( "#{ percent_encode( key ) }=#{ percent_encode( val.to_s ) }" )
20
+ }
21
+ pairs.join '&'
22
+ end
23
+
24
+ # Appends the necessary OAuth credentials for making this authorized call
25
+ # @param [Hash] The out going request to access the resource
26
+ def self.append_custom_auth_params(parsed_url, method, headers)
27
+ apiKey = Configuration.API_KEY.dup
28
+ apiSecret = Configuration.API_SECRET.dup
29
+
30
+ req_url = parsed_url.scheme + '://' + parsed_url.host + parsed_url.path
31
+ hmacHeaders = {
32
+ HEADER_NONCE => Array.new( 5 ) { rand(256) }.pack('C*').unpack('H*').first,
33
+ HEADER_TIMESTAMP => Time.now.to_i,
34
+ HEADER_API_KEY =>apiKey
35
+ }
36
+
37
+ params = hmacHeaders
38
+ method = method.upcase
39
+
40
+ if parsed_url.query
41
+ params.merge! CGI.parse( parsed_url.query )
42
+ end
43
+
44
+ base_str = [
45
+ method.upcase,
46
+ percent_encode( req_url ),
47
+ percent_encode(query_string(params))
48
+ ].join( "&" )
49
+
50
+ key = percent_encode( apiSecret )
51
+
52
+ digest = OpenSSL::Digest::Digest.new( 'sha1' )
53
+ hmac = OpenSSL::HMAC.digest( digest, key, base_str )
54
+
55
+ headers["Authorization"] = HMAC_TEMPLATE % [ percent_encode( Base64.encode64( hmac ).chomp.gsub( /\n/, '' ) ) ]
56
+ headers[HEADER_NONCE] = hmacHeaders[HEADER_NONCE]
57
+ headers[HEADER_TIMESTAMP] = hmacHeaders[HEADER_TIMESTAMP]
58
+ headers[HEADER_API_KEY] = hmacHeaders[HEADER_API_KEY]
59
+ end
60
+
61
+ end
62
+ end