Class: Arango::Foxx
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#commit(body:, replace: nil) ⇒ Object
-
#create(body: @body, type: @type, development: @development, setup: @setup, legacy: @legacy) ⇒ Object
-
#destroy(teardown: @teardown) ⇒ Object
-
#disable_development ⇒ Object
-
#download(path:, warning: @server.warning) ⇒ Object
-
#enable_development ⇒ Object
-
#initialize(database:, body: {}, mount:, development: nil, legacy: nil, provides: nil, name: nil, version: nil, type: "application/json", setup: nil, teardown: nil, cache_name: nil) ⇒ Foxx
constructor
-
#readme ⇒ Object
-
#replace(body: @body, type: @type, teardown: @teardown, setup: @setup, legacy: @legacy) ⇒ Object
-
#replace_configuration(body:) ⇒ Object
-
#replace_dependencies(body:) ⇒ Object
-
#retrieve ⇒ Object
ACTIONS ===.
-
#retrieve_configuration ⇒ Object
CONFIGURATION ===.
-
#retrieve_dependencies ⇒ Object
DEPENDENCY ===.
-
#run_script(name:, body: {}) ⇒ Object
-
#scripts ⇒ Object
MISCELLANEOUS.
-
#swagger ⇒ Object
-
#tests(reporter: nil, idiomatic: nil) ⇒ Object
-
#to_h ⇒ Object
TO HASH ===.
-
#update(body: @body, type: @type, teardown: @teardown, setup: @setup, legacy: @legacy) ⇒ Object
-
#update_configuration(body:) ⇒ Object
-
#update_dependencies(body:) ⇒ Object
#satisfy_category?, #satisfy_class?, #satisfy_class_or_string?, #satisfy_module?, #satisfy_module_or_nil?, #satisfy_module_or_string?, #warning_deprecated
Constructor Details
#initialize(database:, body: {}, mount:, development: nil, legacy: nil, provides: nil, name: nil, version: nil, type: "application/json", setup: nil, teardown: nil, cache_name: nil) ⇒ Foxx
Returns a new instance of Foxx.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/arango/foxx.rb', line 10
def initialize(database:, body: {}, mount:, development: nil, legacy: nil,
provides: nil, name: nil, version: nil, type: "application/json",
setup: nil, teardown: nil, cache_name: nil)
assign_database(database)
unless cache_name.nil?
@cache_name = cache_name
@server.cache.save(:foxx, cache_name, self)
end
assign_attributes(body)
assign_type(type)
@development ||= development
@legacy ||= legacy
@mount ||= mount
@name ||= name
@provides ||= provides
@setup ||= setup
@teardown ||= teardown
@version ||= version
end
|
Instance Attribute Details
#body ⇒ Object
32
33
34
|
# File 'lib/arango/foxx.rb', line 32
def body
@body
end
|
#cache_name ⇒ Object
32
33
34
|
# File 'lib/arango/foxx.rb', line 32
def cache_name
@cache_name
end
|
#database ⇒ Object
32
33
34
|
# File 'lib/arango/foxx.rb', line 32
def database
@database
end
|
#development ⇒ Object
Returns the value of attribute development.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def development
@development
end
|
#legacy ⇒ Object
Returns the value of attribute legacy.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def legacy
@legacy
end
|
#mount ⇒ Object
Returns the value of attribute mount.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def mount
@mount
end
|
#name ⇒ Object
Returns the value of attribute name.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def name
@name
end
|
#provides ⇒ Object
Returns the value of attribute provides.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def provides
@provides
end
|
#server ⇒ Object
32
33
34
|
# File 'lib/arango/foxx.rb', line 32
def server
@server
end
|
#setup ⇒ Object
Returns the value of attribute setup.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def setup
@setup
end
|
#teardown ⇒ Object
Returns the value of attribute teardown.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def teardown
@teardown
end
|
#type ⇒ Object
32
33
34
|
# File 'lib/arango/foxx.rb', line 32
def type
@type
end
|
#version ⇒ Object
Returns the value of attribute version.
33
34
35
|
# File 'lib/arango/foxx.rb', line 33
def version
@version
end
|
Instance Method Details
#commit(body:, replace: nil) ⇒ Object
251
252
253
254
|
# File 'lib/arango/foxx.rb', line 251
def commit(body:, replace: nil)
query = { replace: replace }
@database.request("POST", "_api/foxx/commit", body: body, query: query)
end
|
#create(body: @body, type: @type, development: @development, setup: @setup, legacy: @legacy) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/arango/foxx.rb', line 99
def create(body: @body, type: @type, development: @development,
setup: @setup, legacy: @legacy)
= { Accept: type }
skip_to_json = type != "application/json"
query = {
mount: @mount,
setup: setup,
development: development,
legacy: legacy
}
result = @database.request("POST",
url: "_api/foxx", body: body, headers: ,
skip_to_json: skip_to_json, query: query)
return_foxx(result)
end
|
#destroy(teardown: @teardown) ⇒ Object
115
116
117
118
119
120
121
122
|
# File 'lib/arango/foxx.rb', line 115
def destroy(teardown: @teardown)
query = {
mount: @mount,
teardown: teardown
}
result = @database.request("DELETE", "_api/foxx/service", query: query)
return_foxx(result)
end
|
#disable_development ⇒ Object
229
230
231
232
|
# File 'lib/arango/foxx.rb', line 229
def disable_development
query = { mount: @mount }
@database.request("DELETE", "_api/foxx/development", query: query)
end
|
#download(path:, warning: @server.warning) ⇒ Object
244
245
246
247
248
249
|
# File 'lib/arango/foxx.rb', line 244
def download(path:, warning: @server.warning)
query = { mount: @mount }
@server.download("POST", "_db/#{@database.name}/_api/foxx/download",
path: path, query: query)
puts "File saved in #{path}" if warning
end
|
#enable_development ⇒ Object
224
225
226
227
|
# File 'lib/arango/foxx.rb', line 224
def enable_development
query = { mount: @mount }
@database.request("POST", "_api/foxx/development", query: query)
end
|
#readme ⇒ Object
234
235
236
237
|
# File 'lib/arango/foxx.rb', line 234
def readme
query = { mount: @mount }
@database.request("GET", "_api/foxx/readme", query: query)
end
|
#replace(body: @body, type: @type, teardown: @teardown, setup: @setup, legacy: @legacy) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/arango/foxx.rb', line 124
def replace(body: @body, type: @type, teardown: @teardown, setup: @setup,
legacy: @legacy)
= { Accept: type }
skip_to_json = type != "application/json"
query = {
mount: @mount,
setup: setup,
teardown: teardown,
legacy: legacy
}
result = @database.request("PUT", "_api/foxx/service", body: body,
headers: , skip_to_json: skip_to_json, query: query)
return_foxx(result)
end
|
#replace_configuration(body:) ⇒ Object
169
170
171
172
173
|
# File 'lib/arango/foxx.rb', line 169
def replace_configuration(body:)
query = { mount: @mount }
result = @database.request("PUT", "_api/foxx/configuration", query: query, body: body)
return_foxx(result, :configuration)
end
|
#replace_dependencies(body:) ⇒ Object
189
190
191
192
193
|
# File 'lib/arango/foxx.rb', line 189
def replace_dependencies(body:)
query = { mount: @mount }
result = @database.request("PUT", "_api/foxx/dependencies", query: query, body: body)
return_foxx(result, :dependencies)
end
|
#retrieve ⇒ Object
93
94
95
96
97
|
# File 'lib/arango/foxx.rb', line 93
def retrieve
query = {mount: @mount}
result = @database.request("GET", url: "_api/foxx/service")
return_foxx(result)
end
|
#retrieve_configuration ⇒ Object
157
158
159
160
161
|
# File 'lib/arango/foxx.rb', line 157
def retrieve_configuration
query = { mount: @mount }
result = @database.request("GET", "_api/foxx/configuration", query: query)
return_foxx(result, :configuration)
end
|
#retrieve_dependencies ⇒ Object
177
178
179
180
181
|
# File 'lib/arango/foxx.rb', line 177
def retrieve_dependencies
query = { mount: @mount }
result = @database.request("GET", "_api/foxx/dependencies", query: query)
return_foxx(result, :dependencies)
end
|
#run_script(name:, body: {}) ⇒ Object
202
203
204
205
|
# File 'lib/arango/foxx.rb', line 202
def run_script(name:, body: {})
query = { mount: @mount }
@database.request("POST", "_api/foxx/scripts/#{name}", query: query, body: body)
end
|
#scripts ⇒ Object
197
198
199
200
|
# File 'lib/arango/foxx.rb', line 197
def scripts
query = { mount: @mount }
@database.request("GET", "_api/foxx/scripts", query: query)
end
|
#swagger ⇒ Object
239
240
241
242
|
# File 'lib/arango/foxx.rb', line 239
def swagger
query = { mount: @mount }
@database.request("GET", "_api/foxx/swagger", query: query)
end
|
#tests(reporter: nil, idiomatic: nil) ⇒ Object
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/arango/foxx.rb', line 207
def tests(reporter: nil, idiomatic: nil)
satisfy_category?(reporter, [nil, "default", "suite", "stream", "xunit", "tap"])
= {}
[:"Content-Type"] = case reporter
when "stream"
"application/x-ldjson"
when "tap"
"text/plain, text/*"
when "xunit"
"application/xml, text/xml"
else
nil
end
query = { mount: @mount }
@database.request("GET", "_api/foxx/scripts", query: query, headers: )
end
|
#to_h ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/arango/foxx.rb', line 62
def to_h
{
cache_name: @cache_name,
database: @database.name,
development: @development,
legacy: @legacy,
mount: @mount,
name: @name,
provides: @provides,
teardown: @teardown,
type: @type,
version: @version
}.delete_if{|k,v| v.nil?}
end
|
#update(body: @body, type: @type, teardown: @teardown, setup: @setup, legacy: @legacy) ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/arango/foxx.rb', line 139
def update(body: @body, type: @type, teardown: @teardown,
setup: @setup, legacy: @legacy)
assign_type(type)
= { Accept: type }
skip_to_json = @type != "application/json"
query = {
mount: @mount,
setup: setup,
teardown: teardown,
legacy: legacy
}
result = @database.request("PATCH", "_api/foxx/service", body: body,
headers: , skip_to_json: skip_to_json, query: query)
return_foxx(result)
end
|
#update_configuration(body:) ⇒ Object
163
164
165
166
167
|
# File 'lib/arango/foxx.rb', line 163
def update_configuration(body:)
query = { mount: @mount }
result = @database.request("PATCH", "_api/foxx/configuration", query: query, body: body)
return_foxx(result, :configuration)
end
|
#update_dependencies(body:) ⇒ Object
183
184
185
186
187
|
# File 'lib/arango/foxx.rb', line 183
def update_dependencies(body:)
query = { mount: @mount }
result = @database.request("PATCH", "_api/foxx/dependencies", query: query, body: body)
return_foxx(result, :dependencies)
end
|