tableau_server_client 0.0.5 → 0.0.6
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 +5 -5
- data/lib/tableau_server_client/client.rb +2 -1
- data/lib/tableau_server_client/resources/datasource.rb +25 -5
- data/lib/tableau_server_client/resources/project.rb +39 -1
- data/lib/tableau_server_client/resources/site.rb +17 -0
- data/lib/tableau_server_client/resources/user.rb +44 -0
- data/lib/tableau_server_client/resources/workbook.rb +25 -6
- data/lib/tableau_server_client/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b8a666b653ed10385210a2d5fafd96e14c80f0442841f998c30bd5d379cb671
|
4
|
+
data.tar.gz: f35e189ebd0f4e4b35022ce3f1ba9f2d17c6504320a2b24eed0d39737f78c407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66c31722e7302062da98b6d655b493b268b2ab3a33c7be6edef9d6e814eaa62ef639b2b4b8902661147103466cf2cd6acd766ba02f6d665c0c498717a6f4751e
|
7
|
+
data.tar.gz: f8c22234d123f2d1cb5f8e1dbe9d94dd66ac93fdc8e5768f9f2cbd0b0df5dcb517d9309ab2a402e465b6ac1031afca4ca61b16a5cfaa2ca2d5dd30592460d88f
|
@@ -39,7 +39,8 @@ module TableauServerClient
|
|
39
39
|
def get(resource_location)
|
40
40
|
req_url = request_url(resource_location.path)
|
41
41
|
response = session.get req_url.to_s
|
42
|
-
|
42
|
+
xml = Nokogiri::XML(response.body).xpath("//xmlns:tsResponse").children.first
|
43
|
+
resource_location.klass.from_response(self, resource_location.path, xml)
|
43
44
|
end
|
44
45
|
|
45
46
|
def create(resource)
|
@@ -7,14 +7,13 @@ module TableauServerClient
|
|
7
7
|
|
8
8
|
class Datasource < Resource
|
9
9
|
|
10
|
-
attr_reader :id, :name, :content_url, :type, :created_at, :updated_at, :is_certified
|
10
|
+
attr_reader :id, :name, :content_url, :type, :created_at, :updated_at, :is_certified
|
11
|
+
attr_writer :owner
|
11
12
|
|
12
13
|
def self.from_response(client, path, xml)
|
13
14
|
attrs = extract_attributes(xml)
|
14
|
-
|
15
|
-
|
16
|
-
project_path = "#{site_path}/projects/#{project['id']}"
|
17
|
-
attrs['project'] = Project.from_response(client, project_path, project)
|
15
|
+
attrs['project_id'] = xml.xpath("xmlns:project")[0]['id']
|
16
|
+
attrs['owner_id'] = xml.xpath("xmlns:owner")[0]['id']
|
18
17
|
#TODO add owner
|
19
18
|
new(client, path, attrs)
|
20
19
|
end
|
@@ -30,6 +29,27 @@ module TableauServerClient
|
|
30
29
|
@client.get_collection Connection.location(path)
|
31
30
|
end
|
32
31
|
|
32
|
+
def project
|
33
|
+
@project ||= @client.get_collection(Project.location(site_path)).find {|p| p.id == @project_id }
|
34
|
+
end
|
35
|
+
|
36
|
+
def owner
|
37
|
+
@owner ||= @client.get User.location(site_path, @owner_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_request
|
41
|
+
request = build_request {|b|
|
42
|
+
b.datasource {|w|
|
43
|
+
w.owner(id: owner.id)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def update!
|
49
|
+
@client.update self
|
50
|
+
end
|
51
|
+
|
52
|
+
|
33
53
|
end
|
34
54
|
end
|
35
55
|
end
|
@@ -5,7 +5,7 @@ module TableauServerClient
|
|
5
5
|
|
6
6
|
class Project < Resource
|
7
7
|
|
8
|
-
attr_reader :id, :name, :description, :
|
8
|
+
attr_reader :id, :name, :description, :parent_project_id
|
9
9
|
|
10
10
|
def self.from_response(client, path, xml)
|
11
11
|
attrs = extract_attributes(xml)
|
@@ -30,6 +30,44 @@ module TableauServerClient
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def root_project?
|
34
|
+
self.parent_project_id.nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
def root_project
|
38
|
+
parent_projects[0] || self
|
39
|
+
end
|
40
|
+
|
41
|
+
def parent_projects
|
42
|
+
return @parent_projects if @parent_projects
|
43
|
+
@parent_projects = []
|
44
|
+
curr_pj = self
|
45
|
+
pjs = @client.get_collection Project.location(site_path)
|
46
|
+
while ! curr_pj.root_project?
|
47
|
+
pjs.each do |pj|
|
48
|
+
if pj.id == curr_pj.parent_project_id
|
49
|
+
@parent_projects.unshift pj
|
50
|
+
curr_pj = pj
|
51
|
+
break
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
return @parent_projects
|
56
|
+
end
|
57
|
+
|
58
|
+
def hierarchy
|
59
|
+
(parent_projects << self).map {|p| p.name }.join('/')
|
60
|
+
end
|
61
|
+
|
62
|
+
def extract_values_in_description
|
63
|
+
@values_in_description ||=\
|
64
|
+
description.lines.map { |l|/^(.*):\s*(.*)$/.match(l) }.reject { |m| m.nil? }.map { |m| m[1,2] }.to_h
|
65
|
+
end
|
66
|
+
|
67
|
+
def extract_value_in_description(key)
|
68
|
+
extract_values_in_description[key]
|
69
|
+
end
|
70
|
+
|
33
71
|
end
|
34
72
|
end
|
35
73
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'tableau_server_client/resources/resource'
|
2
2
|
require 'tableau_server_client/resources/datasource'
|
3
3
|
require 'tableau_server_client/resources/workbook'
|
4
|
+
require 'tableau_server_client/resources/user'
|
4
5
|
|
5
6
|
module TableauServerClient
|
6
7
|
module Resources
|
@@ -37,6 +38,22 @@ module TableauServerClient
|
|
37
38
|
@client.get Workbook.location(path, id)
|
38
39
|
end
|
39
40
|
|
41
|
+
def users(filter: [])
|
42
|
+
@client.get_collection User.location(path, filter: filter)
|
43
|
+
end
|
44
|
+
|
45
|
+
def user(id)
|
46
|
+
@client.get User.location(path, id)
|
47
|
+
end
|
48
|
+
|
49
|
+
def projects(filter: [])
|
50
|
+
@client.get_collection Project.location(path, filter: filter)
|
51
|
+
end
|
52
|
+
|
53
|
+
def project(id)
|
54
|
+
projects.find { |p| p.id == id }
|
55
|
+
end
|
56
|
+
|
40
57
|
end
|
41
58
|
end
|
42
59
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'tableau_server_client/resources/resource'
|
2
|
+
|
3
|
+
module TableauServerClient
|
4
|
+
module Resources
|
5
|
+
|
6
|
+
class User < Resource
|
7
|
+
|
8
|
+
attr_reader :id, :name, :site_role, :last_login, :external_auth_user_id, :full_name
|
9
|
+
|
10
|
+
def self.from_response(client, path, xml)
|
11
|
+
attrs = extract_attributes(xml)
|
12
|
+
new(client, path, attrs)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.from_collection_response(client, path, xml)
|
16
|
+
xml.xpath("//xmlns:users/xmlns:user").each do |s|
|
17
|
+
id = s['id']
|
18
|
+
yield from_response(client, "#{path}/#{id}", s)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def reload
|
23
|
+
@client.get User.location(site_path, id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def full_name
|
27
|
+
@full_name ||= self.reload.full_name
|
28
|
+
end
|
29
|
+
|
30
|
+
def workbooks
|
31
|
+
@client.get_collection(Workbook.location(site_path, filter: ["ownerName:eq:#{full_name}"])).select do |w|
|
32
|
+
w.owner.id == id
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def datasources
|
37
|
+
@client.get_collection(Datasource.location(site_path, filter: ["ownerName:eq:#{full_name}"])).select do |d|
|
38
|
+
d.owner.id == id
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -7,15 +7,13 @@ module TableauServerClient
|
|
7
7
|
|
8
8
|
class Workbook < Resource
|
9
9
|
|
10
|
-
attr_reader :id, :name, :content_url, :show_tabs, :size, :created_at, :updated_at
|
10
|
+
attr_reader :id, :name, :content_url, :show_tabs, :size, :created_at, :updated_at
|
11
|
+
attr_writer :owner
|
11
12
|
|
12
13
|
def self.from_response(client, path, xml)
|
13
14
|
attrs = extract_attributes(xml)
|
14
|
-
|
15
|
-
|
16
|
-
project_path = "#{site_path}/projects/#{project['id']}"
|
17
|
-
attrs['project'] = Project.from_response(client, project_path, project)
|
18
|
-
#TODO add owner
|
15
|
+
attrs['project_id'] = xml.xpath("xmlns:project")[0]['id']
|
16
|
+
attrs['owner_id'] = xml.xpath("xmlns:owner")[0]['id']
|
19
17
|
new(client, path, attrs)
|
20
18
|
end
|
21
19
|
|
@@ -30,6 +28,27 @@ module TableauServerClient
|
|
30
28
|
@client.get_collection Connection.location(path)
|
31
29
|
end
|
32
30
|
|
31
|
+
def project
|
32
|
+
@project ||= @client.get_collection(Project.location(site_path)).find {|p| p.id == @project_id }
|
33
|
+
end
|
34
|
+
|
35
|
+
def owner
|
36
|
+
@owner ||= @client.get User.location(site_path, @owner_id)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_request
|
40
|
+
request = build_request {|b|
|
41
|
+
b.workbook {|w|
|
42
|
+
w.owner(id: owner.id)
|
43
|
+
}
|
44
|
+
}
|
45
|
+
request
|
46
|
+
end
|
47
|
+
|
48
|
+
def update!
|
49
|
+
@client.update self
|
50
|
+
end
|
51
|
+
|
33
52
|
end
|
34
53
|
end
|
35
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tableau_server_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shimpeko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/tableau_server_client/resources/resource.rb
|
133
133
|
- lib/tableau_server_client/resources/schedule.rb
|
134
134
|
- lib/tableau_server_client/resources/site.rb
|
135
|
+
- lib/tableau_server_client/resources/user.rb
|
135
136
|
- lib/tableau_server_client/resources/workbook.rb
|
136
137
|
- lib/tableau_server_client/server.rb
|
137
138
|
- lib/tableau_server_client/token.rb
|
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
158
|
version: '0'
|
158
159
|
requirements: []
|
159
160
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.6
|
161
|
+
rubygems_version: 2.7.6
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: Tableau Server REST API Client
|