tableau_rest_api 0.1.2 → 0.1.3
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/.gitignore +12 -0
- data/.ruby-version +1 -0
- data/lib/tableau_rest_api/client.rb +7 -4
- data/lib/tableau_rest_api/resource.rb +9 -2
- data/lib/tableau_rest_api/util/pagination.rb +40 -0
- data/lib/tableau_rest_api/version.rb +1 -1
- data/lib/tableau_rest_api.rb +1 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b09a487d6e675e8c269d57e3034fa3d8889fb6c7
|
4
|
+
data.tar.gz: e9b1d15ecf421e2af1615370d5b9dcdb2e6e6bff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff6cbe3ebf6bda4ea65619b0c3946549029fdcafe0528b471a533a47951e8591a1239e8fe8683d2b5188b0805df1695b001ee76537dc46ef6c39a6bc99c49ff6
|
7
|
+
data.tar.gz: bf7b55e5c93883561ff88514127cde5b0749fed5d3cf1b393526dba77db88bc2a042ff3fd017cfba099def4d6213dfeaa5b525b39f7b86730647205344f6a8fe
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.2
|
@@ -4,6 +4,8 @@ module TableauRestApi
|
|
4
4
|
# See the Request sub-class for resource requests.
|
5
5
|
class Client
|
6
6
|
attr_reader :config, :token
|
7
|
+
|
8
|
+
include TableauRestApi::Pagination
|
7
9
|
|
8
10
|
def initialize
|
9
11
|
@config = Config.new.options
|
@@ -39,9 +41,10 @@ module TableauRestApi
|
|
39
41
|
head = boundary ? head.merge({ :content_type => "multipart/mixed; boundary=#{boundary}"}) : head
|
40
42
|
end
|
41
43
|
|
42
|
-
def build_url(endpoint)
|
44
|
+
def build_url(endpoint, page=nil)
|
43
45
|
endpoint = endpoint.is_a?(Array) ? endpoint.join('/') : endpoint
|
44
|
-
"#{@config[:host]}/#{@config[:base]}/#{@config[:api_version]}/#{endpoint}"
|
46
|
+
url = "#{@config[:host]}/#{@config[:base]}/#{@config[:api_version]}/#{endpoint}"
|
47
|
+
url = page ? url + "?pageNumber=#{page}" : url
|
45
48
|
end
|
46
49
|
|
47
50
|
def get(url)
|
@@ -60,6 +63,6 @@ module TableauRestApi
|
|
60
63
|
|
61
64
|
def delete(url)
|
62
65
|
Response.new(RestClient.delete(url, header)).parse
|
63
|
-
end
|
64
|
-
|
66
|
+
end
|
67
|
+
end
|
65
68
|
end
|
@@ -19,8 +19,9 @@ module TableauRestApi
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def sites
|
22
|
-
|
23
|
-
|
22
|
+
resp = get build_url('sites')
|
23
|
+
sites = extract_sites(resp)
|
24
|
+
sites = retrieve_additional_pages(resp, sites, 'sites', :extract_sites)
|
24
25
|
end
|
25
26
|
|
26
27
|
def create_site(site)
|
@@ -38,5 +39,11 @@ module TableauRestApi
|
|
38
39
|
delete url
|
39
40
|
@token = nil
|
40
41
|
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def extract_sites(response)
|
46
|
+
response.sites.site.to_a.map { |site| Site.new(site, self) }
|
47
|
+
end
|
41
48
|
end
|
42
49
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module TableauRestApi
|
2
|
+
module Pagination
|
3
|
+
def complete?(response)
|
4
|
+
pagination = response.pagination
|
5
|
+
pagination ? paginate(pagination) : true
|
6
|
+
end
|
7
|
+
|
8
|
+
def paginate(pagination)
|
9
|
+
read_pagination_header(pagination)
|
10
|
+
return has_multiple_pages? if first_page
|
11
|
+
@total % ((@page) * @per_page) == @total
|
12
|
+
end
|
13
|
+
|
14
|
+
def first_page
|
15
|
+
@page == 0
|
16
|
+
end
|
17
|
+
|
18
|
+
def has_multiple_pages?
|
19
|
+
@total > @per_page ? false : true
|
20
|
+
end
|
21
|
+
|
22
|
+
def read_pagination_header(pagination)
|
23
|
+
@page = pagination.pageNumber.to_i
|
24
|
+
@per_page = pagination.pageSize.to_i
|
25
|
+
@total = pagination.totalAvailable.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
def next_page
|
29
|
+
@page + 1
|
30
|
+
end
|
31
|
+
|
32
|
+
def retrieve_additional_pages(response, collection, entity, extract)
|
33
|
+
until complete?(response) do
|
34
|
+
response = (get build_url(entity, next_page))
|
35
|
+
collection = collection + self.send(extract, response)
|
36
|
+
end
|
37
|
+
collection
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/tableau_rest_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tableau_rest_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Lancaster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,6 +129,8 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".ruby-version"
|
132
134
|
- Gemfile
|
133
135
|
- Guardfile
|
134
136
|
- LICENSE.txt
|
@@ -190,6 +192,7 @@ files:
|
|
190
192
|
- lib/tableau_rest_api/resources/user.rb
|
191
193
|
- lib/tableau_rest_api/resources/workbook.rb
|
192
194
|
- lib/tableau_rest_api/util/config.rb
|
195
|
+
- lib/tableau_rest_api/util/pagination.rb
|
193
196
|
- lib/tableau_rest_api/util/response.rb
|
194
197
|
- lib/tableau_rest_api/util/token.rb
|
195
198
|
- lib/tableau_rest_api/util/upload.rb
|
@@ -215,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
218
|
version: '0'
|
216
219
|
requirements: []
|
217
220
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.6.13
|
219
222
|
signing_key:
|
220
223
|
specification_version: 4
|
221
224
|
summary: Ruby library wrapping the Tableau REST API.
|