class TableauServerClient::Resources::Project

Attributes

description[R]
id[R]
name[R]
parent_project_id[R]

Public Class Methods

from_collection_response(client, path, xml) { |from_response(client, "#{path}/#{id}", s)| ... } click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 16
def self.from_collection_response(client, path, xml)
  xml.xpath("//xmlns:projects/xmlns:project").each do |s|
    id = s['id']
    yield from_response(client, "#{path}/#{id}", s)
  end
end
from_response(client, path, xml) click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 11
def self.from_response(client, path, xml)
  attrs = extract_attributes(xml)
  new(client, path, attrs)
end

Public Instance Methods

extract_value_in_description(key) click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 74
def extract_value_in_description(key)
  extract_values_in_description[key]
end
extract_values_in_description() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 69
def extract_values_in_description
  @values_in_description ||=\
    description.lines.map { |l|/^(.*):\s*(.*)$/.match(l) }.reject { |m| m.nil? }.map { |m| m[1,2] }.to_h
end
hierarchy() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 59
def hierarchy
  @hierarchy ||= (parent_projects << self).map {|p| p.name }.join('/')
end
parent_projects() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 42
def parent_projects
  return @parent_projects if @parent_projects
  @parent_projects = []
  curr_pj = self
  pjs = @client.get_collection Project.location(site_path)
  while ! curr_pj.root_project?
    pjs.each do |pj|
      if pj.id == curr_pj.parent_project_id
        @parent_projects.unshift pj
        curr_pj = pj
        break
      end
    end
  end
  return @parent_projects
end
redshift_username() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 28
def redshift_username
  if md = description.match(/^REDSHIFT_USERNAME: (.+)$/)
    return md[1]
  end
end
reload() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 23
def reload
  prjs = @client.get_collection Project.location(site_path, filter: ["name:eq:#{name}"])
  prjs.select {|p| p.id == id }.first
end
root_project() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 38
def root_project
  parent_projects[0] || self
end
root_project?() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 34
def root_project?
  self.parent_project_id.nil?
end
workbooks() click to toggle source
# File lib/tableau_server_client/resources/project.rb, line 63
def workbooks
  @client.get_collection(Workbook.location(site_path, filter: [])).select {|w|
    w.project_id == id
  }
end