Class: Superset::Dashboard::Embedded::Get

Inherits:
Request
  • Object
show all
Defined in:
lib/superset/dashboard/embedded/get.rb

Constant Summary

Constants inherited from Request

Request::PAGE_SIZE

Instance Attribute Summary collapse

Attributes inherited from Request

#page_num

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#query_params, #superset_host

Methods included from Superset::Display

#display_headers, #headings, #rows, #table

Constructor Details

#initialize(id) ⇒ Get

Returns a new instance of Get.



11
12
13
# File 'lib/superset/dashboard/embedded/get.rb', line 11

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

dashboard id



5
6
7
# File 'lib/superset/dashboard/embedded/get.rb', line 5

def id
  @id
end

Class Method Details

.call(id) ⇒ Object



7
8
9
# File 'lib/superset/dashboard/embedded/get.rb', line 7

def self.call(id)
  self.new(id).list
end

Instance Method Details

#allowed_domainsObject



27
28
29
# File 'lib/superset/dashboard/embedded/get.rb', line 27

def allowed_domains
  result.first['allowed_domains'] unless response[:result].empty?
end

#listObject



35
36
37
# File 'lib/superset/dashboard/embedded/get.rb', line 35

def list
  super unless response[:result].empty?
end

#responseObject



15
16
17
18
19
20
21
# File 'lib/superset/dashboard/embedded/get.rb', line 15

def response
  @response ||= client.get(route)
rescue Happi::Error::NotFound => e
  logger.info("Dashboard #{id} has no Embedded settings. (skipping)") # some dashboards don't have embedded settings, fine to ignore.
  @response = { result: [] }.with_indifferent_access
  @response
end

#resultObject



23
24
25
# File 'lib/superset/dashboard/embedded/get.rb', line 23

def result
  response[:result].empty? ? [] : [ super ] # wrap single result in an array so it can be used in the tt list and table
end

#uuidObject



31
32
33
# File 'lib/superset/dashboard/embedded/get.rb', line 31

def uuid
  result.first['uuid'] unless response[:result].empty?
end