Class: TableauServerClient::Resources::User

Inherits:
Resource
  • Object
show all
Defined in:
lib/tableau_server_client/resources/user.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, #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

#external_auth_user_idObject (readonly)

Returns the value of attribute external_auth_user_id.



8
9
10
# File 'lib/tableau_server_client/resources/user.rb', line 8

def external_auth_user_id
  @external_auth_user_id
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



8
9
10
# File 'lib/tableau_server_client/resources/user.rb', line 8

def full_name
  @full_name
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/tableau_server_client/resources/user.rb', line 8

def id
  @id
end

#last_loginObject (readonly)

Returns the value of attribute last_login.



8
9
10
# File 'lib/tableau_server_client/resources/user.rb', line 8

def 
  @last_login
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/tableau_server_client/resources/user.rb', line 8

def name
  @name
end

#site_roleObject (readonly)

Returns the value of attribute site_role.



8
9
10
# File 'lib/tableau_server_client/resources/user.rb', line 8

def site_role
  @site_role
end

Class Method Details

.from_collection_response(client, path, xml) ⇒ Object



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

def self.from_collection_response(client, path, xml)
  xml.xpath("//xmlns:users/xmlns:user").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/user.rb', line 10

def self.from_response(client, path, xml)
  attrs = extract_attributes(xml)
  new(client, path, attrs)
end

Instance Method Details

#datasourcesObject



36
37
38
39
40
# File 'lib/tableau_server_client/resources/user.rb', line 36

def datasources
  @client.get_collection(Datasource.location(site_path, filter: ["ownerName:eq:#{full_name}"])).select do |d|
    d.owner.id == id
  end
end

#locationObject



55
56
57
# File 'lib/tableau_server_client/resources/user.rb', line 55

def location
  User.location(site_path, id)
end

#reloadObject



22
23
24
# File 'lib/tableau_server_client/resources/user.rb', line 22

def reload
  @client.get location
end

#to_requestObject



42
43
44
45
46
# File 'lib/tableau_server_client/resources/user.rb', line 42

def to_request
  request = build_request {|b|
    b.user(siteRole: site_role)
  }
end

#update_site_role!(role) ⇒ Object



48
49
50
51
52
53
# File 'lib/tableau_server_client/resources/user.rb', line 48

def update_site_role!(role)
  @site_role = role
  # Using location to get corretct path
  # When initialized from Group path will be groups/group_id/users/user_id
  @client.update(self, path: location.path)
end

#workbooksObject



30
31
32
33
34
# File 'lib/tableau_server_client/resources/user.rb', line 30

def workbooks
  @client.get_collection(Workbook.location(site_path, filter: ["ownerName:eq:#{full_name}"])).select do |w|
    w.owner.id == id
  end
end