Class: Morpheus::CypherInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/cypher_interface.rb

Instance Method Summary collapse

Instance Method Details

#base_pathObject



6
7
8
# File 'lib/morpheus/api/cypher_interface.rb', line 6

def base_path
  "/api/cypher"
end

#create(item_key, params = {}, payload = {}) ⇒ Object



26
27
28
29
30
# File 'lib/morpheus/api/cypher_interface.rb', line 26

def create(item_key, params={}, payload={})
  url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute({method: :post, url: url, headers: headers, payload: payload.to_json})
end

#destroy(item_key, params = {}) ⇒ Object



39
40
41
42
43
# File 'lib/morpheus/api/cypher_interface.rb', line 39

def destroy(item_key, params={})
  url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute({method: :delete, url: url, headers: headers})
end

#get(item_key, params = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/morpheus/api/cypher_interface.rb', line 10

def get(item_key, params={})
  raise "#{self.class}.get() passed a blank item_key!" if item_key.to_s == ''
  url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}" }
  execute({method: :get, url: url, headers: headers})
end

#list(item_key = nil, params = {}) ⇒ Object

list url is the same as get but uses $itemKey/?list=true method: 'LIST' would be neat though



19
20
21
22
23
24
# File 'lib/morpheus/api/cypher_interface.rb', line 19

def list(item_key=nil, params={})
  url = item_key ? "#{@base_url}#{base_path}/#{escape_item_key(item_key)}" : "#{@base_url}#{base_path}"
  params.merge!({list:'true'}) # ditch this probably
  headers = { :params => params, :authorization => "Bearer #{@access_token}" }
  execute({method: :get, url: url, headers: headers})
end

#update(item_key, params = {}, payload = {}) ⇒ Object

update is not even needed I don't think, same as POST



33
34
35
36
37
# File 'lib/morpheus/api/cypher_interface.rb', line 33

def update(item_key, params={}, payload={})
  url = "#{@base_url}#{base_path}/#{escape_item_key(item_key)}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute({method: :put, url: url, headers: headers, payload: payload.to_json})
end