Class: TableauServerClient::Resources::Project
- Inherits:
-
Resource
- Object
- Resource
- TableauServerClient::Resources::Project
show all
- Defined in:
- lib/tableau_server_client/resources/project.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
attr_reader, attributes, #attributes, #delete!, extract_attributes, extract_site_path, #initialize, location, #location, #path, plural_resource_name, resource_name, #server_url, #site_id, #site_path
#build_request
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
9
10
11
|
# File 'lib/tableau_server_client/resources/project.rb', line 9
def description
@description
end
|
#id ⇒ Object
Returns the value of attribute id.
9
10
11
|
# File 'lib/tableau_server_client/resources/project.rb', line 9
def id
@id
end
|
#name ⇒ Object
Returns the value of attribute name.
9
10
11
|
# File 'lib/tableau_server_client/resources/project.rb', line 9
def name
@name
end
|
#parent_project_id ⇒ Object
Returns the value of attribute parent_project_id.
9
10
11
|
# File 'lib/tableau_server_client/resources/project.rb', line 9
def parent_project_id
@parent_project_id
end
|
Class Method Details
.from_collection_response(client, path, xml) ⇒ Object
16
17
18
19
20
21
|
# 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) ⇒ Object
11
12
13
14
|
# File 'lib/tableau_server_client/resources/project.rb', line 11
def self.from_response(client, path, xml)
attrs = (xml)
new(client, path, attrs)
end
|
Instance Method Details
74
75
76
|
# File 'lib/tableau_server_client/resources/project.rb', line 74
def (key)
[key]
end
|
69
70
71
72
|
# File 'lib/tableau_server_client/resources/project.rb', line 69
def
@values_in_description ||=\
description.lines.map { |l|/^(.*):\s*(.*)$/.match(l) }.reject { |m| m.nil? }.map { |m| m[1,2] }.to_h
end
|
#hierarchy ⇒ Object
59
60
61
|
# File 'lib/tableau_server_client/resources/project.rb', line 59
def hierarchy
@hierarchy ||= (parent_projects << self).map {|p| p.name }.join('/')
end
|
#parent_projects ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# 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 ⇒ Object
28
29
30
31
32
|
# 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 ⇒ Object
23
24
25
26
|
# 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 ⇒ Object
38
39
40
|
# File 'lib/tableau_server_client/resources/project.rb', line 38
def root_project
parent_projects[0] || self
end
|
#root_project? ⇒ Boolean
34
35
36
|
# File 'lib/tableau_server_client/resources/project.rb', line 34
def root_project?
self.parent_project_id.nil?
end
|
#workbooks ⇒ Object
63
64
65
66
67
|
# 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
|