tableau_api 2.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4798e618f0d34f889de213df1639f637bd10725
4
- data.tar.gz: 101be1cca96ab9cb21fd6061f557ea2d718ac8a7
3
+ metadata.gz: a147139944855ed7147760ceae5d65bcd5f6fb1c
4
+ data.tar.gz: ea08dc0b70183fc30620959fa255e041e6c318ea
5
5
  SHA512:
6
- metadata.gz: 2ebb0f01b35a52a1270cd50dc21dc883d801acfe82dfaa4d0284ab3c47cef1fc61a0c024d02abc9720ac3114852355e105ba711d7b8ff4a926950b5dda7f0bd6
7
- data.tar.gz: 75afe1a966db2064aa0a89c2f0e321e43a701288bba57a1dd8f22f031db2be5e2a699e2a74ad988196517923bbf63f91d71737ff88b61282c7cc2dda54b1f6fa
6
+ metadata.gz: b60cbc7aec82d7a36868faadbe38f775786a67b84c809c2803e384424c877d6c22116b1da652d0634f57d731b0d99a2b3e69123d746499390e7e2a2c34d71a63
7
+ data.tar.gz: f36628abb279e8ca26aee9747a9fafb0ab29e41268b6787e2da9a90d2d4a116d3f18fd7d7ca6557481340a72aaf6a6306cb95f5ce6caf83a4ab274b2df17b994
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.4.10
data/.travis.yml CHANGED
@@ -4,6 +4,6 @@ branches:
4
4
  - master
5
5
  language: ruby
6
6
  rvm:
7
- - 2.6.3
8
- - 2.5.5
9
- - 2.4.1
7
+ - 2.6.6
8
+ - 2.5.8
9
+ - 2.4.10
data/CHANGELOG.md CHANGED
@@ -3,6 +3,42 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## upcoming
7
+
8
+ ### Changed
9
+
10
+ ## [4.1.0] - 2022-04-13
11
+
12
+ - Specify major version number of ruby in Docker testing command in README
13
+ - Add support for CreateRefreshMetrics and RunExplainData workbook capabilities
14
+
15
+ ## [4.0.0] - 2020-11-30
16
+
17
+ ### Changed/Fixed
18
+
19
+ - Changed interface to Connection#api_get_collection to properly merge a string
20
+ query with the pagination parameters instead of overwriting the pagination
21
+ params. This means you can't pass a Hash `query` parameter to `Jobs#list`
22
+ anymore, but job filtering now works properly because colons in the filter
23
+ will not be URL-encoded.
24
+ - Avoid mutating extra argument hash to endpoint methods
25
+
26
+
27
+ ## [3.0.0] - 2020-11-11
28
+
29
+ ### Added
30
+
31
+ - Added Jobs resource
32
+
33
+
34
+ ### Changed
35
+
36
+ - Updated to API version 3.1
37
+ - This is a breaking change for site roles:
38
+ https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_new_site_roles.htm
39
+ - Include full error detail in TableauError message
40
+
41
+
6
42
  ## [2.0.0] - 2019-08-29
7
43
 
8
44
  - Updated to API version 2.8, compatible with Tableau Server >= 10.5
data/README.md CHANGED
@@ -54,7 +54,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
54
54
  ### Docker
55
55
 
56
56
  ```
57
- docker run -it -d -v $(pwd):/src ruby /bin/bash
57
+ docker run -it -d -v $(pwd):/src ruby:2 /bin/bash
58
58
  docker exec -it CONTAINER_ID /bin/bash -c "cd /src && bundle && rake"
59
59
  ```
60
60
 
@@ -62,16 +62,31 @@ docker exec -it CONTAINER_ID /bin/bash -c "cd /src && bundle && rake"
62
62
 
63
63
  Cassettes should be self-contained, generated by a single spec file
64
64
  run in defined order. To make changes to specs, it's best to delete a whole cassette
65
- and rerun the whole spec file.
65
+ and rerun the whole spec file, except for auth.yml, since it could be difficult to
66
+ generate a trusted ticket from a non-trusted host.
66
67
 
67
- Set the environment variables below to an administrator account, create a tunnel
68
- to your tableau server on port 2000, then run the commands below.
68
+ To regenerate all the the cassettes, you'll first need to create the following on the Tableau server:
69
+ * *Site*: Default
70
+ * *Site*: TestSite
71
+ * *Datasource*: test (this might need to be created from Tableau Desktop)
72
+ * *Username*: test_test
73
+
74
+ And delete the following if they exist:
75
+ * *Group*: testgroup (probably under TestSite)
76
+ * *Project*: test_project (probably under Default)
77
+ * *Site*: Test Site 2
78
+ * *User*: test (probably under TestSite)
79
+ * *Workbook*: test
80
+ * *Workbook*: testpublish
81
+
82
+ Set the environment variables below to an administrator account and your Tableau Server hostname.
83
+
84
+ Then run the commands below:
69
85
 
