Skip to content

Latest commit

 

History

History
115 lines (77 loc) · 2.69 KB

README.md

File metadata and controls

115 lines (77 loc) · 2.69 KB

TableauRuby

Unofficial Tableau API Ruby client

Installation

Add this line to your application's Gemfile:

gem 'tableau_ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tableau_ruby

Usage

Setup

require 'rubygems'
require 'tableau_ruby'

Tableau.configure do |config|
	# Required
	config.host = 'https://your-url-here.com'
	config.admin_name = 'your-admin-username'
	config.admin_password = 'your-admin-password'
	# Optional
	config.user_name = 'user-to-act-on-behalf-of'
	config.site_name = 'defaults-to-Default'
end

@client = Tableau::Client.new

# Alternatively pass the information as a hash

@client = Tableau::Client.new(
	host: 'https://your-url-here.com',
	admin_name: 'your-admin-password',
	admin_password: 'your-admin-password'
)

@site = JSON.parse(@client.sites.find_by(name: 'Default'))['site']

@user = Tableau::User.new(@client, JSON.parse(@client.users.find_by(site_id: @site['id'], name: 'user-name'))['user'])
@user.workbooks

Sites

# By default the all request does not include projects in the results
# add them by including include_projects: true
@sites = client.sites.all(include_projects: true)

@site = client.sites.find_by(id: 'site-id') # also try :name and :url
@site = client.sites.create(name: 'Site Name')
@site = client.sites.update(id: 'site-id')
@site = client.sites.delete(id: 'site-id')

Projects

@projects = @client.projects.all()

@project = client.projects.create(name: 'Project Name', site_id: 'project-site-id')
@project = client.projects.update(id: 'project-id', site_id: 'project-site-id')
@project = client.projects.delete(id: 'project-id', site_id: 'project-site-id')

Users

@users = client.users.all(site_id: 'site-id')

@user = client.users.find_by(name: 'user-name', site_id: 'site-id')
@user = client.users.create(name: 'new user', site_id: 'site-id')
@user = client.users.delete(id: 'user-id', site_id: 'site-id')

Workbooks

@workbooks = client.workbooks.all(site_id: 'site-id')

@workbook = client.workbooks.find(id: 'workbook-id', site_id: 'site-id', include_views: true)

@workbook_image = client.workbooks.preview_image(id: 'workbook-id', site_id: 'site-id') # returns the binary image data.

TODO

  • inherit site_id from client object to avoid having to pass site_id
  • consolidate parameter checking
  • error responses
  • make self documenting

Contributing

  1. Fork it ( https://github.com/[my-github-username]/tableau_ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request