nexosis_api 1.1.2 → 1.2.0
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 +4 -4
- data/lib/nexosis_api.rb +11 -11
- data/lib/nexosis_api/algorithm.rb +18 -18
- data/lib/nexosis_api/algorithm_run.rb +32 -32
- data/lib/nexosis_api/algorithm_selection.rb +34 -34
- data/lib/nexosis_api/client.rb +98 -72
- data/lib/nexosis_api/client/datasets.rb +157 -162
- data/lib/nexosis_api/client/imports.rb +74 -75
- data/lib/nexosis_api/client/sessions.rb +213 -213
- data/lib/nexosis_api/client/views.rb +109 -0
- data/lib/nexosis_api/column.rb +49 -0
- data/lib/nexosis_api/column_options.rb +33 -0
- data/lib/nexosis_api/column_role.rb +15 -12
- data/lib/nexosis_api/column_type.rb +19 -15
- data/lib/nexosis_api/dataset_data.rb +24 -24
- data/lib/nexosis_api/dataset_model.rb +26 -26
- data/lib/nexosis_api/dataset_summary.rb +27 -27
- data/lib/nexosis_api/http_exception.rb +28 -24
- data/lib/nexosis_api/impact_metric.rb +22 -22
- data/lib/nexosis_api/imports_response.rb +66 -66
- data/lib/nexosis_api/join.rb +58 -0
- data/lib/nexosis_api/link.rb +18 -18
- data/lib/nexosis_api/metric.rb +21 -21
- data/lib/nexosis_api/session.rb +88 -80
- data/lib/nexosis_api/session_response.rb +26 -26
- data/lib/nexosis_api/session_result.rb +23 -23
- data/lib/nexosis_api/time_interval.rb +15 -15
- data/lib/nexosis_api/view_data.rb +13 -0
- data/lib/nexosis_api/view_definition.rb +51 -0
- data/nexosisapi.gemspec +20 -20
- metadata +10 -5
- data/lib/nexosis_api/dataset_column.rb +0 -47
@@ -1,75 +1,74 @@
|
|
1
|
-
require 'json'
|
2
|
-
module NexosisApi
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
1
|
+
require 'json'
|
2
|
+
module NexosisApi
|
3
|
+
class Client
|
4
|
+
# Imports-based API operations
|
5
|
+
#
|
6
|
+
# @see http://docs.nexosis.com/
|
7
|
+
module Imports
|
8
|
+
|
9
|
+
# List all existing import requests
|
10
|
+
#
|
11
|
+
# @return [Array of NexosisApi::ImportsResponse]
|
12
|
+
def list_imports
|
13
|
+
imports_url = "/imports"
|
14
|
+
response = self.class.get(imports_url, :headers => @headers)
|
15
|
+
if(response.success?)
|
16
|
+
items = []
|
17
|
+
response.parsed_response["items"].each do |i|
|
18
|
+
items << NexosisApi::ImportsResponse.new(i)
|
19
|
+
end
|
20
|
+
items
|
21
|
+
else
|
22
|
+
raise HttpException.new("There was a problem getting the imports: #{response.code}.", "uploading dataset from s3 #{dataset_name}" ,response)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Import a file from AWS s3 as your dataset
|
27
|
+
#
|
28
|
+
# @param dataset_name [String] the name to give to the new dataset or existing dataset to which this data will be upserted
|
29
|
+
# @param bucket_name [String] the AWS S3 bucket name in which the path will be found
|
30
|
+
# @param path [String] the path within the bucket (usually file name)
|
31
|
+
# @param region [String] the region in which your bucket exists. Defaults to us-east-1
|
32
|
+
# @param column_metadata [Array of NexosisApi::Column] description of each column in target dataset. Optional.
|
33
|
+
# @return [NexosisApi::ImportsResponse]
|
34
|
+
# @see http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region for information on region names
|
35
|
+
def import_from_s3(dataset_name, bucket_name, path, region = "us-east-1", column_metadata = [])
|
36
|
+
raise ArgumentError "dataset_name was not provided and is not optional " unless dataset_name.to_s.empty? == false
|
37
|
+
raise ArgumentError "bucket_name was not provided and is not optional " unless bucket_name.to_s.empty? == false
|
38
|
+
raise ArgumentError "path was not provided and is not optional " unless path.to_s.empty? == false
|
39
|
+
s3_import_url = "/imports/s3"
|
40
|
+
column_json = Column.to_json(column_metadata)
|
41
|
+
body = {
|
42
|
+
"dataSetName" => dataset_name,
|
43
|
+
"bucket" => bucket_name,
|
44
|
+
"path" => path,
|
45
|
+
"region" => region,
|
46
|
+
"columns" => column_json
|
47
|
+
}
|
48
|
+
response = self.class.post(s3_import_url, :headers => @headers, :body => body.to_json)
|
49
|
+
if(response.success?)
|
50
|
+
NexosisApi::ImportsResponse.new(response.parsed_response)
|
51
|
+
else
|
52
|
+
raise HttpException.new("There was a problem importing from s3: #{response.code}.", "uploading dataset from s3 #{dataset_name}" ,response)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Get s3 response back from import created previously. Presumably to check status.
|
57
|
+
#
|
58
|
+
# @param import_id [String] The id returned from a previous request to import
|
59
|
+
# @return [NexosisApi::ImportsResponse]
|
60
|
+
# @example get S3 import
|
61
|
+
# NexosisApi.client.retrieve_import('740dca2a-b488-4322-887e-fa473b1caa54')
|
62
|
+
def retrieve_import(import_id)
|
63
|
+
raise ArgumentError "import_id was not provided and is not optional " unless import_id.to_s.empty? == false
|
64
|
+
imports_url = "/imports/#{import_id}"
|
65
|
+
response = self.class.get(imports_url, :headers => @headers)
|
66
|
+
if(response.success?)
|
67
|
+
NexosisApi::ImportsResponse.new(response.parsed_response)
|
68
|
+
else
|
69
|
+
raise HttpException.new("There was a problem getting the import #{response.code}.", "requesting an import #{import_id}" ,response)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -1,213 +1,213 @@
|
|
1
|
-
require 'csv'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module NexosisApi
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
end
|
1
|
+
require 'csv'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module NexosisApi
|
5
|
+
class Client
|
6
|
+
# Session-based API operations
|
7
|
+
#
|
8
|
+
# @see http://docs.nexosis.com/
|
9
|
+
module Sessions
|
10
|
+
|
11
|
+
# List sessions previously submitted
|
12
|
+
#
|
13
|
+
# @param query_options [Hash] optionally provide query parameters to limit the search of sessions.
|
14
|
+
# @param page [Integer] optionally provide a page number for paging. Defaults to 0 (first page).
|
15
|
+
# @param pageSize [Integer] optionally provide a page size to limit the total number of results. Defaults to 50, max 1000
|
16
|
+
# @return [Array of NexosisApi::SessionResponse] with all sessions matching the query or all if no query
|
17
|
+
# @note query parameters hash members are dataset_name, event_name, requested_before_date, and requested_after_date.
|
18
|
+
# After and before dates refer to the session requested date.
|
19
|
+
# @example query for just one dataset
|
20
|
+
# sessions = NexosisApi.client.list_sessions :dataset_name => 'MyDataset'
|
21
|
+
def list_sessions(query_options = {}, page = 0, pageSize = 50)
|
22
|
+
sessions_url = '/sessions'
|
23
|
+
query = {
|
24
|
+
'dataSetName' => query_options[:dataset_name],
|
25
|
+
'eventName' => query_options[:event_name],
|
26
|
+
'requestedAfterDate' => query_options[:requested_after_date],
|
27
|
+
'requestedBeforeDate' => query_options[:requested_before_date],
|
28
|
+
'type' => query_options[:type],
|
29
|
+
'page' => page,
|
30
|
+
'pageSize' => pageSize
|
31
|
+
}
|
32
|
+
response = self.class.get(sessions_url, :headers => @headers, :query => query)
|
33
|
+
if(response.success?)
|
34
|
+
all_responses = []
|
35
|
+
response.parsed_response['items'].each do |session_hash|
|
36
|
+
response_hash = { 'session' => session_hash }.merge(response.headers)
|
37
|
+
all_responses << NexosisApi::SessionResponse.new(response_hash)
|
38
|
+
end
|
39
|
+
all_responses
|
40
|
+
else
|
41
|
+
raise HttpException.new('Could not retrieve sessions',"Get all sessions with query #{query_options.to_s}",response)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Remove a session
|
46
|
+
# @param session_id [String] required session identifier
|
47
|
+
def remove_session(session_id)
|
48
|
+
if(session_id.to_s.empty?)
|
49
|
+
raise ArgumentError 'session_id cannot be empty or nil'
|
50
|
+
end
|
51
|
+
session_url = "/sessions/#{session_id}"
|
52
|
+
response = self.class.delete(session_url, headers: @headers)
|
53
|
+
if(response.success?)
|
54
|
+
return
|
55
|
+
else
|
56
|
+
raise HttpException.new('Could not delete session with given id', "remove session with id #{session_id.to_s}",response)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Remove sessions that have been run. All query options are optional and will be used to limit the sessions removed.
|
61
|
+
# @param query_options [Hash] optionally provide query parametes to limit the set of sessions removed.
|
62
|
+
# @note query parameters hash members are type, dataset_name, event_name, start_date, and end_date.
|
63
|
+
# Start and end dates refer to the session requested date.
|
64
|
+
# Results are not removed but then can only be accessed by dataset name
|
65
|
+
# @example Remove all sessions based on a dataset by name
|
66
|
+
# NexosisApi.client.remove_sessions :dataset_name => 'existing_dataset'
|
67
|
+
def remove_sessions(query_options = {})
|
68
|
+
sessions_url = '/sessions'
|
69
|
+
response = self.class.delete(sessions_url, :headers => @headers, :query => get_query_from_options(query_options))
|
70
|
+
if(response.success?)
|
71
|
+
return
|
72
|
+
else
|
73
|
+
raise HttpException.new('Could not remove sessions', "Remove sessions with query #{query_options.to_s}",response)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Initiate a new forecast session based on a named dataset.
|
78
|
+
#
|
79
|
+
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
80
|
+
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 string.
|
81
|
+
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 string.
|
82
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
83
|
+
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
84
|
+
# @param column_metadata [Array of NexosisApi::Column] (optional) - specification for how to handle columns if different from existing metadata on dataset
|
85
|
+
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
86
|
+
# @note The time interval selected must be greater than or equal to the finest granularity of the data provided.
|
87
|
+
# For instance if your data includes many recoreds per hour, then you could request hour, day, or any other result interval.
|
88
|
+
# However, if your data includes only a few records per day or fewer, then a request for an hourly result interval will produce poor results.
|
89
|
+
def create_forecast_session(dataset_name, start_date, end_date, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY, column_metadata = nil)
|
90
|
+
create_session(dataset_name, start_date, end_date, target_column, false, nil, 'forecast', result_interval, column_metadata)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Estimate the cost of a forecast from data already saved to the API.
|
94
|
+
#
|
95
|
+
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
96
|
+
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 string.
|
97
|
+
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 string.
|
98
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
99
|
+
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
100
|
+
# @return [NexosisApi::SessionResponse] providing information about the sesssion, including the cost
|
101
|
+
def estimate_forecast_session(dataset_name, start_date, end_date, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
102
|
+
create_session(dataset_name, start_date, end_date, target_column, true, nil, 'forecast', result_interval)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Analyze impact for an event with data already saved to the API.
|
106
|
+
#
|
107
|
+
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
108
|
+
# @param start_date [DateTime] The starting date of the impactful event. Can be ISO 8601 string.
|
109
|
+
# @param end_date [DateTime] The ending date of the impactful event. Can be ISO 8601 string.
|
110
|
+
# @param event_name [String] The name of the event.
|
111
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in datatset.
|
112
|
+
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
113
|
+
# @param column_metadata [Array of NexosisApi::Column] (optional) - specification for how to handle columns if different from existing metadata on dataset
|
114
|
+
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
115
|
+
def create_impact_session(dataset_name, start_date, end_date, event_name, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY, column_metadata = nil)
|
116
|
+
create_session(dataset_name, start_date, end_date, target_column, false, event_name, 'impact', result_interval, column_metadata)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Estimate the cost of impact analysis for an event with data already saved to the API.
|
120
|
+
#
|
121
|
+
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
122
|
+
# @param start_date [DateTime] The starting date of the impactful event. Can be ISO 8601 string.
|
123
|
+
# @param end_date [DateTime] The ending date of the impactful event. Can be ISO 8601 string.
|
124
|
+
# @param event_name [String] The name of the event.
|
125
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
126
|
+
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
127
|
+
# @return [NexosisApi::SessionResponse] providing information about the sesssion, including the cost
|
128
|
+
def estimate_impact_session(dataset_name, start_date, end_date, event_name, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
129
|
+
create_session(dataset_name, start_date, end_date, target_column, true, event_name, 'impact', result_interval)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Get the results of the session.
|
133
|
+
#
|
134
|
+
# @param session_id [String] the Guid string returned in a previous session request
|
135
|
+
# @param as_csv [Boolean] indicate whether results should be returned in csv format
|
136
|
+
# @return [NexosisApi::SessionResult] SessionResult if parsed, String of csv data otherwise
|
137
|
+
def get_session_results(session_id, as_csv = false)
|
138
|
+
session_result_url = "/sessions/#{session_id}/results"
|
139
|
+
if as_csv
|
140
|
+
@headers["Accept"] = 'text/csv'
|
141
|
+
end
|
142
|
+
response = self.class.get(session_result_url, @options)
|
143
|
+
@headers.delete('Accept')
|
144
|
+
|
145
|
+
if(response.success?)
|
146
|
+
if(as_csv)
|
147
|
+
response.body
|
148
|
+
else
|
149
|
+
NexosisApi::SessionResult.new(response.parsed_response)
|
150
|
+
end
|
151
|
+
else
|
152
|
+
raise HttpException.new("There was a problem getting the session: #{response.code}.", "get results for session #{session_id}" ,response)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Get a specific session by id.
|
157
|
+
#
|
158
|
+
# @param session_id [String] the Guid string returned in a previous session request
|
159
|
+
# @return [NexosisApi::Session] a Session object populated with the session's data
|
160
|
+
def get_session(session_id)
|
161
|
+
session_url = "/sessions/#{session_id}"
|
162
|
+
response = self.class.get(session_url, @options)
|
163
|
+
if(response.success?)
|
164
|
+
NexosisApi::Session.new(response.parsed_response)
|
165
|
+
else
|
166
|
+
raise HttpException.new("There was a problem getting the session: #{response.code}.", "getting session #{session_id}" ,response)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
private
|
171
|
+
def create_session(dataset_name, start_date, end_date, target_column = nil, is_estimate=false, event_name = nil, type = "forecast", result_interval = NexosisApi::TimeInterval::DAY, column_metadata = nil)
|
172
|
+
session_url = "/sessions/#{type}"
|
173
|
+
query = {
|
174
|
+
'targetColumn' => target_column.to_s,
|
175
|
+
'startDate' => start_date.to_s,
|
176
|
+
'endDate' => end_date.to_s,
|
177
|
+
'isestimate' => is_estimate.to_s,
|
178
|
+
'resultInterval' => result_interval.to_s
|
179
|
+
}
|
180
|
+
query['dataSetName'] = dataset_name.to_s unless dataset_name.to_s.empty?
|
181
|
+
if(event_name.nil? == false)
|
182
|
+
query['eventName'] = event_name
|
183
|
+
end
|
184
|
+
body = ''
|
185
|
+
if(column_metadata.nil? == false)
|
186
|
+
column_json = Column.to_json(column_metadata)
|
187
|
+
body = {
|
188
|
+
'dataSetName' => dataset_name,
|
189
|
+
'columns' => column_json
|
190
|
+
}
|
191
|
+
end
|
192
|
+
response = self.class.post(session_url, :headers => @headers, :query => query, :body => body.to_json)
|
193
|
+
if(response.success?)
|
194
|
+
session_hash = {'session' => response.parsed_response}.merge(response.headers)
|
195
|
+
NexosisApi::SessionResponse.new(session_hash)
|
196
|
+
else
|
197
|
+
raise HttpException.new("Unable to create new #{type} session", "Create session for dataset #{dataset_name}",response)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def get_query_from_options(options)
|
202
|
+
query = {
|
203
|
+
'dataSetName' => options[:dataset_name],
|
204
|
+
'eventName' => options[:event_name],
|
205
|
+
'startDate' => options[:start_date],
|
206
|
+
'endDate' => options[:end_date],
|
207
|
+
'type' => options[:type]
|
208
|
+
}
|
209
|
+
query
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|