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, #site_path
#build_request
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
8
9
10
|
# File 'lib/tableau_server_client/resources/project.rb', line 8
def description
@description
end
|
#id ⇒ Object
Returns the value of attribute id.
8
9
10
|
# File 'lib/tableau_server_client/resources/project.rb', line 8
def id
@id
end
|
#name ⇒ Object
Returns the value of attribute name.
8
9
10
|
# File 'lib/tableau_server_client/resources/project.rb', line 8
def name
@name
end
|
#parent_project_id ⇒ Object
Returns the value of attribute parent_project_id.
8
9
10
|
# File 'lib/tableau_server_client/resources/project.rb', line 8
def parent_project_id
@parent_project_id
end
|
Class Method Details
.from_collection_response(client, path, xml) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/tableau_server_client/resources/project.rb', line 15
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
10
11
12
13
|
# File 'lib/tableau_server_client/resources/project.rb', line 10
def self.from_response(client, path, xml)
attrs = (xml)
new(client, path, attrs)
end
|
Instance Method Details
67
68
69
|
# File 'lib/tableau_server_client/resources/project.rb', line 67
def (key)
[key]
end
|
62
63
64
65
|
# File 'lib/tableau_server_client/resources/project.rb', line 62
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
58
59
60
|
# File 'lib/tableau_server_client/resources/project.rb', line 58
def hierarchy
(parent_projects << self).map {|p| p.name }.join('/')
end
|
#parent_projects ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/tableau_server_client/resources/project.rb', line 41
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
27
28
29
30
31
|
# File 'lib/tableau_server_client/resources/project.rb', line 27
def redshift_username
if md = description.match(/^REDSHIFT_USERNAME: (.+)$/)
return md[1]
end
end
|
#reload ⇒ Object
22
23
24
25
|
# File 'lib/tableau_server_client/resources/project.rb', line 22
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
37
38
39
|
# File 'lib/tableau_server_client/resources/project.rb', line 37
def root_project
parent_projects[0] || self
end
|
#root_project? ⇒ Boolean
33
34
35
|
# File 'lib/tableau_server_client/resources/project.rb', line 33
def root_project?
self.parent_project_id.nil?
end
|