Module: LookerSDK::Client::Dynamic
- Included in:
- LookerSDK::Client
- Defined in:
- lib/looker-sdk/client/dynamic.rb
Constant Summary collapse
Hash.new
Instance Attribute Summary collapse
-
#dynamic ⇒ Object
Returns the value of attribute dynamic.
Instance Method Summary collapse
- #clear_swagger ⇒ Object
- #load_swagger ⇒ Object
- #method_link(entry) ⇒ Object
- #operations ⇒ Object
- #respond_to?(method_name, include_private = false) ⇒ Boolean
- #try_load_swagger ⇒ Object
Instance Attribute Details
#dynamic ⇒ Object
Returns the value of attribute dynamic.
32 33 34 |
# File 'lib/looker-sdk/client/dynamic.rb', line 32 def dynamic @dynamic end |
Instance Method Details
#clear_swagger ⇒ Object
47 48 49 |
# File 'lib/looker-sdk/client/dynamic.rb', line 47 def clear_swagger @swagger = @operations = nil end |
#load_swagger ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/looker-sdk/client/dynamic.rb', line 51 def load_swagger # We only need the swagger if we are going to be building our own 'operations' hash return if shared_swagger && @@sharable_operations[api_endpoint] # First, try to load swagger.json w/o authenticating @swagger ||= without_authentication { try_load_swagger } unless @swagger # try again, this time with authentication @swagger = try_load_swagger end # in unit tests, @swagger may be nil and last_response nil because no HTTP request was made if @swagger.nil? if @last_error raise @last_error else raise "Load of swagger.json failed." end end @swagger end |
#method_link(entry) ⇒ Object
94 95 96 97 |
# File 'lib/looker-sdk/client/dynamic.rb', line 94 def method_link(entry) uri = URI.parse(api_endpoint) "#{uri.scheme}://#{uri.host}:#{uri.port}/api-docs/index.html#!/#{entry[:info][:tags].first}/#{entry[:info][:operationId]}" rescue "http://docs.looker.com/" end |
#operations ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/looker-sdk/client/dynamic.rb', line 74 def operations return @@sharable_operations[api_endpoint] if shared_swagger && @@sharable_operations[api_endpoint] if !@swagger && @lazy_swagger load_swagger end return nil unless @swagger @operations ||= Hash[ @swagger[:paths].map do |path_name, path_info| path_info.map do |method, route_info| route = @swagger[:basePath].to_s + path_name.to_s [route_info[:operationId].to_sym, {:route => route, :method => method, :info => route_info}] end end.reduce(:+) ].freeze shared_swagger ? (@@sharable_operations[api_endpoint] = @operations) : @operations end |
#respond_to?(method_name, include_private = false) ⇒ Boolean
112 113 114 |
# File 'lib/looker-sdk/client/dynamic.rb', line 112 def respond_to?(method_name, include_private=false) !!find_entry(method_name) || super end |
#try_load_swagger ⇒ Object
34 35 36 37 |
# File 'lib/looker-sdk/client/dynamic.rb', line 34 def try_load_swagger resp = get('swagger.json') rescue nil resp && last_response && last_response.status == 200 && last_response.data && last_response.data.to_attrs end |