70
86
  ```
71
87
  docker run -it -d \
72
88
  -v $(pwd):/src \
73
- --add-host=docker:$(ifconfig en0 | grep 'inet\b' | cut -d ' ' -f 2) \
74
- -e TABLEAU_HOST='http://docker:2000' -e TABLEAU_ADMIN_USERNAME -e TABLEAU_ADMIN_PASSWORD \
89
+ -e TABLEAU_HOST -e TABLEAU_ADMIN_USERNAME -e TABLEAU_ADMIN_PASSWORD \
75
90
  ruby /bin/bash
76
91
  docker exec -it CONTAINER_ID /bin/bash -c "cd /src && bundle && rake"
77
92
  ```
@@ -29,7 +29,8 @@ module TableauApi
29
29
  users: TableauApi::Resources::Users,
30
30
  groups: TableauApi::Resources::Groups,
31
31
  workbooks: TableauApi::Resources::Workbooks,
32
- datasources: TableauApi::Resources::Datasources
32
+ datasources: TableauApi::Resources::Datasources,
33
+ jobs: TableauApi::Resources::Jobs
33
34
  }
34
35
  end
35
36
 
@@ -1,30 +1,30 @@
1
1
  module TableauApi
2
2
  class Connection
3
- API_VERSION = '2.8'.freeze
3
+ API_VERSION = '3.1'.freeze
4
4
 
5
5
  include HTTParty
6
+ headers 'User-Agent' => "tableau_api/#{::TableauApi::VERSION} Ruby/#{RUBY_VERSION}"
6
7
 
7
8
  def initialize(client)
8
9
  @client = client
9
10
  end
10
11
 
11
- def post(path, *args)
12
- self.class.post("#{@client.host}/#{path}", *args)
12
+ def post(path, **kwargs)
13
+ self.class.post("#{@client.host}/#{path}", kwargs)
13
14
  end
14
15
 
15
16
  # if the result is paginated, it will fetch subsequent pages
16
17
  # collection can be delimited with a period to do nested hash lookups
17
18
  # e.g. objects.object
18
- def api_get_collection(path, collection, *args)
19
+ def api_get_collection(path, collection, page_number: 1, page_size: 100, **kwargs)
19
20
  Enumerator.new do |enum|
20
- args[0] = {} unless args[0]
21
- page_size = (args[0].delete(:page_size) { 100 }).to_i
22
- page_number = (args[0].delete(:page_number) { 1 }).to_i
23
-
24
21
  loop do
25
- uri = URI::HTTP.build(path: "/#{path}", query: URI.encode_www_form(pageSize: page_size, pageNumber: page_number)).request_uri
22
+ query = kwargs.fetch(:query, '')
23
+ query += '&' unless query.empty?
24
+ query += "pageSize=#{page_size}&pageNumber=#{page_number}"
25
+ new_kwargs = kwargs.merge(query: query)
26
26
 
27
- res = api_get(uri, *args)
27
+ res = api_get(path, **new_kwargs)
28
28
  raise TableauError, res if res.code.to_s != '200'
29
29
 
30
30
  # ensure the result is an array because it will not be an array if there is only one element
@@ -40,24 +40,22 @@ module TableauApi
40
40
  end
41
41
  end
42
42
 
43
- def api_get(path, *args)
44
- api_method(:get, path, *args)
43
+ def api_get(path, **kwargs)
44
+ api_method(:get, path, kwargs)
45
45
  end
46
46
 
47
- def api_post(path, *args)
48
- args[0][:headers] = {} unless args[0][:headers]
49
- args[0][:headers]['Content-Type'] = 'application/xml'
50
- api_method(:post, path, *args)
47
+ def api_post(path, **kwargs)
48
+ new_headers = kwargs.fetch(:headers, {}).merge('Content-Type' => 'application/xml')
49
+ api_method(:post, path, kwargs.merge(headers: new_headers))
51
50
  end
52
51
 
53
- def api_put(path, *args)
54
- args[0][:headers] = {} unless args[0][:headers]
55
- args[0][:headers]['Content-Type'] = 'application/xml'
56
- api_method(:put, path, *args)
52
+ def api_put(path, **kwargs)
53
+ new_headers = kwargs.fetch(:headers, {}).merge('Content-Type' => 'application/xml')
54
+ api_method(:put, path, kwargs.merge(headers: new_headers))
57
55
  end
58
56
 
59
- def api_delete(path, *args)
60
- api_method(:delete, path, *args)
57
+ def api_delete(path, **kwargs)
58
+ api_method(:delete, path, kwargs)
61
59
  end
62
60
 
63
61
  def api_post_multipart(path, parts, headers)
@@ -75,14 +73,12 @@ module TableauApi
75
73
 
76
74
  private
77
75
 
78
- def api_method(method, path, *args)
76
+ def api_method(method, path, kwargs)
79
77
  # do not attach auth headers or attempt to signin if we're signing in
80
78
  unless path == 'auth/signin'
