module GeoEngineer::ApiGatewayHelpers::ClassMethods
Class Methods
Public Instance Methods
__fetch_remote_rest_api_resources_for_rest_api(provider, rr)
click to toggle source
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 49 def __fetch_remote_rest_api_resources_for_rest_api(provider, rr) _client(provider).get_resources({ rest_api_id: rr[:_terraform_id] })['items'].map(&:to_h).map do |res| next nil unless res[:path_part] # default resource has no path_part res[:_terraform_id] = res[:id] res[:_geo_id] = "#{rr[:_geo_id]}::#{res[:path_part]}" res end.compact end
_client(provider)
click to toggle source
Helper Client
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 23 def _client(provider) AwsClients.api_gateway(provider) end
_fetch_integration(provider, rr, res, meth)
click to toggle source
Integration
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 86 def _fetch_integration(provider, rr, res, meth) return _client(provider).get_integration({ rest_api_id: rr[:_terraform_id], resource_id: res[:_terraform_id], http_method: meth }).to_h rescue Aws::APIGateway::Errors::NotFoundException return nil end
_fetch_method(provider, rr, res, meth)
click to toggle source
Method
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 97 def _fetch_method(provider, rr, res, meth) return _client(provider).get_method({ rest_api_id: rr[:_terraform_id], resource_id: res[:_terraform_id], http_method: meth }).to_h rescue Aws::APIGateway::Errors::NotFoundException return nil end
_fetch_remote_rest_api_resources_for_rest_api(provider, rr)
click to toggle source
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 61 def _fetch_remote_rest_api_resources_for_rest_api(provider, rr) cache = GeoEngineer::ApiGatewayHelpers._rest_api_resource_cache[provider] ||= {} return cache[rr[:_terraform_id]] if cache[rr[:_terraform_id]] cache[rr[:_terraform_id]] = __fetch_remote_rest_api_resources_for_rest_api(provider, rr) end
_fetch_remote_rest_apis(provider)
click to toggle source
Rest API
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 28 def _fetch_remote_rest_apis(provider) cache = GeoEngineer::ApiGatewayHelpers._rest_api_cache return cache[provider] if cache[provider] ret = _client(provider).get_rest_apis['items'].map(&:to_h).map do |rr| rr[:_terraform_id] = rr[:id] rr[:_geo_id] = rr[:name] rr[:root_resource_id] = _root_resource_id(provider, rr) rr end.compact cache[provider] = ret ret end
_remote_rest_api_resource(provider) { |rr, res| ... }
click to toggle source
Combination Methods
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 69 def _remote_rest_api_resource(provider) _fetch_remote_rest_apis(provider).map do |rr| _fetch_remote_rest_api_resources_for_rest_api(provider, rr).map do |res| yield rr, res end end end
_remote_rest_api_resource_method(provider) { |rr, res, meth| ... }
click to toggle source
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 77 def _remote_rest_api_resource_method(provider) _remote_rest_api_resource(provider) do |rr, res| (res[:resource_methods] || {}).keys.map do |meth| yield rr, res, meth end end end
_root_resource_id(provider, rr)
click to toggle source
# File lib/geoengineer/resources/api_gateway/helpers.rb, line 42 def _root_resource_id(provider, rr) _client(provider).get_resources({ rest_api_id: rr[:id] })['items'].map do |res| return res.id if res.path == '/' end nil end