Class: TableauServerClient::Resources::Subscription

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

Methods included from TableauServerClient::RequestBuilder

#build_request

Constructor Details

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#subjectObject (readonly)

Returns the value of attribute subject.



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

def subject
  @subject
end

Class Method Details

.from_collection_response(client, path, xml) ⇒ Object



18
19
20
21
22
23
# File 'lib/tableau_server_client/resources/subscription.rb', line 18

def self.from_collection_response(client, path, xml)
  xml.xpath("//xmlns:subscriptions/xmlns:subscription").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
14
15
16
# File 'lib/tableau_server_client/resources/subscription.rb', line 10

def self.from_response(client, path, xml)
  attrs = extract_attributes(xml)
  attrs['content_id'] = xml.xpath("xmlns:content")[0]['id']
  attrs['schedule_id'] = xml.xpath("xmlns:schedule")[0]['id']
  attrs['user_id']   = xml.xpath("xmlns:user")[0]['id']
  new(client, path, attrs)
end

Instance Method Details

#contentObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/tableau_server_client/resources/subscription.rb', line 25

def content
  raise NotImplementedError
end

#scheduleObject



29
30
31
# File 'lib/tableau_server_client/resources/subscription.rb', line 29

def schedule
  @schedule ||= @client.get_collection(Schedule.location(nil)).find {|s| s.id == @schedule_id }
end

#userObject



33
34
35
# File 'lib/tableau_server_client/resources/subscription.rb', line 33

def user
  @user ||= @client.get User.location(site_path, @user_id)
end