Class: TableauServerClient::Resources::Datasource

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

Defined Under Namespace

Classes: DatasourceContent

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, #server_url, #site_id, #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.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def content_url
  @content_url
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def id
  @id
end

#is_certifiedObject (readonly)

Returns the value of attribute is_certified.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def is_certified
  @is_certified
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def name
  @name
end

#ownerObject



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

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

#owner_idObject (readonly)

Returns the value of attribute owner_id.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def owner_id
  @owner_id
end

#project_idObject (readonly)

Returns the value of attribute project_id.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def project_id
  @project_id
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def type
  @type
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def updated_at
  @updated_at
end

#webpage_urlObject (readonly)

Returns the value of attribute webpage_url.



12
13
14
# File 'lib/tableau_server_client/resources/datasource.rb', line 12

def webpage_url
  @webpage_url
end

Class Method Details

.from_collection_response(client, path, xml) ⇒ Object



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

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

.from_response(client, path, xml) ⇒ Object



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

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']
  #TODO add owner
  new(client, path, attrs)
end

Instance Method Details

#connectionsObject



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

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

#contentObject



54
55
56
# File 'lib/tableau_server_client/resources/datasource.rb', line 54

def content
  DatasourceContent.new(download.xpath('//datasource').first)
end

#projectObject



34
35
36
# File 'lib/tableau_server_client/resources/datasource.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
# File 'lib/tableau_server_client/resources/datasource.rb', line 42

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

#update!Object



50
51
52
# File 'lib/tableau_server_client/resources/datasource.rb', line 50

def update!
  @client.update self
end