81
- args[0] = {} unless args[0]
82
- args[0][:headers] = {} unless args[0][:headers]
83
- args[0][:headers].merge!(auth_headers)
79
+ new_headers = auth_headers(kwargs.fetch(:headers, {}))
84
80
  end
85
- self.class.send(method, url_for(path), *args)
81
+ self.class.public_send(method, url_for(path), kwargs.merge(headers: new_headers))
86
82
  end
87
83
 
88
84
  def url_for(path)
@@ -8,7 +8,7 @@ module TableauApi
8
8
  @error_code = error['code']
9
9
  @summary = error['summary']
10
10
  @detail = error['detail']
11
- super(summary)
11
+ super("#{error_code}: #{summary}; #{detail}")
12
12
  end
13
13
  end
14
14
  end
@@ -0,0 +1,10 @@
1
+ module TableauApi
2
+ module Resources
3
+ class Jobs < Base
4
+ def list(params = {})
5
+ url = "sites/#{@client.auth.site_id}/jobs"
6
+ @client.connection.api_get_collection(url, 'backgroundJobs.backgroundJob', **params)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -2,13 +2,14 @@ module TableauApi
2
2
  module Resources
3
3
  class Users < Base
4
4
  SITE_ROLES = %w[
5
- Interactor
6
- Publisher
7
- SiteAdministrator
5
+ Creator
6
+ Explorer
7
+ ExplorerCanPublish
8
+ SiteAdministratorCreator
9
+ SiteAdministratorExplorer
10
+ ServerAdministrator
8
11
  Unlicensed
9
- UnlicensedWithPublish
10
12
  Viewer
11
- ViewerWithPublish
12
13
  ].freeze
13
14
 
14
15
  def create(username:, site_role: 'Viewer')
@@ -49,8 +49,8 @@ module TableauApi
49
49
  # rubocop:enable Metrics/ParameterLists
50
50
 
51
51
  CAPABILITIES = %w[
52
- AddComment ChangeHierarchy ChangePermissions Delete ExportData ExportImage ExportXml
53
- Filter Read ShareView ViewComments ViewUnderlyingData WebAuthoring Write
52
+ AddComment ChangeHierarchy ChangePermissions CreateRefreshMetrics Delete ExportData ExportImage
53
+ ExportXml Filter Read RunExplainData ShareView ViewComments ViewUnderlyingData WebAuthoring Write
54
54
  ].freeze
55
55
 
56
56
  CAPABILITY_MODES = %w[ALLOW DENY].freeze
@@ -1,3 +1,3 @@
1
1
  module TableauApi
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '4.1.0'.freeze
3
3
  end
data/lib/tableau_api.rb CHANGED
@@ -2,6 +2,8 @@ require 'httparty'
2
2
  require 'builder'
3
3
  require 'net/http/post/multipart'
4
4
 
5
+ require 'tableau_api/version'
6
+
5
7
  require 'tableau_api/client'
6
8
  require 'tableau_api/connection'
7
9
  require 'tableau_api/error'
@@ -13,7 +15,7 @@ require 'tableau_api/resources/users'
13
15
  require 'tableau_api/resources/groups'
14
16
  require 'tableau_api/resources/workbooks'
15
17
  require 'tableau_api/resources/datasources'
16
- require 'tableau_api/version'
18
+ require 'tableau_api/resources/jobs'
17
19
 
18
20
  module TableauApi
19
21
  class << self
data/tableau_api.gemspec CHANGED
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'multipart-post', '~> 2.0'
27
27
  spec.add_dependency 'rubyzip', '~> 1.0'
28
28
 
29
- spec.add_development_dependency 'bundler', '~> 1.12'
30
29
  spec.add_development_dependency 'rake', '~> 11.0'
31
30
  spec.add_development_dependency 'rspec', '~> 3.6'
32
31
  spec.add_development_dependency 'vcr', '~> 3.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tableau_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Manning
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-08-30 00:00:00.000000000 Z
13
+ date: 2022-04-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -68,20 +68,6 @@ dependencies:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '1.0'
71
- - !ruby/object:Gem::Dependency
72
- name: bundler
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '1.12'
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - "~>"
83
- - !ruby/object:Gem::Version
84
- version: '1.12'
85
71
  - !ruby/object:Gem::Dependency
86
72
  name: rake
87
73
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +209,7 @@ files:
223
209
  - lib/tableau_api/resources/base.rb
224
210
  - lib/tableau_api/resources/datasources.rb
225
211
  - lib/tableau_api/resources/groups.rb
212
+ - lib/tableau_api/resources/jobs.rb
226
213
  - lib/tableau_api/resources/projects.rb
227
214
  - lib/tableau_api/resources/sites.rb
228
215
  - lib/tableau_api/resources/users.rb
@@ -249,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
236
  version: '0'
250
237
  requirements: []
251
238
  rubyforge_project:
252
- rubygems_version: 2.5.2.3
239
+ rubygems_version: 2.6.14.4
253
240
  signing_key:
254
241
  specification_version: 4
255
242
  summary: Ruby interface to the Tableau API.