Class: TableauServerClient::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/tableau_server_client/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_url, username, password, content_url: "", api_version: "3.1", token_lifetime: 240, log_level: :info, impersonation_username: nil) ⇒ Server

Implement for_token def for_token(token)



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tableau_server_client/server.rb', line 13

def initialize(server_url, username, password,
               content_url: "", api_version: "3.1", token_lifetime: 240,
               log_level: :info, impersonation_username: nil)
  @server_url = server_url
  @username = username
  @password = password
  @content_url = content_url
  @api_version = api_version
  @token_lifetime = token_lifetime
  @logger = ::Logger.new(STDOUT)
  @logger.level = ::Logger.const_get(log_level.upcase.to_sym)
  @impersonation_username = impersonation_username
end

Instance Attribute Details

#api_versionObject (readonly)

Returns the value of attribute api_version.



27
28
29
# File 'lib/tableau_server_client/server.rb', line 27

def api_version
  @api_version
end

#content_urlObject (readonly)

Returns the value of attribute content_url.



27
28
29
# File 'lib/tableau_server_client/server.rb', line 27

def content_url
  @content_url
end

#impersonation_usernameObject (readonly)

Returns the value of attribute impersonation_username.



27
28
29
# File 'lib/tableau_server_client/server.rb', line 27

def impersonation_username
  @impersonation_username
end

#loggerObject (readonly)

Returns the value of attribute logger.



27
28
29
# File 'lib/tableau_server_client/server.rb', line 27

def logger
  @logger
end

#server_urlObject (readonly)

Returns the value of attribute server_url.



27
28
29
# File 'lib/tableau_server_client/server.rb', line 27

def server_url
  @server_url
end

#token_lifetimeObject (readonly)

Returns the value of attribute token_lifetime.



27
28
29
# File 'lib/tableau_server_client/server.rb', line 27

def token_lifetime
  @token_lifetime
end

#usernameObject (readonly)

Returns the value of attribute username.



27
28
29
# File 'lib/tableau_server_client/server.rb', line 27

def username
  @username
end

Instance Method Details

#full_site(id) ⇒ Object



43
44
45
# File 'lib/tableau_server_client/server.rb', line 43

def full_site(id)
  client_for_site(client.get(Resources::Site.location(path, id)).content_url).get Resources::Site.location(path, id)
end

#pathObject



51
52
53
# File 'lib/tableau_server_client/server.rb', line 51

def path
  nil
end

#schedulesObject



47
48
49
# File 'lib/tableau_server_client/server.rb', line 47

def schedules
  client.get_collection Resources::Schedule.location(path)
end

#site(id) ⇒ Object



35
36
37
# File 'lib/tableau_server_client/server.rb', line 35

def site(id)
  sites.select { |s| s.id == id }.first
end

#site_by_name(site_name) ⇒ Object



39
40
41
# File 'lib/tableau_server_client/server.rb', line 39

def site_by_name(site_name)
  sites.select { |s| s.name == site_name }.first
end

#sitesObject



29
30
31
32
33
# File 'lib/tableau_server_client/server.rb', line 29

def sites
  client.get_collection(Resources::Site.location(path)).map {|s|
    client_for_site(s.content_url).get_collection(Resources::Site.location(path)).select {|x| x.id == s.id }.first
  }
end