nexosis_api 2.4.1 → 3.0.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/client.rb +2 -0
- data/lib/nexosis_api/client/datasets.rb +7 -11
- data/lib/nexosis_api/client/imports.rb +3 -10
- data/lib/nexosis_api/client/models.rb +4 -14
- data/lib/nexosis_api/client/sessions.rb +8 -17
- data/lib/nexosis_api/list_queries.rb +198 -0
- data/lib/nexosis_api/sort_order.rb +11 -0
- data/nexosisapi.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab792a54e07188d8425d45c39c7b64f3862f009ec1f83c30531057411091a911
|
4
|
+
data.tar.gz: c252e1fdd7f2be4c0a1bc6bb91ce0b5cf2f75de33db70f7ecd48e3e62d0c17e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5955b865d93589337ef1ba7f4c4b132adbf2d1513216a1140d673187d49479573eb5021342666a0a653c93cbd8ac00bbbb28f52c8b6161bbfdd64606f7b169c
|
7
|
+
data.tar.gz: 5c569ddb22bf8d748dd3b53e72819e1358b0a829789ad68167974676f1ad542b9d8c0244fef4bcc1875fd4358f1d9d22bf038f5abbd4aad6f694dc34a0d48fb4
|
data/lib/nexosis_api/client.rb
CHANGED
@@ -20,6 +20,7 @@ require 'nexosis_api/impact_metric'
|
|
20
20
|
require 'nexosis_api/imports_response'
|
21
21
|
require 'nexosis_api/join'
|
22
22
|
require 'nexosis_api/link'
|
23
|
+
require 'nexosis_api/list_queries'
|
23
24
|
require 'nexosis_api/message'
|
24
25
|
require 'nexosis_api/metric'
|
25
26
|
require 'nexosis_api/model_summary'
|
@@ -31,6 +32,7 @@ require 'nexosis_api/session_response'
|
|
31
32
|
require 'nexosis_api/session_result'
|
32
33
|
require 'nexosis_api/session_selection_metrics'
|
33
34
|
require 'nexosis_api/session'
|
35
|
+
require 'nexosis_api/sort_order'
|
34
36
|
require 'nexosis_api/time_interval'
|
35
37
|
require 'nexosis_api/timeseries_outliers'
|
36
38
|
require 'nexosis_api/view_definition'
|
@@ -28,19 +28,15 @@ module NexosisApi
|
|
28
28
|
|
29
29
|
# Gets the list of data sets that have been saved to the system, optionally filtering by partial name match.
|
30
30
|
#
|
31
|
-
# @param
|
32
|
-
# @param page [int] page number for items in list
|
33
|
-
# @param page_size [int] number of items in each page
|
31
|
+
# @param dataset_list_query [NexosisApi::DatasetListQuery] Defines options for limiting list query results.
|
34
32
|
# @return [NexosisApi::PagedArray of NexosisApi::DatasetSummary] array of datasets found
|
35
|
-
# @since 1.4 - added paging parameters
|
36
|
-
|
33
|
+
# @since 1.4.0 - added paging parameters
|
34
|
+
# @since 2.5.0 - added multiple query options
|
35
|
+
# @since 3.0.0 - use list query instead of differing parms
|
36
|
+
# @note a default list query will use page=0 and pageSize=50 in the query
|
37
|
+
def list_datasets(dataset_list_query = NexosisApi::DatasetListQuery.new)
|
37
38
|
list_dataset_url = '/data'
|
38
|
-
|
39
|
-
page: page,
|
40
|
-
pageSize: page_size
|
41
|
-
}
|
42
|
-
query['partialName'] = partial_name unless partial_name.empty?
|
43
|
-
response = self.class.get(list_dataset_url, headers: @headers, query: query)
|
39
|
+
response = self.class.get(list_dataset_url, headers: @headers, query: dataset_list_query.query_parameters)
|
44
40
|
if response.success?
|
45
41
|
NexosisApi::PagedArray.new(response.parsed_response,
|
46
42
|
response.parsed_response['items']
|
@@ -8,19 +8,12 @@ module NexosisApi
|
|
8
8
|
|
9
9
|
# List all existing import requests
|
10
10
|
#
|
11
|
-
# @param
|
12
|
-
# @param page [int] page number for items in list
|
13
|
-
# @param page_size [int] number of items in each page
|
11
|
+
# @param import_list_query [NexosisApi::ImportListQuery] options to limit the query results
|
14
12
|
# @return [NexosisApi::PagedArray of NexosisApi::ImportsResponse]
|
15
13
|
# @since 1.4 added paging parameters
|
16
|
-
def list_imports(
|
14
|
+
def list_imports(import_list_query = NexosisApi::ImportListQuery.new)
|
17
15
|
imports_url = '/imports'
|
18
|
-
|
19
|
-
dataSetName: dataset_name,
|
20
|
-
page: page,
|
21
|
-
pageSize: page_size
|
22
|
-
}
|
23
|
-
response = self.class.get(imports_url, headers: @headers, query: query)
|
16
|
+
response = self.class.get(imports_url, headers: @headers, query: import_list_query.query_parameters)
|
24
17
|
if (response.success?)
|
25
18
|
NexosisApi::PagedArray.new(response.parsed_response,
|
26
19
|
response.parsed_response['items']
|
@@ -5,24 +5,14 @@ module NexosisApi
|
|
5
5
|
module Models
|
6
6
|
# List all models created in your company, optionally filtered by query parameters
|
7
7
|
#
|
8
|
-
# @param
|
9
|
-
# models created for this data source name.
|
10
|
-
# @param query_options [Hash] limit by dates: begin_date and/or end_date
|
8
|
+
# @param model_list_query [NexosisApi::ModelListQuery] optionally limit query results by the given parameters
|
11
9
|
# @note - query options dates can either be ISO 8601 compliant strings or Date objects.
|
12
10
|
# @return [NexosisApi::PagedArray of NexosisApi::ModelSummary] - all models available within the query parameters
|
13
11
|
# @raise [NexosisApi::HttpException]
|
14
|
-
|
12
|
+
# @since 3.0.0 - all query parameters use list query class
|
13
|
+
def list_models(model_list_query = NexosisApi::ModelListQuery.new)
|
15
14
|
model_url = '/models'
|
16
|
-
|
17
|
-
page: page,
|
18
|
-
pageSize: page_size
|
19
|
-
}
|
20
|
-
unless query_options.empty?
|
21
|
-
query.store('createdBeforeDate', query_options['end_date']) unless query_options['end_date'].nil?
|
22
|
-
query.store('createdAfterDate', query_options['begin_date']) unless query_options['begin_date'].nil?
|
23
|
-
end
|
24
|
-
query.store('dataSourceName', datasource_name) unless datasource_name.nil?
|
25
|
-
response = self.class.get(model_url, headers: @headers, query: query)
|
15
|
+
response = self.class.get(model_url, headers: @headers, query: model_list_query.query_parameters)
|
26
16
|
raise HttpException.new("There was a problem listing models: #{response.code}.",
|
27
17
|
"listing models with data source name #{datasource_name}",
|
28
18
|
response) unless response.success?
|
@@ -10,29 +10,20 @@ module NexosisApi
|
|
10
10
|
|
11
11
|
# List sessions previously submitted
|
12
12
|
#
|
13
|
-
# @param
|
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
|
13
|
+
# @param session_list_query [NexosisApi::SessionListQuery] optionally provide query parameters to limit the search of sessions.
|
16
14
|
# @return [NexosisApi::PagedArray of NexosisApi::SessionResponse] with all sessions matching the query or all if no query
|
17
15
|
# @raise [NexosisApi::HttpException]
|
18
|
-
# @note query parameters hash members are dataset_name, event_name,
|
19
|
-
#
|
16
|
+
# @note query parameters hash members are dataset_name, event_name, model_id,
|
17
|
+
# sort_by, sort_order, requested_before_date, and requested_after_date.
|
18
|
+
# After and before dates refer to the session requested date.
|
20
19
|
# @example query for just one dataset
|
21
20
|
# sessions = NexosisApi.client.list_sessions :dataset_name => 'MyDataset'
|
22
|
-
|
21
|
+
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/sessions-list-all?
|
22
|
+
def list_sessions(session_list_query = NexosisApi::SessionListQuery.new)
|
23
23
|
sessions_url = '/sessions'
|
24
|
-
|
25
|
-
'dataSetName' => query_options[:dataset_name],
|
26
|
-
'eventName' => query_options[:event_name],
|
27
|
-
'requestedAfterDate' => query_options[:requested_after_date],
|
28
|
-
'requestedBeforeDate' => query_options[:requested_before_date],
|
29
|
-
'type' => query_options[:type],
|
30
|
-
'page' => page,
|
31
|
-
'pageSize' => pageSize
|
32
|
-
}
|
33
|
-
response = self.class.get(sessions_url, headers: @headers, query: query)
|
24
|
+
response = self.class.get(sessions_url, headers: @headers, query: session_list_query.query_parameters)
|
34
25
|
raise HttpException.new('Could not retrieve sessions',
|
35
|
-
"Get all sessions with query #{
|
26
|
+
"Get all sessions with query #{session_list_query.query_parameters}",
|
36
27
|
response) unless response.success?
|
37
28
|
NexosisApi::PagedArray.new(response.parsed_response, response.parsed_response['items'].map do |session_hash|
|
38
29
|
response_hash = { 'session' => session_hash }.merge(response.headers)
|
@@ -0,0 +1,198 @@
|
|
1
|
+
module NexosisApi
|
2
|
+
require 'date'
|
3
|
+
# Class to hold general query options for list requests
|
4
|
+
# @since 3.0.0
|
5
|
+
class ListQuery
|
6
|
+
def initialize(options = { 'page_number': 0, 'page_size': 50 }, *additional_keys)
|
7
|
+
assert_valid_keys(options, :page_number, :page_size, :sort_order, :sort_by, additional_keys)
|
8
|
+
@page_number = options.key?(:page_number) ? options[:page_number] : 0
|
9
|
+
@page_size = options.key?(:page_size) ? options[:page_size] : 50
|
10
|
+
@sort_order = NexosisApi::SortOrder.const_get(options[:sort_order].upcase) if options.key? :sort_order
|
11
|
+
@sort_by = options[:sort_by] if options.key? :sort_by
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_hash
|
15
|
+
query = {
|
16
|
+
'page': @page_number,
|
17
|
+
'pageSize': @page_size
|
18
|
+
}
|
19
|
+
query.store(:sortOrder, @sort_order) unless @sort_order.nil?
|
20
|
+
query.store(:sortBy, @sort_by) unless @sort_by.nil?
|
21
|
+
query
|
22
|
+
end
|
23
|
+
|
24
|
+
# Count of results to retrieve in each page (max 1000).
|
25
|
+
# @return [Integer]
|
26
|
+
attr_accessor :page_size
|
27
|
+
|
28
|
+
# zero-based page number of results to retrieve
|
29
|
+
# @return [Integer]
|
30
|
+
attr_accessor :page_number
|
31
|
+
|
32
|
+
# Direction to sort the results.
|
33
|
+
# @return [NexosisApi::SortOrder]
|
34
|
+
attr_accessor :sort_order
|
35
|
+
|
36
|
+
# The name of an entity property to sort by
|
37
|
+
# @return [String]
|
38
|
+
# @note - each entity has different possibilities. See the api doc links on each list type for more information.
|
39
|
+
attr_accessor :sort_by
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def date_string(date_field)
|
44
|
+
raise ArgumentError, 'date_field was not provided and is not optional ' if date_field.to_s.empty?
|
45
|
+
date = DateTime.parse(date_field.to_s)
|
46
|
+
date.strftime('%FT%T%:z')
|
47
|
+
end
|
48
|
+
|
49
|
+
def assert_valid_keys(options, *valid_keys)
|
50
|
+
valid_keys.flatten!
|
51
|
+
options.keys.each do |k|
|
52
|
+
unless valid_keys.include?(k)
|
53
|
+
raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# class to hold the query options for list datasets
|
60
|
+
# @since 3.0.0
|
61
|
+
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/datasets-list-all?
|
62
|
+
# @note - sort by properties include dataSetName, dataSetSize, rowCount, dateCreated, and lastModified
|
63
|
+
class DatasetListQuery < ListQuery
|
64
|
+
def initialize(options = {})
|
65
|
+
|
66
|
+
@partial_name = options[:partial_name] if options.key? :partial_name
|
67
|
+
super(options, :partial_name)
|
68
|
+
end
|
69
|
+
|
70
|
+
# A hash suitable for using as the query portion of an HTTP request to the API
|
71
|
+
# @return [Hash]
|
72
|
+
def query_parameters
|
73
|
+
parm_hash = {}
|
74
|
+
parm_hash.store(:partialName, @partial_name) unless @partial_name.nil?
|
75
|
+
self.to_hash.merge(parm_hash)
|
76
|
+
end
|
77
|
+
# The name or part of a name by which to limit the list results.
|
78
|
+
# @return [String]
|
79
|
+
attr_accessor :partial_name
|
80
|
+
end
|
81
|
+
|
82
|
+
# class to hold the query options for list datasets
|
83
|
+
# @since 3.0.0
|
84
|
+
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/sessions-list-all?
|
85
|
+
# @note sort by properties include id, name, type, status, dataSourceName, and requestedDate
|
86
|
+
class SessionListQuery < ListQuery
|
87
|
+
def initialize(options = {})
|
88
|
+
@datasource_name = options[:datasource_name] if options.key? :datasource_name
|
89
|
+
@event_name = options[:event_name] if options.key? :event_name
|
90
|
+
@model_id = options[:model_id] if options.key? :model_id
|
91
|
+
@requested_after_date = options[:requested_after_date] if options.key? :requested_after_date
|
92
|
+
@requested_before_date = options[:requested_before_date] if options.key? :requested_before_date
|
93
|
+
super(options, :datasource_name, :event_name, :model_id, :requested_after_date, :requested_before_date)
|
94
|
+
end
|
95
|
+
|
96
|
+
# A hash suitable for using as the query portion of an HTTP request to the API
|
97
|
+
# @return [Hash]
|
98
|
+
def query_parameters
|
99
|
+
parm_hash = {}
|
100
|
+
parm_hash.store(:dataSourceName, @datasource_name) unless @datasource_name.nil?
|
101
|
+
parm_hash.store(:eventName, @event_name) unless @event_name.nil?
|
102
|
+
parm_hash.store(:modelId, @model_id) unless @model_id.nil?
|
103
|
+
parm_hash.store(:requestedAfterDate, date_string(@requested_after_date)) unless @requested_after_date.nil?
|
104
|
+
parm_hash.store(:requestedBeforeDate, date_string(@requested_before_date)) unless @requested_before_date.nil?
|
105
|
+
self.to_hash.merge(parm_hash)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Limits sessions to those for a particular data source
|
109
|
+
# @return [String]
|
110
|
+
attr_accessor :datasource_name
|
111
|
+
|
112
|
+
# Limits impact sessions to those for a particular event
|
113
|
+
# @return [String]
|
114
|
+
attr_accessor :event_name
|
115
|
+
|
116
|
+
# Limits model-building sessions to those that built the specified model
|
117
|
+
# @return [String]
|
118
|
+
attr_accessor :model_id
|
119
|
+
|
120
|
+
# Format - date-time (as date-time in ISO8601). Limits sessions to those requested on or after the specified date
|
121
|
+
# @return [String]
|
122
|
+
attr_accessor :requested_after_date
|
123
|
+
|
124
|
+
# Format - date-time (as date-time in ISO8601). Limits sessions to those requested on or before the specified date
|
125
|
+
# @return [String]
|
126
|
+
attr_accessor :requested_before_date
|
127
|
+
end
|
128
|
+
|
129
|
+
# class to hold the query options for list models
|
130
|
+
# @since 3.0.0
|
131
|
+
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/models-list-all?
|
132
|
+
# @note sort by properties include id, modelName, dataSourceName, type, createdDate, and lastUsedDate
|
133
|
+
class ModelListQuery < ListQuery
|
134
|
+
def initialize(options = {})
|
135
|
+
@datasource_name = options[:datasource_name] if options.key? :datasource_name
|
136
|
+
@created_after_date = options[:created_after_date] if options.key? :created_after_date
|
137
|
+
@created_before_date = options[:created_before_date] if options.key? :created_before_date
|
138
|
+
super(options, :datasource_name, :created_after_date, :created_before_date)
|
139
|
+
end
|
140
|
+
|
141
|
+
# A hash suitable for using as the query portion of an HTTP request to the API
|
142
|
+
# @return [Hash]
|
143
|
+
def query_parameters
|
144
|
+
parm_hash = {}
|
145
|
+
parm_hash.store(:dataSourceName, @datasource_name) unless @datasource_name.nil?
|
146
|
+
parm_hash.store(:createdAfterDate, date_string(@created_after_date)) unless @created_after_date.nil?
|
147
|
+
parm_hash.store(:createdBeforeDate, date_string(@created_before_date)) unless @created_before_date.nil?
|
148
|
+
self.to_hash.merge(parm_hash)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Limits models to those for a particular data source
|
152
|
+
# @return [String]
|
153
|
+
attr_accessor :datasource_name
|
154
|
+
|
155
|
+
# Format - date-time (as date-time in ISO8601). Limits models to those created on or after the specified date
|
156
|
+
# @return [String]
|
157
|
+
attr_accessor :created_after_date
|
158
|
+
|
159
|
+
# Format - date-time (as date-time in ISO8601). Limits models to those created on or before the specified date
|
160
|
+
# @return [String]
|
161
|
+
attr_accessor :created_before_date
|
162
|
+
end
|
163
|
+
|
164
|
+
# class to hold the query options for list imports
|
165
|
+
# @since 3.0.0
|
166
|
+
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/imports-list-imports?
|
167
|
+
# @note sort by properties include id, dataSetName, requestedDate, and currentStatusDate
|
168
|
+
class ImportListQuery < ListQuery
|
169
|
+
def initialize(options = {})
|
170
|
+
@dataset_name = options[:dataset_name] if options.key? :dataset_name
|
171
|
+
@requested_after_date = options[:requested_after_date] if options.key? :requested_after_date
|
172
|
+
@requested_before_date = options[:requested_before_date] if options.key? :requested_before_date
|
173
|
+
super(options, :dataset_name, :requested_after_date, :requested_before_date)
|
174
|
+
end
|
175
|
+
|
176
|
+
# A hash suitable for using as the query portion of an HTTP request to the API
|
177
|
+
# @return [Hash]
|
178
|
+
def query_parameters
|
179
|
+
parm_hash = {}
|
180
|
+
parm_hash.store(:dataSourceName, @dataset_name) unless @dataset_name.nil?
|
181
|
+
parm_hash.store(:requestedAfterDate, date_string(@requested_after_date)) unless @requested_after_date.nil?
|
182
|
+
parm_hash.store(:requestedBeforeDate, date_string(@requested_before_date)) unless @requested_before_date.nil?
|
183
|
+
self.to_hash.merge(parm_hash)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Limits imports to those for a particular dataset
|
187
|
+
# @return [String]
|
188
|
+
attr_accessor :dataset_name
|
189
|
+
|
190
|
+
# Format - date-time (as date-time in ISO8601). Limits imports to those requested on or after the specified date
|
191
|
+
# @return [String]
|
192
|
+
attr_accessor :requested_after_date
|
193
|
+
|
194
|
+
# Format - date-time (as date-time in ISO8601). Limits imports to those requested on or before the specified date
|
195
|
+
# @return [String]
|
196
|
+
attr_accessor :requested_before_date
|
197
|
+
end
|
198
|
+
end
|
data/nexosisapi.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
spec.required_ruby_version = '>= 2.3.0'
|
18
18
|
spec.summary = "Ruby client for working with the Nexosis API"
|
19
|
-
spec.version = '
|
19
|
+
spec.version = '3.0.0'
|
20
20
|
spec.metadata["yard.run"] = "yri"
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexosis_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nexosis,Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/nexosis_api/imports_response.rb
|
77
77
|
- lib/nexosis_api/join.rb
|
78
78
|
- lib/nexosis_api/link.rb
|
79
|
+
- lib/nexosis_api/list_queries.rb
|
79
80
|
- lib/nexosis_api/message.rb
|
80
81
|
- lib/nexosis_api/metric.rb
|
81
82
|
- lib/nexosis_api/model_summary.rb
|
@@ -87,6 +88,7 @@ files:
|
|
87
88
|
- lib/nexosis_api/session_response.rb
|
88
89
|
- lib/nexosis_api/session_result.rb
|
89
90
|
- lib/nexosis_api/session_selection_metrics.rb
|
91
|
+
- lib/nexosis_api/sort_order.rb
|
90
92
|
- lib/nexosis_api/time_interval.rb
|
91
93
|
- lib/nexosis_api/timeseries_outliers.rb
|
92
94
|
- lib/nexosis_api/view_data.rb
|