batchly_api 0.5.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d08dfe84b746f0abd7eb08f51cb0291e3a8ce4c8
4
+ data.tar.gz: fa67cd56b55a42895a6c8de0cac601f505ec73e0
5
+ SHA512:
6
+ metadata.gz: 5df14041efbe3416f277f01a56e740f513ef0625c06f78db2c7c7036922676b0f47fa18fec80047f1734a7edf1fb52b903ebfaafa2e81e0fcbc70a071ec6eeb3
7
+ data.tar.gz: 303a3eea99259aa0f7eb9b1921c89bb939fadfe31ff2bbdb90984fa03251f42b3ec0e6bf95cb0e59142ae700e2b515ca0d179e7b2e176c2062183725a20464b7
@@ -0,0 +1,30 @@
1
+ # This file was automatically generated for support.batchly.net by APIMATIC BETA v2.0 on 11/18/2015
2
+ require 'openssl'
3
+ require 'json'
4
+ require 'unirest'
5
+ require 'uri'
6
+ require 'cgi'
7
+ require 'base64'
8
+
9
+ # APIMATIC Helper Files
10
+ require 'batchly_api/api_helper.rb'
11
+ require 'batchly_api/api_exception.rb'
12
+ require 'batchly_api/configuration.rb'
13
+ require 'batchly_api/custom_auth_utility.rb'
14
+
15
+ # Controllers
16
+ require 'batchly_api/controllers/account_controller.rb'
17
+ require 'batchly_api/controllers/data_source_controller.rb'
18
+ require 'batchly_api/controllers/job_controller.rb'
19
+ require 'batchly_api/controllers/project_controller.rb'
20
+ require 'batchly_api/controllers/run_controller.rb'
21
+
22
+ # Models
23
+ require 'batchly_api/models/execute_job_request.rb'
24
+ require 'batchly_api/models/add_aws_account_request.rb'
25
+ require 'batchly_api/models/add_s_3_data_source_request.rb'
26
+ require 'batchly_api/models/create_job_request.rb'
27
+ require 'batchly_api/models/job_schedule.rb'
28
+ require 'batchly_api/models/create_project_request.rb'
29
+ require 'batchly_api/models/vpc_details.rb'
30
+ require 'batchly_api/models/update_project_request.rb'
@@ -0,0 +1,23 @@
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 APIException < StandardError
5
+
6
+ # value store
7
+ attr_reader :response_code
8
+
9
+ # value store
10
+ attr_reader :response_body
11
+
12
+ # The HTTP response code from the API request
13
+ # @param [String] the reason for raising an exception
14
+ # @param [Numeric] the HTTP response code from the API request
15
+ # @param [Object] the HTTP unprased response from the API request
16
+ def initialize(reason, response_code, response_body)
17
+ super(reason)
18
+ @response_code = response_code
19
+ @response_body = response_body
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,82 @@
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 APIHelper
5
+
6
+ # Replaces template parameters in the given url
7
+ # @param [String] The query string builder to replace the template parameters
8
+ # @param [Array] The parameters to replace in the url
9
+ def self.append_url_with_template_parameters(query_builder, parameters)
10
+ # perform parameter validation
11
+ raise ArgumentError, 'Given value for parameter \"query_builder\" is invalid.' unless query_builder.is_a? String
12
+
13
+ # return if there are no parameters to replace
14
+ if parameters.nil? then
15
+ abort('no parameters to append')
16
+ end
17
+
18
+ # iterate and append parameters
19
+ parameters.map do |key, value|
20
+ replace_value = ''
21
+
22
+ if value.nil?
23
+ replace_value = ''
24
+ elsif value.is_a? Enumerable
25
+ replace_value = value.join("/")
26
+ else
27
+ replace_value = value.to_s
28
+ end
29
+
30
+ # find the template parameter and replace it with its value
31
+ query_builder = query_builder.gsub('{' + key.to_s + '}', replace_value)
32
+ end
33
+
34
+ query_builder
35
+ end
36
+
37
+ # Appends the given set of parameters to the given query string
38
+ # @param [String] The query string builder to replace the template parameters
39
+ # @param [Array] The parameters to append
40
+ def self.append_url_with_query_parameters(query_builder, parameters)
41
+ # perform parameter validation
42
+ raise ArgumentError, 'Given value for parameter \"query_builder\" is invalid.' unless query_builder.is_a? String
43
+
44
+ # return if there are no parameters to replace
45
+ if parameters.nil? then
46
+ abort('no parameters to append')
47
+ end
48
+
49
+ #remove any nil values
50
+ parameters = parameters.reject {|key, value| value.nil?}
51
+
52
+ # does the query string already has parameters
53
+ has_params = query_builder.include? '?'
54
+ separator = if has_params then '&' else '?' end
55
+
56
+ # append query with separator and parameters
57
+ query_builder << separator << URI.unescape(URI.encode_www_form(parameters))
58
+ end
59
+
60
+ # Validates and processes the given Url
61
+ # @param [String] The given Url to process
62
+ # @return [String] Pre-processed Url as string
63
+ def self.clean_url(url)
64
+ # perform parameter validation
65
+ raise ArgumentError, 'Invalid Url.' unless url.is_a? String
66
+
67
+ # ensure that the urls are absolute
68
+ matches = url.match(/^(https?:\/\/[^\/]+)/)
69
+ raise ArgumentError, 'Invalid Url format.' if matches.nil?
70
+
71
+ # get the http protocol match
72
+ protocol = matches[1]
73
+
74
+ # remove redundant forward slashes
75
+ query = url[protocol.length..-1].gsub(/\/\/+/, '/')
76
+
77
+ # return process url
78
+ return protocol + query;
79
+ end
80
+
81
+ end
82
+ end
@@ -0,0 +1,21 @@
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 Configuration
5
+
6
+ # The base Uri for API calls
7
+ @BASE_URI = "http://api.corrs.batchly.net"
8
+
9
+ # The access key for batchly
10
+ @API_KEY = "UPDATE YOUR GENERATED API KEY HERE"
11
+
12
+ # The access key for batchly
13
+ @API_SECRET = "UPDATE YOUR GENERATED API SECRET HERE"
14
+
15
+ # create the getters and setters
16
+ class << self
17
+ attr_accessor :BASE_URI
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,150 @@
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 AccountController
5
+
6
+ # Lists all active projects in the given account identifier.
7
+ # @param [String] id Required parameter: TODO: type description here
8
+ # @return Array<ProjectModel> response from the API call
9
+ def list_projects id
10
+ # the base uri for api requests
11
+ query_builder = Configuration.BASE_URI.dup
12
+
13
+ # prepare query string for API call
14
+ query_builder << "/Account/{id}/Projects"
15
+
16
+ # process optional query parameters
17
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
18
+ "id" => id,
19
+ }
20
+
21
+ # validate and preprocess url
22
+ query_url = APIHelper.clean_url query_builder
23
+
24
+ # prepare headers
25
+ headers = {
26
+ "user-agent" => "batchly/0.5.1",
27
+ "accept" => "application/json"
28
+ }
29
+
30
+ # append custom auth authorization
31
+ CustomAuthUtility.append_custom_auth_params query_url, "GET", headers
32
+
33
+ # invoke the API call request to fetch the response
34
+ response = Unirest.get query_url, headers:headers
35
+
36
+ #Error handling using HTTP status codes
37
+ if !(response.code.between?(200,206)) # [200,206] = HTTP OK
38
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
39
+ end
40
+
41
+ response.body
42
+ end
43
+
44
+ # Add a new AWS account. The credentials should have IAMFullAccess Permissions. The keys are used to only create a new Batchly role in AWS IAM. The keys are not saved in batchly servers. Future calls are made using the newly created Batchly Role.
45
+ # @param [AddAWSAccountRequest] model Required parameter: TODO: type description here
46
+ # @return AccountModel response from the API call
47
+ def add_aws_cloud_account model
48
+ # the base uri for api requests
49
+ query_builder = Configuration.BASE_URI.dup
50
+
51
+ # prepare query string for API call
52
+ query_builder << "/Account/AWS"
53
+
54
+ # validate and preprocess url
55
+ query_url = APIHelper.clean_url query_builder
56
+
57
+ # prepare headers
58
+ headers = {
59
+ "user-agent" => "batchly/0.5.1",
60
+ "accept" => "application/json",
61
+ "content-type" => "application/json; charset=utf-8"
62
+ }
63
+
64
+ # append custom auth authorization
65
+ CustomAuthUtility.append_custom_auth_params query_url, "POST", headers
66
+
67
+ # invoke the API call request to fetch the response
68
+ response = Unirest.post query_url, headers:headers, parameters:model.to_json
69
+
70
+ # Error handling using HTTP status codes
71
+ if response.code == 400
72
+ raise APIException.new "BadRequest", 400, response.raw_body
73
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
74
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
75
+ end
76
+
77
+ response.body
78
+ end
79
+
80
+ # Deactivates the account and all associated jobs.
81
+ # @param [String] id Required parameter: TODO: type description here
82
+ # @return void response from the API call
83
+ def delete_account id
84
+ # the base uri for api requests
85
+ query_builder = Configuration.BASE_URI.dup
86
+
87
+ # prepare query string for API call
88
+ query_builder << "/Account/{id}"
89
+
90
+ # process optional query parameters
91
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
92
+ "id" => id,
93
+ }
94
+
95
+ # validate and preprocess url
96
+ query_url = APIHelper.clean_url query_builder
97
+
98
+ # prepare headers
99
+ headers = {
100
+ "user-agent" => "batchly/0.5.1"
101
+ }
102
+
103
+ # append custom auth authorization
104
+ CustomAuthUtility.append_custom_auth_params query_url, "DELETE", headers
105
+
106
+ # invoke the API call request to fetch the response
107
+ response = Unirest.delete query_url, headers:headers
108
+
109
+ # Error handling using HTTP status codes
110
+ if response.code == 404
111
+ raise APIException.new "NotFound", 404, response.raw_body
112
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
113
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
114
+ end
115
+ end
116
+
117
+ # Lists all active accounts associated with the batchly account
118
+ # @return Array<AccountModel> response from the API call
119
+ def list_accounts
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 << "/Account"
125
+
126
+ # validate and preprocess url
127
+ query_url = APIHelper.clean_url query_builder
128
+
129
+ # prepare headers
130
+ headers = {
131
+ "user-agent" => "batchly/0.5.1",
132
+ "accept" => "application/json"
133
+ }
134
+
135
+ # append custom auth authorization
136
+ CustomAuthUtility.append_custom_auth_params query_url, "GET", headers
137
+
138
+ # invoke the API call request to fetch the response
139
+ response = Unirest.get query_url, headers:headers
140
+
141
+ #Error handling using HTTP status codes
142
+ if !(response.code.between?(200,206)) # [200,206] = HTTP OK
143
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
144
+ end
145
+
146
+ response.body
147
+ end
148
+
149
+ end
150
+ end
@@ -0,0 +1,42 @@
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 DataSourceController
5
+
6
+ # Registers a new s3 endpoint with batchly. This endpoint can be used as either a source or destination for your job.
7
+ # @param [AddS3DataSourceRequest] model Required parameter: TODO: type description here
8
+ # @return String response from the API call
9
+ def add_s_3 model
10
+ # the base uri for api requests
11
+ query_builder = Configuration.BASE_URI.dup
12
+
13
+ # prepare query string for API call
14
+ query_builder << "/DataSource/S3"
15
+
16
+ # validate and preprocess url
17
+ query_url = APIHelper.clean_url query_builder
18
+
19
+ # prepare headers
20
+ headers = {
21
+ "user-agent" => "batchly/0.5.1",
22
+ "content-type" => "application/json; charset=utf-8"
23
+ }
24
+
25
+ # append custom auth authorization
26
+ CustomAuthUtility.append_custom_auth_params query_url, "POST", headers
27
+
28
+ # invoke the API call request to fetch the response
29
+ response = Unirest.post query_url, headers:headers, parameters:model.to_json
30
+
31
+ # Error handling using HTTP status codes
32
+ if response.code == 400
33
+ raise APIException.new "BadRequest", 400, response.raw_body
34
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
35
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
36
+ end
37
+
38
+ response.body
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,152 @@
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 JobController
5
+
6
+ # TODO: type endpoint description here
7
+ # @return Array<JobModel> response from the API call
8
+ def list_jobs
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 << "/Job"
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
+ # Adds a new job. Job can be created after registering source and destination as data sources and uploading new processor. Job brings your processors and data endpoints together.
39
+ # @param [CreateJobRequest] request Required parameter: TODO: type description here
40
+ # @return JobModel response from the API call
41
+ def add_job 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 << "/Job"
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 JobModel response from the API call
77
+ def describe_job 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 << "/Job/{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
+ # Deletes the jobs and removes all schedules
115
+ # @param [String] id Required parameter: TODO: type description here
116
+ # @return void response from the API call
117
+ def delete_job id
118
+ # the base uri for api requests
119
+ query_builder = Configuration.BASE_URI.dup
120
+
121
+ # prepare query string for API call
122
+ query_builder << "/Job/{id}"
123
+
124
+ # process optional query parameters
125
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
126
+ "id" => id,
127
+ }
128
+
129
+ # validate and preprocess url
130
+ query_url = APIHelper.clean_url query_builder
131
+
132
+ # prepare headers
133
+ headers = {
134
+ "user-agent" => "batchly/0.5.1"
135
+ }
136
+
137
+ # append custom auth authorization
138
+ CustomAuthUtility.append_custom_auth_params query_url, "DELETE", headers
139
+
140
+ # invoke the API call request to fetch the response
141
+ response = Unirest.delete query_url, headers:headers
142
+
143
+ # Error handling using HTTP status codes
144
+ if response.code == 404
145
+ raise APIException.new "NotFound", 404, response.raw_body
146
+ elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK
147
+ raise APIException.new "HTTP Response Not OK", response.code, response.raw_body
148
+ end
149
+ end
150
+
151
+ end
152
+ end