GithubHelp home page GithubHelp logo

clj-tableau's Introduction

clj-tableau

A Clojure library designed to interact with Tableau APIs including Data Extract API, REST Server API and the undocumented Web Service API.

Build Status

Installation

clj-tableau is available as a Maven artifact from Clojars:

Clojars Project

clj-tableau supports clojure 1.6.0 and higher.

To use tableau extract API you should download and manually put the dependent jar files (dataextract.jar and jna.jar) to the /resources folder. Please make sure that the TDE library binaries are included in the PATH environment variable.

Usage

Data Extract API

The TDE related functionality is provided by the clj-tableau.dataextract namespace.

First, require it in the REPL:

(require '[clj-tableau.dataextract :refer :all])

Or in your application:

(ns my-app.core
  (:require [clj-tableau.dataextract :refer :all]))

Opening or creating a TDE file:

(with-extract [tdefile "myfile.tde"]
  <yourcode>
)

tdefile handle will be closed when you leave the closure. To create a new table inside tdefile and add two rows in it:

; define table structure
(def mytable-def
  ; collation can be omitted
  ;
  { :collation Collation/EN_GB
    :columns [ :foo Type/String
               :bar Type/Integer]})

(with-extract [tdefile "myfile.tde"]
  (->
    ; open or create new table in tde file
    ; if tde exists, mytable-def parameter
    ; is not required
    (table tdefile "Extract" mytable-def)
    ; add-rows take table + sequence of vectors
    ; with column values
    (add-rows '(["first" 1] ["second" 2]))))

You can add lines one-by-one with add-row or pass (lazy) sequences to add-rows function. Row should be vec with same number of elements as defined columns in extract table.

If you append rows to an existing TDE file then the table definition parameter of table function can be omitted.

Rest & Web Servie API

REST API support is a new addition to clj-tableau. Our implementation uses the clj-http and data.xml clojure libraries. This new namespace allows to query site, group & user related information supplied by Tableau Server.

The first step is to require the namespace in our REPL:

(require '[clj-tableau.restapi :refer :all])

You have two options for logging onto your desired Tableau Server:

Using logon-to-server:
(logon-to-server "http://tableau-server.com" "TestSite" "JohnDoe" "secret")
Using with-tableau-rest-api
(with-tableau-rest-api [sess ["http://tableau-server.com" "TestSite" "JohnDoe" "secret"]]
                         (->>
                           (get-users-on-site sess)))

Most of the functions require you to pass an existing session. For example if you would like to know the list of groups on the server then all you need to do is:

(get-groups-on-site (logon-to-server "http://tableau-server.com" "TestSite" "JohnDoe" "secret"))

The same goes for listing all users on the site:

(get-users-on-site (logon-to-server "http://tableau-server.com" "TestSite" "JohnDoe" "secret"))

For a full list of available functions please refer to:

  • logon-to-server
  • signout
  • with-tableau-rest-api
  • update-user
  • add-user
  • delete-user-from-site
  • get-users-on-site
  • get-users-from-group
  • get-groups-on-site
  • get-group-id
  • add-user-to-tableau-group
  • remove-user-from-tableau-group
  • query-user-on-site

Examples

Example codes are located under /doc folder.

License

Copyright © 2015 Tamas Foldi (@tfoldi), Starschema Ltd.

Distributed under BSD License.

clj-tableau's People

Contributors

rolandvarga avatar tfoldi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clj-tableau's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.