class Neo4j::Core::CypherSession::Adaptors::HTTP
Constants
- CONSTRAINT_TYPES
- DEFAULT_FARADAY_CONFIGURATOR
- ROW_REST
Attributes
requestor[R]
url[R]
Public Class Methods
new(url, options = {})
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 14 def initialize(url, options = {}) 15 @url = url 16 @options = options 17 end
transaction_class()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 85 def self.transaction_class 86 require 'neo4j/core/cypher_session/transactions/http' 87 Neo4j::Core::CypherSession::Transactions::HTTP 88 end
Public Instance Methods
check_for_schema_response_error!(response)
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 76 def check_for_schema_response_error!(response) 77 if response.body.is_a?(Hash) && response.body.key?(:errors) 78 message = response.body[:errors].map { |error| "#{error[:code]}: #{error[:message]}" }.join("\n ") 79 fail CypherSession::ConnectionFailedError, "Connection failure: \n #{message}" 80 elsif !response.success? 81 fail CypherSession::ConnectionFailedError, "Connection failure: \n status: #{response.status} \n #{response.body}" 82 end 83 end
connect()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 25 def connect 26 @requestor = Requestor.new(@url, USER_AGENT_STRING, self.class.method(:instrument_request), @options.fetch(:faraday_configurator, DEFAULT_FARADAY_CONFIGURATOR)) 27 end
connected?()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 101 def connected? 102 !!@requestor 103 end
constraints(_session, _label = nil, _options = {})
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 64 def constraints(_session, _label = nil, _options = {}) 65 response = @requestor.get('db/data/schema/constraint') 66 67 check_for_schema_response_error!(response) 68 list = response.body || [] 69 list.map do |item| 70 {type: CONSTRAINT_TYPES[item[:type]], 71 label: item[:label].to_sym, 72 properties: item[:property_keys].map(&:to_sym)} 73 end 74 end
indexes(_session)
click to toggle source
Schema
inspection methods
# File lib/neo4j/core/cypher_session/adaptors/http.rb 49 def indexes(_session) 50 response = @requestor.get('db/data/schema/index') 51 52 check_for_schema_response_error!(response) 53 list = response.body || [] 54 55 list.map do |item| 56 {label: item[:label].to_sym, 57 properties: item[:property_keys].map(&:to_sym)} 58 end 59 end
indexes_for_label(label)
click to toggle source
Schema
inspection methods
# File lib/neo4j/core/cypher_session/adaptors/http.rb 91 def indexes_for_label(label) 92 url = db_data_url + "schema/index/#{label}" 93 @connection.get(url) 94 end
query_set(transaction, queries, options = {})
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 31 def query_set(transaction, queries, options = {}) 32 setup_queries!(queries, transaction) 33 34 return unless path = transaction.query_path(options.delete(:commit)) 35 36 faraday_response = @requestor.post(path, queries) 37 38 transaction.apply_id_from_url!(faraday_response.env[:response_headers][:location]) 39 40 wrap_level = options[:wrap_level] || @options[:wrap_level] 41 Responses::HTTP.new(faraday_response, wrap_level: wrap_level).results 42 end
supports_metadata?()
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 105 def supports_metadata? 106 Gem::Version.new(version(nil)) >= Gem::Version.new('2.1.5') 107 end
version(_session)
click to toggle source
# File lib/neo4j/core/cypher_session/adaptors/http.rb 44 def version(_session) 45 @version ||= @requestor.get('db/data/').body[:neo4j_version] 46 end