tableau_api 3.0.0 → 4.0.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: 32337332fcbfbd3e1df178024ad0eb90c64ba347
4
- data.tar.gz: 1acad5975fe2d1e33637e0d7092415697d0db997
3
+ metadata.gz: ab171fa9db1acc1d2baa0134e86df90f9fabae6c
4
+ data.tar.gz: 7ade53d8f0ed080241ddc2f37810a0e29193773c
5
5
  SHA512:
6
- metadata.gz: a2685533571a39906bc593726395b3555123b7ceee2e2921ed3d614938873d9b03777e7b20f215180999e2e2af25064004b575ed5793bb2dd53710bf31a5062c
7
- data.tar.gz: 91f5141706ffff117ec5fd6c4643b00066d17a19e69c2f895256b6c4f33fd7dc6e2f4c8e7c22d672f185ec60af27ed0ccd720767060f3d1c6020cf7fc4e3b50f
6
+ metadata.gz: a15d7705a00c982b44d3b3ceb47eae9231440a77acb8af470df74dcb95baa28f1375c8479bce2eb778d4f83c99003230180b345cfdc30f74326f54ecb3955006
7
+ data.tar.gz: 4523b88ddaf739fa6064b428a2c555ea533bb93d6d65e70280182d362144a0b05da0c87a42294170574c12b045edca33a2e9fae2e0db13abf7ae74062b9b5f09
@@ -1 +1 @@
1
- 2.4.9
1
+ 2.4.10
@@ -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
@@ -3,7 +3,19 @@
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
- ## [3.0.0] -
6
+ ## [4.0.0] - 2020-11-30
7
+
8
+ ### Changed/Fixed
9
+
10
+ - Changed interface to Connection#api_get_collection to properly merge a string
11
+ query with the pagination parameters instead of overwriting the pagination
12
+ params. This means you can't pass a Hash `query` parameter to `Jobs#list`
13
+ anymore, but job filtering now works properly because colons in the filter
14
+ will not be URL-encoded.
15
+ - Avoid mutating extra argument hash to endpoint methods
16
+
17
+
18
+ ## [3.0.0] - 2020-11-11
7
19
 
8
20
  ### Added
9
21
 
data/README.md CHANGED
@@ -68,7 +68,7 @@ generate a trusted ticket from a non-trusted host.
68
68
  To regenerate all the the cassettes, you'll first need to create the following on the Tableau server:
69
69
  * *Site*: Default
70
70
  * *Site*: TestSite
71
- * *Datasource*: test
71
+ * *Datasource*: test (this might need to be created from Tableau Desktop)
72
72
  * *Username*: test_test
73
73
 
74
74
  And delete the following if they exist:
@@ -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'
@@ -14,7 +16,6 @@ require 'tableau_api/resources/groups'
14
16
  require 'tableau_api/resources/workbooks'
15
17
  require 'tableau_api/resources/datasources'
16
18
  require 'tableau_api/resources/jobs'
17
- require 'tableau_api/version'
18
19
 
19
20
  module TableauApi
20
21
  class << self
@@ -3,28 +3,28 @@ module TableauApi
3
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(**args[0], 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)
@@ -1,9 +1,9 @@
1
1
  module TableauApi
2
2
  module Resources
3
3
  class Jobs < Base
4
- def list(kwargs = {})
4
+ def list(params = {})
5
5
  url = "sites/#{@client.auth.site_id}/jobs"
6
- @client.connection.api_get_collection(url, 'backgroundJobs.backgroundJob', **kwargs)
6
+ @client.connection.api_get_collection(url, 'backgroundJobs.backgroundJob', **params)
7
7
  end
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module TableauApi
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
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: 3.0.0
4
+ version: 4.0.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: 2020-11-11 00:00:00.000000000 Z
13
+ date: 2020-12-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty