Class: TableauServerClient::Resources::Workbook

Inherits:
Resource
  • Object
show all
Includes:
Downloadable
Defined in:
lib/tableau_server_client/resources/workbook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Downloadable

#download

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

Methods included from TableauServerClient::RequestBuilder

#build_request

Constructor Details

This class inherits a constructor from TableauServerClient::Resources::Resource

Instance Attribute Details

#content_urlObject (readonly)

Returns the value of attribute content_url.



13
14
15
# File 'lib/tableau_server_client/resources/workbook.rb', line 13

def content_url
  @content_url
end

#created_atObject (readonly)

Returns the value of attribute created_at.



13
14
15
# File 'lib/tableau_server_client/resources/workbook.rb', line 13

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/tableau_server_client/resources/workbook.rb', line 13

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/tableau_server_client/resources/workbook.rb', line 13

def name
  @name
end

#ownerObject



38
39
40
# File 'lib/tableau_server_client/resources/workbook.rb', line 38

def owner
  @owner ||= @client.get User.location(site_path, @owner_id)
end

#show_tabsObject (readonly)

Returns the value of attribute show_tabs.



13
14
15
# File 'lib/tableau_server_client/resources/workbook.rb', line 13

def show_tabs
  @show_tabs
end

#sizeObject (readonly)

Returns the value of attribute size.



13
14
15
# File 'lib/tableau_server_client/resources/workbook.rb', line 13

def size
  @size
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



13
14
15
# File 'lib/tableau_server_client/resources/workbook.rb', line 13

def updated_at
  @updated_at
end

Class Method Details

.from_collection_response(client, path, xml) ⇒ Object



23
24
25
26
27
28
# File 'lib/tableau_server_client/resources/workbook.rb', line 23

def self.from_collection_response(client, path, xml)
  xml.xpath("//xmlns:workbooks/xmlns:workbook").each do |s|
    id = s['id']
    yield from_response(client, "#{path}/#{id}", s)
  end
end

.from_response(client, path, xml) ⇒ Object



16
17
18
19
20
21
# File 'lib/tableau_server_client/resources/workbook.rb', line 16

def self.from_response(client, path, xml)
  attrs = extract_attributes(xml)
  attrs['project_id'] = xml.xpath("xmlns:project")[0]['id']
  attrs['owner_id']   = xml.xpath("xmlns:owner")[0]['id']
  new(client, path, attrs)
end

Instance Method Details

#connectionsObject



30
31
32
# File 'lib/tableau_server_client/resources/workbook.rb', line 30

def connections
  @client.get_collection Connection.location(path)
end

#embedded_datasourcesObject



55
56
57
58
59
# File 'lib/tableau_server_client/resources/workbook.rb', line 55

def embedded_datasources
  download.xpath('//datasources//datasource').map do |ds|
    Datasource::DatasourceContent.new(ds)
  end
end

#projectObject



34
35
36
# File 'lib/tableau_server_client/resources/workbook.rb', line 34

def project
  @project ||= @client.get_collection(Project.location(site_path)).find {|p| p.id == @project_id }
end

#to_requestObject



42
43
44
45
46
47
48
49
# File 'lib/tableau_server_client/resources/workbook.rb', line 42

def to_request
  request = build_request {|b|
    b.workbook {|w|
      w.owner(id: owner.id)
    }
  }
  request
end

#update!Object



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

def update!
  @client.update self
end