onvo 0.0.0 → 0.1.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/onvo/accounts.rb +14 -0
- data/lib/onvo/automations.rb +26 -0
- data/lib/onvo/dashboard/dashboard_resource.rb +16 -0
- data/lib/onvo/dashboard/datasources.rb +19 -0
- data/lib/onvo/dashboard/questions.rb +17 -0
- data/lib/onvo/dashboard/sessions.rb +24 -0
- data/lib/onvo/dashboard/widgets.rb +28 -0
- data/lib/onvo/dashboard.rb +20 -0
- data/lib/onvo/dashboards.rb +26 -0
- data/lib/onvo/datasources.rb +34 -0
- data/lib/onvo/embed_users.rb +34 -0
- data/lib/onvo/teams.rb +14 -0
- data/lib/onvo.rb +30 -4
- data/lib/resource.rb +51 -0
- metadata +50 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a7a5c75c36304b627cecd1f2ec86178bc3027e829fcfc1c146b0da30a4fbb86
|
4
|
+
data.tar.gz: 5689e8bd4998ca276a24f60232ee91675c89f9ef2c101bbf31e8e31a4c6b8363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e106aa86da954751fe9e97748c90e462c7bf4bd39622b44e4bbe659c9196e2e6a29c70a6621aad84fa80b09c14e3f4fc1e57a3376f315ed37ad086c1a362a1
|
7
|
+
data.tar.gz: 8fdd8b97d7cdd0f82013f48c2d4c0335e1a1d9c47808c95e35346d53f7c1e612aa6626ae19517bd9d43b74506fea9920220fc0a4523b16db6956f2cef52fd84e
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../resource'
|
4
|
+
|
5
|
+
# Automation endpoints
|
6
|
+
class Automations < Resource
|
7
|
+
def list
|
8
|
+
base_get('/automations')
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id)
|
12
|
+
base_get("/automations/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete(id)
|
16
|
+
base_delete("/automations/#{id}")
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(id, body)
|
20
|
+
base_post("/automations/#{id}", body)
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(body)
|
24
|
+
base_put('/automations', body)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../resource'
|
4
|
+
|
5
|
+
# The default template for an Onvo Dashboard Resource
|
6
|
+
class DashboardResource < Resource
|
7
|
+
include HTTParty
|
8
|
+
|
9
|
+
attr_accessor :dashboard_id
|
10
|
+
|
11
|
+
def initialize(dashboard_id, endpoint, api_key)
|
12
|
+
@dashboard_id = dashboard_id
|
13
|
+
@endpoint = endpoint
|
14
|
+
super(endpoint, api_key)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require_relative './dashboard_resource'
|
5
|
+
|
6
|
+
# Dashboard Widget endpoints
|
7
|
+
class DashboardDatasources < DashboardResource
|
8
|
+
def list
|
9
|
+
base_get("/dashboards/#{@dashboard_id}/datasources")
|
10
|
+
end
|
11
|
+
|
12
|
+
def link(datasource_id)
|
13
|
+
base_put("/dashboards/#{@dashboard_id}/datasources", datasourceId: datasource_id) #TODO: check if not "datasourceId"
|
14
|
+
end
|
15
|
+
|
16
|
+
def unlink(datasource_id)
|
17
|
+
base_delete("/dashboards/#{@dashboard_id}/datasources/#{datasource_id}")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require_relative './dashboard_resource'
|
5
|
+
|
6
|
+
# Dashboard Question endpoints
|
7
|
+
class DashboardQuestions < DashboardResource
|
8
|
+
def list
|
9
|
+
base_get("/dashboards/#{@dashboard_id}/questions")
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO: ask?
|
13
|
+
def create(query)
|
14
|
+
processed_query = URI.encode_www_form_component(query)
|
15
|
+
base_put("/dashboards/#{@dashboard_id}/questions?query=#{processed_query}")
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './dashboard_resource'
|
4
|
+
|
5
|
+
# Dashboard session endpoints
|
6
|
+
class DashboardSessions < DashboardResource
|
7
|
+
def list
|
8
|
+
base_get("/dashboards/#{@dashboard_id}/sessions")
|
9
|
+
end
|
10
|
+
|
11
|
+
# TODO: check if rename to delete_all
|
12
|
+
def delete
|
13
|
+
base_delete("/dashboards/#{@dashboard_id}/sessions")
|
14
|
+
end
|
15
|
+
|
16
|
+
def upsert(user_id, parameters = {})
|
17
|
+
session_data = base_post(
|
18
|
+
"/dashboards/#{@dashboard_id}/sessions",
|
19
|
+
user: user_id,
|
20
|
+
parameters: parameters
|
21
|
+
)
|
22
|
+
session_data.merge({ 'url': "#{@endpoint}#{session_data['url']}" })
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require_relative './dashboard_resource'
|
5
|
+
|
6
|
+
# Dashboard Widget endpoints
|
7
|
+
class DashboardWidgets < DashboardResource
|
8
|
+
def list
|
9
|
+
base_get("/dashboards/#{@dashboard_id}/widgets")
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(widget_id)
|
13
|
+
base_get("/dashboards/#{@dashboard_id}/widgets/#{widget_id}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(widget_id)
|
17
|
+
base_delete("/dashboards/#{@dashboard_id}/widgets/#{widget_id}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(widget_id, body)
|
21
|
+
base_post("/dashboards/#{@dashboard_id}/widgets/#{widget_id}", body)
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(query)
|
25
|
+
processed_query = URI.encode_www_form_component(query)
|
26
|
+
base_put("/dashboards/#{@dashboard_id}/widgets?query=#{processed_query}")
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './dashboard/datasources'
|
4
|
+
require_relative './dashboard/widgets'
|
5
|
+
require_relative './dashboard/questions'
|
6
|
+
require_relative './dashboard/sessions'
|
7
|
+
|
8
|
+
# The Dashboard API
|
9
|
+
class Dashboard
|
10
|
+
attr_accessor :datasources, :widgets, :questions, :sessions
|
11
|
+
|
12
|
+
def initialize(dashboard_id, endpoint, api_key)
|
13
|
+
params = [dashboard_id, endpoint, api_key]
|
14
|
+
|
15
|
+
@datasources = DashboardDatasources.new(*params)
|
16
|
+
@widgets = DashboardWidgets.new(*params)
|
17
|
+
@questions = DashboardQuestions.new(*params)
|
18
|
+
@sessions = DashboardSessions.new(*params)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../resource'
|
4
|
+
|
5
|
+
# Dashboard endpoints
|
6
|
+
class Dashboards < Resource
|
7
|
+
def list
|
8
|
+
base_get('/dashboards')
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id)
|
12
|
+
base_get("/dashboards/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete(id)
|
16
|
+
base_delete("/dashboards/#{id}")
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(id, body)
|
20
|
+
base_post("/dashboards/#{id}", body)
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(body)
|
24
|
+
base_put('/dashboards', body)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../resource'
|
4
|
+
|
5
|
+
# Datasource endpoints
|
6
|
+
class Datasources < Resource
|
7
|
+
def list
|
8
|
+
base_get('/datasources')
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id)
|
12
|
+
base_get("/datasources/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_data(id)
|
16
|
+
base_get("/datasources/#{id}/data")
|
17
|
+
end
|
18
|
+
|
19
|
+
def fetch_column_descriptions(id)
|
20
|
+
base_post("/datasources/#{id}/populate-columns")
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(id)
|
24
|
+
base_delete("/datasources/#{id}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def update(id, body)
|
28
|
+
base_post("/datasources/#{id}", body)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create(body)
|
32
|
+
base_put('/datasources', body)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../resource'
|
4
|
+
|
5
|
+
# Embed user endpoints
|
6
|
+
class EmbedUsers < Resource
|
7
|
+
def list
|
8
|
+
base_get('/embed-users')
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id)
|
12
|
+
base_get("/embed-users/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete(id)
|
16
|
+
base_delete("/embed-users/#{id}")
|
17
|
+
end
|
18
|
+
|
19
|
+
def upsert(id, name, email, metadata = {})
|
20
|
+
base_post(
|
21
|
+
'/embed-users',
|
22
|
+
{
|
23
|
+
'id': id,
|
24
|
+
'name': name,
|
25
|
+
'email': email,
|
26
|
+
'metadata': metadata
|
27
|
+
}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_access_token(id)
|
32
|
+
base_get("/embed-users/#{id}/token")
|
33
|
+
end
|
34
|
+
end
|
data/lib/onvo/teams.rb
ADDED
data/lib/onvo.rb
CHANGED
@@ -1,7 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require_relative './onvo/accounts'
|
4
|
+
require_relative './onvo/teams'
|
5
|
+
require_relative './onvo/embed_users'
|
6
|
+
require_relative './onvo/datasources'
|
7
|
+
require_relative './onvo/automations'
|
8
|
+
require_relative './onvo/dashboards'
|
9
|
+
|
10
|
+
require_relative './onvo/dashboard'
|
11
|
+
|
12
|
+
# The Onvo Ruby SDK
|
13
|
+
class Onvo
|
14
|
+
attr_reader :accounts, :teams, :embed_users, :datasources, :automations, :dashboards
|
15
|
+
attr_accessor :endpoint, :api_key
|
16
|
+
|
17
|
+
def initialize(endpoint = ENV['ONVO_API_ENDPOINT'], api_key = ENV['ONVO_API_KEY'])
|
18
|
+
@endpoint = endpoint
|
19
|
+
@api_key = api_key
|
20
|
+
params = [@endpoint, @api_key]
|
21
|
+
|
22
|
+
@accounts = Accounts.new(*params)
|
23
|
+
@teams = Teams.new(*params)
|
24
|
+
@embed_users = EmbedUsers.new(*params)
|
25
|
+
@datasources = Datasources.new(*params)
|
26
|
+
@automations = Automations.new(*params)
|
27
|
+
@dashboards = Dashboards.new(*params)
|
28
|
+
end
|
29
|
+
|
30
|
+
def dashboard(dashboard_id)
|
31
|
+
Dashboard.new(dashboard_id, @endpoint, @api_key)
|
6
32
|
end
|
7
|
-
end
|
33
|
+
end
|
data/lib/resource.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
require 'json'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
# The default template for an Onvo Resource
|
8
|
+
class Resource
|
9
|
+
include HTTParty
|
10
|
+
|
11
|
+
attr_accessor :options
|
12
|
+
|
13
|
+
def initialize(endpoint, api_key)
|
14
|
+
self.class.base_uri endpoint
|
15
|
+
@options = {
|
16
|
+
headers: {
|
17
|
+
'x-api-key': api_key,
|
18
|
+
'Content-Type': 'application/json'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def base_request
|
24
|
+
response = yield
|
25
|
+
body = JSON.parse(response.body)
|
26
|
+
# TODO: Replace Runtime w/ custom errors
|
27
|
+
raise "#{response.code} Error : #{body['message']}" if response.code >= 400
|
28
|
+
|
29
|
+
body
|
30
|
+
rescue JSON::ParserError, TypeError
|
31
|
+
response.body
|
32
|
+
end
|
33
|
+
|
34
|
+
def base_get(subdirectory)
|
35
|
+
base_request { self.class.get(subdirectory, options) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def base_put(subdirectory, body = nil)
|
39
|
+
params = body ? options.merge({ body: body.to_json }) : options
|
40
|
+
base_request { self.class.put(subdirectory, params) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def base_post(subdirectory, body = nil)
|
44
|
+
params = body ? options.merge({ body: body.to_json }) : options
|
45
|
+
base_request { self.class.post(subdirectory, params) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def base_delete(subdirectory)
|
49
|
+
base_request { self.class.delete(subdirectory, options) }
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,23 +1,66 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onvo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Ronnel Davis
|
8
7
|
- Bryan Davis
|
8
|
+
- Ronnel Davis
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
12
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.13.7
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.13.7
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: minitest-hooks
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.5.1
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.5.1
|
42
|
+
description: A gem to provide utilities to seamlessly communicate with the Onvo platform,
|
43
|
+
allowing developers to integrate AI-powered dashboards into their products.
|
15
44
|
email:
|
45
|
+
- bryandavis999.dev@gmail.com
|
16
46
|
executables: []
|
17
47
|
extensions: []
|
18
48
|
extra_rdoc_files: []
|
19
49
|
files:
|
20
50
|
- lib/onvo.rb
|
51
|
+
- lib/onvo/accounts.rb
|
52
|
+
- lib/onvo/automations.rb
|
53
|
+
- lib/onvo/dashboard.rb
|
54
|
+
- lib/onvo/dashboard/dashboard_resource.rb
|
55
|
+
- lib/onvo/dashboard/datasources.rb
|
56
|
+
- lib/onvo/dashboard/questions.rb
|
57
|
+
- lib/onvo/dashboard/sessions.rb
|
58
|
+
- lib/onvo/dashboard/widgets.rb
|
59
|
+
- lib/onvo/dashboards.rb
|
60
|
+
- lib/onvo/datasources.rb
|
61
|
+
- lib/onvo/embed_users.rb
|
62
|
+
- lib/onvo/teams.rb
|
63
|
+
- lib/resource.rb
|
21
64
|
homepage:
|
22
65
|
licenses: []
|
23
66
|
metadata: {}
|
@@ -25,6 +68,7 @@ post_install_message:
|
|
25
68
|
rdoc_options: []
|
26
69
|
require_paths:
|
27
70
|
- lib
|
71
|
+
- lib/onvo
|
28
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
29
73
|
requirements:
|
30
74
|
- - ">="
|
@@ -39,6 +83,5 @@ requirements: []
|
|
39
83
|
rubygems_version: 3.3.7
|
40
84
|
signing_key:
|
41
85
|
specification_version: 4
|
42
|
-
summary:
|
43
|
-
allowing developers to integrate AI-powered dashboards into their products.
|
86
|
+
summary: Communicate with the Onvo platform.
|
44
87
|
test_files: []
|