arangorb 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ArangoRB.gemspec +20 -18
- data/Gemfile +3 -0
- data/README.md +1079 -908
- data/lib/AQL.rb +155 -0
- data/lib/Batch.rb +97 -0
- data/lib/Cache.rb +71 -0
- data/lib/Collection.rb +852 -0
- data/lib/Database.rb +417 -0
- data/lib/Document.rb +346 -0
- data/lib/Edge.rb +104 -0
- data/lib/Error.rb +125 -0
- data/lib/Foxx.rb +277 -0
- data/lib/Graph.rb +325 -0
- data/lib/Index.rb +126 -0
- data/lib/Replication.rb +235 -0
- data/lib/Request.rb +143 -0
- data/lib/Server.rb +466 -0
- data/lib/Task.rb +120 -0
- data/lib/Transaction.rb +115 -0
- data/lib/Traversal.rb +224 -0
- data/lib/User.rb +197 -0
- data/lib/Vertex.rb +127 -0
- data/lib/View.rb +151 -0
- data/lib/arangorb.rb +23 -15
- data/lib/helpers/Error.rb +28 -0
- data/lib/helpers/Return.rb +53 -0
- metadata +64 -45
- data/lib/ArangoRB_AQL.rb +0 -181
- data/lib/ArangoRB_Cache.rb +0 -174
- data/lib/ArangoRB_Col.rb +0 -526
- data/lib/ArangoRB_DB.rb +0 -363
- data/lib/ArangoRB_Doc.rb +0 -319
- data/lib/ArangoRB_Edg.rb +0 -184
- data/lib/ArangoRB_Gra.rb +0 -201
- data/lib/ArangoRB_Index.rb +0 -135
- data/lib/ArangoRB_Replication.rb +0 -261
- data/lib/ArangoRB_Ser.rb +0 -446
- data/lib/ArangoRB_Task.rb +0 -129
- data/lib/ArangoRB_Tra.rb +0 -169
- data/lib/ArangoRB_Tran.rb +0 -68
- data/lib/ArangoRB_User.rb +0 -157
- data/lib/ArangoRB_Ver.rb +0 -162
- data/spec/arangoRB_helper.rb +0 -4
- data/spec/arangoRestart_helper.rb +0 -14
- data/spec/arangorb-1.3.0.gem +0 -0
- data/spec/lib/0.1.0/arangoAQL_helper.rb +0 -64
- data/spec/lib/0.1.0/arangoC_helper.rb +0 -170
- data/spec/lib/0.1.0/arangoDB_helper.rb +0 -119
- data/spec/lib/0.1.0/arangoDoc_helper.rb +0 -79
- data/spec/lib/0.1.0/arangoE_helper.rb +0 -50
- data/spec/lib/0.1.0/arangoG_helper.rb +0 -78
- data/spec/lib/0.1.0/arangoS_helper.rb +0 -37
- data/spec/lib/0.1.0/arangoT_helper.rb +0 -48
- data/spec/lib/0.1.0/arangoV_helper.rb +0 -65
- data/spec/lib/1.0.0/arangoC_helper.rb +0 -73
- data/spec/lib/1.0.0/arangoDB_helper.rb +0 -48
- data/spec/lib/1.0.0/arangoI_helper.rb +0 -43
- data/spec/lib/1.0.0/arangoS_helper.rb +0 -192
- data/spec/lib/1.0.0/arangoTa_helper.rb +0 -49
- data/spec/lib/1.0.0/arangoTr_helper.rb +0 -15
- data/spec/lib/1.0.0/arangoU_helper.rb +0 -72
- data/spec/lib/1.1.0/arangoRB_helper.rb +0 -144
- data/spec/lib/1.1.0/arangoRB_walks_helper.rb +0 -19
- data/spec/lib/1.2.0/arangoCache_helper.rb +0 -66
- data/spec/lib/1.3.0/arangoHash_helper.rb +0 -30
- data/spec/lib/arangoRB_0.1.0_helper.rb +0 -9
- data/spec/lib/arangoRB_1.0.0_helper.rb +0 -6
- data/spec/lib/arangoRB_1.1.0_helper.rb +0 -2
- data/spec/lib/arangoRB_1.2.0_helper.rb +0 -2
- data/spec/spec_helper.rb +0 -42
data/lib/Edge.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# === GRAPH VERTEX ===
|
2
|
+
|
3
|
+
module Arango
|
4
|
+
class Edge < Arango::Document
|
5
|
+
def initialize(name: nil, collection:, body: {}, rev: nil, from: nil,
|
6
|
+
to: nil)
|
7
|
+
assign_collection(collection)
|
8
|
+
body[:_key] ||= name
|
9
|
+
body[:_rev] ||= rev
|
10
|
+
body[:_from] ||= from
|
11
|
+
body[:_to] ||= to
|
12
|
+
body[:_id] ||= "#{@collection.name}/#{name}" unless name.nil?
|
13
|
+
assign_attributes(body)
|
14
|
+
end
|
15
|
+
|
16
|
+
# === DEFINE ===
|
17
|
+
|
18
|
+
attr_reader :collection, :database, :server, :graph
|
19
|
+
|
20
|
+
def collection=(collection)
|
21
|
+
satisfy_class?(collection, [Arango::Collection])
|
22
|
+
if collection.graph.nil?
|
23
|
+
raise Arango::Error.new err: :collection_does_not_have_a_graph, data:
|
24
|
+
{"name_collection": collection.name, "graph": nil}
|
25
|
+
end
|
26
|
+
@collection = collection
|
27
|
+
@graph = @collection.graph
|
28
|
+
@database = @collection.database
|
29
|
+
@server = @database.server
|
30
|
+
end
|
31
|
+
alias assign_collection collection=
|
32
|
+
|
33
|
+
# == GET ==
|
34
|
+
|
35
|
+
def retrieve(if_match: false)
|
36
|
+
headers = {}
|
37
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
38
|
+
result = @graph.request("GET", "edge/#{@collection.name}/#{@body[:_key]}",
|
39
|
+
headers: headers, key: :edge)
|
40
|
+
return_element(result)
|
41
|
+
end
|
42
|
+
|
43
|
+
# == POST ==
|
44
|
+
|
45
|
+
def create(body: {}, waitForSync: nil)
|
46
|
+
body = @body.merge(body)
|
47
|
+
query = {
|
48
|
+
"waitForSync": waitForSync,
|
49
|
+
"_from": @body[:_from],
|
50
|
+
"_to": @body[:_to]
|
51
|
+
}
|
52
|
+
result = @graph.request("POST", "edge/#{@collection.name}", body: body,
|
53
|
+
query: query, key: :edge)
|
54
|
+
return result if @server.async != false
|
55
|
+
body2 = result.clone
|
56
|
+
body = body.merge(body2)
|
57
|
+
assign_attributes(body)
|
58
|
+
return return_directly?(result) ? result : self
|
59
|
+
end
|
60
|
+
|
61
|
+
# == PUT ==
|
62
|
+
|
63
|
+
def replace(body: {}, waitForSync: nil, keepNull: nil, if_match: false)
|
64
|
+
query = {
|
65
|
+
"waitForSync": waitForSync,
|
66
|
+
"keepNull": keepNull
|
67
|
+
}
|
68
|
+
headers = {}
|
69
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
70
|
+
result = @graph.request("PUT", "edge/#{@collection.name}/#{@body[:_key]}",
|
71
|
+
body: body, query: query, headers: headers, key: :edge)
|
72
|
+
return result if @server.async != false
|
73
|
+
body2 = result.clone
|
74
|
+
body = body.merge(body2)
|
75
|
+
assign_attributes(body)
|
76
|
+
return return_directly?(result) ? result : self
|
77
|
+
end
|
78
|
+
|
79
|
+
def update(body: {}, waitForSync: nil, if_match: false)
|
80
|
+
query = {"waitForSync": waitForSync}
|
81
|
+
headers = {}
|
82
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
83
|
+
result = @graph.request("PATCH", "edge/#{@collection.name}/#{@body[:_key]}",
|
84
|
+
body: body, query: query, headers: headers, key: :edge)
|
85
|
+
return result if @server.async != false
|
86
|
+
body2 = result.clone
|
87
|
+
body = body.merge(body2)
|
88
|
+
body = @body.merge(body)
|
89
|
+
assign_attributes(body)
|
90
|
+
return return_directly?(result) ? result : self
|
91
|
+
end
|
92
|
+
|
93
|
+
# === DELETE ===
|
94
|
+
|
95
|
+
def destroy(waitForSync: nil, if_match: false)
|
96
|
+
query = {"waitForSync": waitForSync}
|
97
|
+
headers = {}
|
98
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
99
|
+
result = @graph.request("DELETE", "edge/#{@collection.name}/#{@body[:_key]}",
|
100
|
+
query: query, headers: headers)
|
101
|
+
return_delete(result)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/lib/Error.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# === ERROR ===
|
2
|
+
|
3
|
+
module Arango
|
4
|
+
class Error < StandardError
|
5
|
+
@@list_arango_rb_errors = {
|
6
|
+
no_other_aql_next: {
|
7
|
+
code: 10001, message: "No other values with AQL next"
|
8
|
+
},
|
9
|
+
no_other_simple_next: {
|
10
|
+
code: 10002, message: "No other values with AQL next"
|
11
|
+
},
|
12
|
+
is_a_edge_collection: {
|
13
|
+
code: 10003, message: "This collection is an Edge collection"
|
14
|
+
},
|
15
|
+
is_a_document_collection: {
|
16
|
+
code: 10004, message: "This collection is a Document collection"
|
17
|
+
},
|
18
|
+
database_graph_no_same_as_collection_database: {
|
19
|
+
code: 10005, message: "Database of graph is not the same as the class"
|
20
|
+
},
|
21
|
+
wrong_type_instead_of_expected_one: {
|
22
|
+
code: 10006, message: "Expected a type, received another"
|
23
|
+
},
|
24
|
+
no_other_export_next: {
|
25
|
+
code: 10007, message: "No other values with AQL next"
|
26
|
+
},
|
27
|
+
no_aql_id_available: {
|
28
|
+
code: 10008, message: "AQL does not have id. It could have already been killed"
|
29
|
+
},
|
30
|
+
id_is_not_valid: {
|
31
|
+
code: 10009, message: "Given attribute is not a valid document id or an Arango::Document"
|
32
|
+
},
|
33
|
+
collection_does_not_have_a_graph: {
|
34
|
+
code: 10010, message: "Collection does not have a graph"
|
35
|
+
},
|
36
|
+
arangodb_did_not_return_a_valid_result: {
|
37
|
+
code: 10011, message: "ArangoDB didn't return a valid result"
|
38
|
+
},
|
39
|
+
read_or_write_should_be_string_or_collections: {
|
40
|
+
code: 10012, message: "read or write should be an array of name classes or Arango::Collections"
|
41
|
+
},
|
42
|
+
wrong_class: {
|
43
|
+
code: 10013, message: "Wrong class"
|
44
|
+
},
|
45
|
+
wrong_element: {
|
46
|
+
code: 10014, message: "Element is not part of the list"
|
47
|
+
},
|
48
|
+
orphan_collection_used_by_edge_definition: {
|
49
|
+
code: 10015, message: "Orphan collection is already used by an edge definition"
|
50
|
+
},
|
51
|
+
impossible_to_parse_arangodb_response: {
|
52
|
+
code: 10016, message: "Impossible to parse ArangoDB response"
|
53
|
+
},
|
54
|
+
batch_query_not_valid: {
|
55
|
+
code: 10017, message: "Query is not valid"
|
56
|
+
},
|
57
|
+
arangorb_didnt_return_a_valid_result: {
|
58
|
+
code: 10018, message: "ArangoRB didn't return a valid result"
|
59
|
+
},
|
60
|
+
impossible_to_connect_with_database: {
|
61
|
+
code: 10019, message: "Impossible to connect with database"
|
62
|
+
},
|
63
|
+
you_cannot_assign_from_or_to_to_a_vertex: {
|
64
|
+
code: 10020, message: "You cannot assign from or to to a Vertex"
|
65
|
+
},
|
66
|
+
wrong_start_vertex_type: {
|
67
|
+
code: 10021, message: "Starting vertex should be an Arango::Vertex, an Arango::Document (not Edge) or a valid vertex id"
|
68
|
+
},
|
69
|
+
database_undefined_for_traversal: {
|
70
|
+
code: 10022, message: "Database undefined for traversal"
|
71
|
+
},
|
72
|
+
edge_collection_should_be_of_type_edge: {
|
73
|
+
code: 10022, message: "Database undefined for traversal"
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
def initialize(err:, data: nil, skip_assignment: false)
|
78
|
+
unless skip_assignment
|
79
|
+
@message = @@list_arango_rb_errors[err][:message]
|
80
|
+
@code = @@list_arango_rb_errors[err][:code]
|
81
|
+
@internal_code = err
|
82
|
+
@data = data
|
83
|
+
end
|
84
|
+
super(@message)
|
85
|
+
end
|
86
|
+
attr_reader :data, :code, :message
|
87
|
+
|
88
|
+
def to_h
|
89
|
+
{
|
90
|
+
"message": @message,
|
91
|
+
"code": @code,
|
92
|
+
"data": @data,
|
93
|
+
"internal_code": @internal_code
|
94
|
+
}.delete_if{|k,v| v.nil?}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
module Arango
|
100
|
+
class ErrorDB < Arango::Error
|
101
|
+
def initialize(message:, code:, data:, errorNum:, action:, url:, request:)
|
102
|
+
@message = message
|
103
|
+
@code = code
|
104
|
+
@data = data
|
105
|
+
@errorNum = errorNum
|
106
|
+
@action = action
|
107
|
+
@url = url
|
108
|
+
@request = request
|
109
|
+
super(err: nil, skip_assignment: true)
|
110
|
+
end
|
111
|
+
attr_reader :message, :code, :data, :errorNum, :action, :url, :request
|
112
|
+
|
113
|
+
def to_h
|
114
|
+
{
|
115
|
+
"action": @action,
|
116
|
+
"url": @url,
|
117
|
+
"request": @request,
|
118
|
+
"message": @message,
|
119
|
+
"code": @code,
|
120
|
+
"data": @data,
|
121
|
+
"errorNum": @errorNum
|
122
|
+
}.delete_if{|k,v| v.nil?}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/Foxx.rb
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
# === FOXX ===
|
2
|
+
|
3
|
+
module Arango
|
4
|
+
class Foxx
|
5
|
+
include Arango::Helper_Error
|
6
|
+
include Arango::Helper_Return
|
7
|
+
include Arango::Database_Return
|
8
|
+
|
9
|
+
def self.new(*args)
|
10
|
+
hash = args[0]
|
11
|
+
super unless hash.is_a?(Hash)
|
12
|
+
database = hash[:database]
|
13
|
+
if database.is_a?(Arango::Database) && database.server.active_cache && !hash[:mount].nil?
|
14
|
+
cache_name = "#{database.name}/#{hash[:mount]}"
|
15
|
+
cached = database.server.cache.cache.dig(:foxx, cache_name)
|
16
|
+
if cached.nil?
|
17
|
+
hash[:cache_name] = cache_name
|
18
|
+
return super
|
19
|
+
else
|
20
|
+
body = hash[:body] || {}
|
21
|
+
[:mount, :development, :legacy, :provides, :name, :version,
|
22
|
+
:type, :setup, :teardown].each{|k| body[k] ||= hash[k]}
|
23
|
+
cached.assign_attributes(body)
|
24
|
+
return cached
|
25
|
+
end
|
26
|
+
end
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(database:, body: {}, mount:, development: nil, legacy: nil,
|
31
|
+
provides: nil, name: nil, version: nil, type: "application/json",
|
32
|
+
setup: nil, teardown: nil, cache_name: nil)
|
33
|
+
assign_database(database)
|
34
|
+
unless cache_name.nil?
|
35
|
+
@cache_name = cache_name
|
36
|
+
@server.cache.save(:foxx, cache_name, self)
|
37
|
+
end
|
38
|
+
assign_attributes(body)
|
39
|
+
assign_type(type)
|
40
|
+
@mount ||= mount
|
41
|
+
@development ||= development
|
42
|
+
@setup ||= setup
|
43
|
+
@legacy ||= legacy
|
44
|
+
@provides ||= provides
|
45
|
+
@name ||= name
|
46
|
+
@version ||= version
|
47
|
+
@teardown ||= teardown
|
48
|
+
end
|
49
|
+
|
50
|
+
# === DEFINE ===
|
51
|
+
|
52
|
+
attr_reader :database, :server, :type, :body, :cache_name
|
53
|
+
attr_accessor :name, :development, :legacy, :provides,
|
54
|
+
:version, :mount, :setup, :teardown
|
55
|
+
|
56
|
+
def body=(result)
|
57
|
+
if result.is_a?(Hash)
|
58
|
+
@body = result
|
59
|
+
@name = result[:name] || @name
|
60
|
+
@version = result[:version] || @version
|
61
|
+
@mount = result[:mount] || @mount
|
62
|
+
@development = result[:development] || @development
|
63
|
+
@legacy = result[:legacy] || @legacy
|
64
|
+
@provides = result[:provides] || @provides
|
65
|
+
if @server.active_cache && @cache_name.nil?
|
66
|
+
@cache_name = "#{@database.name}/#{@mount}"
|
67
|
+
@server.cache.save(:task, @cache_name, self)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
alias assign_attributes body=
|
72
|
+
|
73
|
+
def type=(type)
|
74
|
+
satisfy_category?(type, ["application/zip", "zip", "application/javascript", "javascript", "application/json", "json", "multipart/form-data", "data"], "type")
|
75
|
+
type = "application/#{type}" if ["zip", "javascript", "json"].include?(type)
|
76
|
+
type = "multipart/form-data" if type == "data"
|
77
|
+
@type = type
|
78
|
+
end
|
79
|
+
alias assign_type type=
|
80
|
+
|
81
|
+
# === TO HASH ===
|
82
|
+
|
83
|
+
def to_h
|
84
|
+
{
|
85
|
+
"name": @name,
|
86
|
+
"version": @version,
|
87
|
+
"mount": @mount,
|
88
|
+
"development": @development,
|
89
|
+
"legacy": @legacy,
|
90
|
+
"provides": @provides,
|
91
|
+
"type": @type,
|
92
|
+
"teardown": @teardown,
|
93
|
+
"cache_name": @cache_name,
|
94
|
+
"database": @database.name
|
95
|
+
}.delete_if{|k,v| v.nil?}
|
96
|
+
end
|
97
|
+
|
98
|
+
def return_foxx(result, val=nil)
|
99
|
+
return result if @server.async != false
|
100
|
+
case val
|
101
|
+
when :configuration
|
102
|
+
@configuration = result
|
103
|
+
when :dependencies
|
104
|
+
@dependencies = result
|
105
|
+
else
|
106
|
+
assign_attributes(result)
|
107
|
+
end
|
108
|
+
return return_directly?(result) ? result : self
|
109
|
+
end
|
110
|
+
private :return_foxx
|
111
|
+
|
112
|
+
# === ACTIONS ===
|
113
|
+
|
114
|
+
def retrieve
|
115
|
+
query = {"mount": @mount}
|
116
|
+
result = @database.request("GET", url: "_api/foxx/service")
|
117
|
+
return_foxx(result)
|
118
|
+
end
|
119
|
+
|
120
|
+
def create(body: @body, type: @type, development: @development,
|
121
|
+
setup: @setup, legacy: @legacy)
|
122
|
+
headers = {"Accept": type}
|
123
|
+
skip_to_json = type != "application/json"
|
124
|
+
query = {
|
125
|
+
"mount": @mount,
|
126
|
+
"setup": setup,
|
127
|
+
"development ": development ,
|
128
|
+
"legacy": legacy
|
129
|
+
}
|
130
|
+
result = @database.request("POST",
|
131
|
+
url: "_api/foxx", body: body, headers: headers,
|
132
|
+
skip_to_json: skip_to_json, query: query)
|
133
|
+
return_foxx(result)
|
134
|
+
end
|
135
|
+
|
136
|
+
def destroy(teardown: @teardown)
|
137
|
+
query = {
|
138
|
+
"mount": @mount,
|
139
|
+
"teardown": teardown
|
140
|
+
}
|
141
|
+
result = @database.request("DELETE", "_api/foxx/service", query: query)
|
142
|
+
return_foxx(result)
|
143
|
+
end
|
144
|
+
|
145
|
+
def replace(body: @body, type: @type, teardown: @teardown, setup: @setup,
|
146
|
+
legacy: @legacy)
|
147
|
+
headers = {"Accept": type}
|
148
|
+
skip_to_json = type != "application/json"
|
149
|
+
query = {
|
150
|
+
"mount": @mount,
|
151
|
+
"setup": setup,
|
152
|
+
"development ": development,
|
153
|
+
"legacy": legacy
|
154
|
+
}
|
155
|
+
result = @database.request("PUT", "_api/foxx/service", body: body,
|
156
|
+
headers: headers, skip_to_json: skip_to_json, query: query)
|
157
|
+
return_foxx(result)
|
158
|
+
end
|
159
|
+
|
160
|
+
def update(body: @body, type: @type, teardown: @teardown,
|
161
|
+
setup: @setup, legacy: @legacy)
|
162
|
+
assign_type(type)
|
163
|
+
headers = {"Accept": type}
|
164
|
+
skip_to_json = @type != "application/json"
|
165
|
+
query = {
|
166
|
+
"mount": @mount,
|
167
|
+
"setup": setup,
|
168
|
+
"development ": development,
|
169
|
+
"legacy": legacy
|
170
|
+
}
|
171
|
+
result = @database.request("PATCH", "_api/foxx/service", body: body,
|
172
|
+
headers: headers, skip_to_json: skip_to_json, query: query)
|
173
|
+
return_foxx(result)
|
174
|
+
end
|
175
|
+
|
176
|
+
# === CONFIGURATION ===
|
177
|
+
|
178
|
+
def retrieveConfiguration
|
179
|
+
query = {"mount": @mount}
|
180
|
+
result = @database.request("GET", "_api/foxx/configuration", query: query)
|
181
|
+
return_foxx(result, :configuration)
|
182
|
+
end
|
183
|
+
|
184
|
+
def updateConfiguration(body:)
|
185
|
+
query = {"mount": @mount}
|
186
|
+
result = @database.request("PATCH", "_api/foxx/configuration", query: query, body: body)
|
187
|
+
return_foxx(result, :configuration)
|
188
|
+
end
|
189
|
+
|
190
|
+
def replaceConfiguration(body:)
|
191
|
+
query = {"mount": @mount}
|
192
|
+
result = @database.request("PUT", "_api/foxx/configuration", query: query, body: body)
|
193
|
+
return_foxx(result, :configuration)
|
194
|
+
end
|
195
|
+
|
196
|
+
# === DEPENDENCY ===
|
197
|
+
|
198
|
+
def retrieveDependencies
|
199
|
+
query = {"mount": @mount}
|
200
|
+
result = @database.request("GET", "_api/foxx/dependencies", query: query)
|
201
|
+
return_foxx(result, :dependencies)
|
202
|
+
end
|
203
|
+
|
204
|
+
def updateDependencies(body:)
|
205
|
+
query = {"mount": @mount}
|
206
|
+
result = @database.request("PATCH", "_api/foxx/dependencies", query: query, body: body)
|
207
|
+
return_foxx(result, :dependencies)
|
208
|
+
end
|
209
|
+
|
210
|
+
def replaceDependencies(body:)
|
211
|
+
query = {"mount": @mount}
|
212
|
+
result = @database.request("PUT", "_api/foxx/dependencies", query: query, body: body)
|
213
|
+
return_foxx(result, :dependencies)
|
214
|
+
end
|
215
|
+
|
216
|
+
# === MISCELLANEOUS
|
217
|
+
|
218
|
+
def scripts
|
219
|
+
query = {"mount": @mount}
|
220
|
+
@database.request("GET", "_api/foxx/scripts", query: query)
|
221
|
+
end
|
222
|
+
|
223
|
+
def run_script(name:, body: {})
|
224
|
+
query = {"mount": @mount}
|
225
|
+
@database.request("POST", "_api/foxx/scripts/#{name}", query: query, body: body)
|
226
|
+
end
|
227
|
+
|
228
|
+
def tests(reporter: nil, idiomatic: nil)
|
229
|
+
satisfy_category?(reporter, [nil, "default", "suite", "stream", "xunit", "tap"])
|
230
|
+
headers = {}
|
231
|
+
headers[:"Content-Type"] = case reporter
|
232
|
+
when "stream"
|
233
|
+
"application/x-ldjson"
|
234
|
+
when "tap"
|
235
|
+
"text/plain, text/*"
|
236
|
+
when "xunit"
|
237
|
+
"application/xml, text/xml"
|
238
|
+
else
|
239
|
+
nil
|
240
|
+
end
|
241
|
+
query = {"mount": @mount}
|
242
|
+
@database.request("GET", "_api/foxx/scripts", query: query, headers: headers)
|
243
|
+
end
|
244
|
+
|
245
|
+
def enableDevelopment
|
246
|
+
query = {"mount": @mount}
|
247
|
+
@database.request("POST", "_api/foxx/development", query: query)
|
248
|
+
end
|
249
|
+
|
250
|
+
def disableDevelopment
|
251
|
+
query = {"mount": @mount}
|
252
|
+
@database.request("DELETE", "_api/foxx/development", query: query)
|
253
|
+
end
|
254
|
+
|
255
|
+
def readme
|
256
|
+
query = {"mount": @mount}
|
257
|
+
@database.request("GET", "_api/foxx/readme", query: query)
|
258
|
+
end
|
259
|
+
|
260
|
+
def swagger
|
261
|
+
query = {"mount": @mount}
|
262
|
+
@database.request("GET", "_api/foxx/swagger", query: query)
|
263
|
+
end
|
264
|
+
|
265
|
+
def download(path:, warning: @server.warning)
|
266
|
+
query = {"mount": @mount}
|
267
|
+
@server.download("POST", "_db/#{@database.name}/_api/foxx/download",
|
268
|
+
path: path, query: query)
|
269
|
+
puts "File saved in #{path}" if warning
|
270
|
+
end
|
271
|
+
|
272
|
+
def commit(body:, replace: nil)
|
273
|
+
query = {"replace": replace}
|
274
|
+
@database.request("POST", "_api/foxx/commit", body: body, query: query)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|