Class: Arango::Server
Instance Attribute Summary collapse
-
#active_cache ⇒ Object
DEFINE ===.
-
#async ⇒ Object
DEFINE ===.
-
#base_uri ⇒ Object
readonly
DEFINE ===.
-
#cache ⇒ Object
readonly
DEFINE ===.
-
#password ⇒ Object
DEFINE ===.
-
#pool ⇒ Object
DEFINE ===.
-
#port ⇒ Object
DEFINE ===.
-
#return_output ⇒ Object
DEFINE ===.
-
#server ⇒ Object
DEFINE ===.
-
#size ⇒ Object
Returns the value of attribute size.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#tls ⇒ Object
DEFINE ===.
-
#username ⇒ Object
DEFINE ===.
-
#verbose ⇒ Object
DEFINE ===.
-
#warning ⇒ Object
Returns the value of attribute warning.
Instance Method Summary collapse
-
#[](database) ⇒ Object
DATABASE ==.
-
#agencyConfig ⇒ Object
AGENCY ===.
- #agencyRead(body:, agency_mode: nil) ⇒ Object
- #agencyWrite(body:, agency_mode: nil) ⇒ Object
- #allEndpoints(warning: @warning) ⇒ Object
- #available? ⇒ Boolean
-
#batch(boundary: "XboundaryX", queries: []) ⇒ Object
BATCH ===.
- #cancelAsync(id:) ⇒ Object
- #changePropertyWAL(allowOversizeEntries: nil, logfileSize: nil, historicLogfiles: nil, reserveLogfiles: nil, throttleWait: nil, throttleWhenPending: nil) ⇒ Object
-
#checkPort(port: @port) ⇒ Object
CLUSTER ==.
- #clusterHealth ⇒ Object
- #clusterStatistics(dbserver:) ⇒ Object
- #createDumpBatch(ttl:, dbserver: nil) ⇒ Object
- #database(name:) ⇒ Object
- #databases(user: false) ⇒ Object
- #databaseVersion ⇒ Object
- #destroyAllAsync ⇒ Object
- #destroyAsync(id:, stamp: nil) ⇒ Object
- #destroyAsyncByType(type:, stamp: nil) ⇒ Object
- #destroyDumpBatch(id:, dbserver: nil) ⇒ Object
- #destroyExpiredAsync ⇒ Object
- #download(*args) ⇒ Object
- #echo ⇒ Object
-
#endpoint ⇒ Object
ENDPOINT ===.
- #endpoints ⇒ Object
- #engine ⇒ Object
- #execute(body:) ⇒ Object
-
#fetchAsync(id:) ⇒ Object
ASYNC ===.
- #flushWAL(waitForSync: nil, waitForCollector: nil) ⇒ Object
-
#initialize(username: "root", password:, server: "localhost", warning: true, port: "8529", verbose: false, return_output: false, async: false, active_cache: false, pool: false, size: 5, timeout: 5, tls: false) ⇒ Server
constructor
A new instance of Server.
-
#log(upto: nil, level: nil, start: nil, size: nil, offset: nil, search: nil, sort: nil) ⇒ Object
MONITORING ===.
- #loglevel ⇒ Object
- #mode ⇒ Object
- #prolongDumpBatch(id:, ttl:, dbserver: nil) ⇒ Object
- #propertyWAL ⇒ Object
- #reload ⇒ Object
-
#request(*args) ⇒ Object
REQUESTS ===.
- #restartPool ⇒ Object
- #retrieveAsync(id:) ⇒ Object
- #retrieveAsyncByType(type:, count: nil) ⇒ Object
- #retrieveDoneAsync(count: nil) ⇒ Object
- #retrievePendingAsync(count: nil) ⇒ Object
- #return_delete(result) ⇒ Object
- #return_directly?(result) ⇒ Boolean
- #role ⇒ Object
- #serverData ⇒ Object
- #serverId ⇒ Object
- #shutdown ⇒ Object
- #statistics ⇒ Object
- #statisticsDescription ⇒ Object
- #status ⇒ Object
-
#tasks ⇒ Object
TASKS ==.
- #test(body:) ⇒ Object
- #time ⇒ Object
-
#to_h ⇒ Object
TO HASH ===.
- #transactions ⇒ Object
- #updateLoglevel(body:) ⇒ Object
- #updateMode(mode:) ⇒ Object
-
#user(password: "", name:, extra: {}, active: nil) ⇒ Object
USER ===.
- #users ⇒ Object
-
#version(details: nil) ⇒ Object
MISCELLANEOUS FUNCTIONS ===.
Methods included from Helper_Error
#satisfy_category?, #satisfy_class?, #warning_deprecated
Constructor Details
#initialize(username: "root", password:, server: "localhost", warning: true, port: "8529", verbose: false, return_output: false, async: false, active_cache: false, pool: false, size: 5, timeout: 5, tls: false) ⇒ Server
Returns a new instance of Server.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/Server.rb', line 7 def initialize(username: "root", password:, server: "localhost", warning: true, port: "8529", verbose: false, return_output: false, async: false, active_cache: false, pool: false, size: 5, timeout: 5, tls: false) @tls = tls @base_uri = "http" @base_uri += "s" if tls @base_uri += "://#{server}:#{port}" @server = server @port = port @username = username @password = password @options = {body: {}, headers: {}, query: {}, basic_auth: {username: @username, password: @password }, format: :plain} @verbose = verbose @return_output = return_output @warning = warning @active_cache = active_cache @cache = @active_cache ? Arango::Cache.new : nil @pool = pool @size = size @timeout = timeout @request = Arango::Request.new(return_output: @return_output, base_uri: @base_uri, options: @options, verbose: @verbose, async: @async) assign_async(async) if @pool @internal_request = ConnectionPool.new(size: @size, timeout: @timeout){ @request } end end |
Instance Attribute Details
#active_cache ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def active_cache @active_cache end |
#async ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def async @async end |
#base_uri ⇒ Object (readonly)
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def base_uri @base_uri end |
#cache ⇒ Object (readonly)
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def cache @cache end |
#password ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def password @password end |
#pool ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def pool @pool end |
#port ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def port @port end |
#return_output ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def return_output @return_output end |
#server ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def server @server end |
#size ⇒ Object
Returns the value of attribute size.
41 42 43 |
# File 'lib/Server.rb', line 41 def size @size end |
#timeout ⇒ Object
Returns the value of attribute timeout.
41 42 43 |
# File 'lib/Server.rb', line 41 def timeout @timeout end |
#tls ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def tls @tls end |
#username ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def username @username end |
#verbose ⇒ Object
DEFINE ===
39 40 41 |
# File 'lib/Server.rb', line 39 def verbose @verbose end |
#warning ⇒ Object
Returns the value of attribute warning.
41 42 43 |
# File 'lib/Server.rb', line 41 def warning @warning end |
Instance Method Details
#[](database) ⇒ Object
DATABASE ==
175 176 177 |
# File 'lib/Server.rb', line 175 def [](database) Arango::Database.new(name: database, server: self) end |
#agencyConfig ⇒ Object
AGENCY ===
391 392 393 |
# File 'lib/Server.rb', line 391 def agencyConfig request("GET", "_api/agency/config") end |
#agencyRead(body:, agency_mode: nil) ⇒ Object
402 403 404 405 406 407 |
# File 'lib/Server.rb', line 402 def agencyRead(body:, agency_mode: nil) satisfy_category?(agency_mode, ["waitForCommmitted", "waitForSequenced", "noWait", nil]) headers = {"X-ArangoDB-Agency-Mode": agency_mode} request("POST", "_api/agency/read", headers: headers, body: body) end |
#agencyWrite(body:, agency_mode: nil) ⇒ Object
395 396 397 398 399 400 |
# File 'lib/Server.rb', line 395 def agencyWrite(body:, agency_mode: nil) satisfy_category?(agency_mode, ["waitForCommmitted", "waitForSequenced", "noWait", nil]) headers = {"X-ArangoDB-Agency-Mode": agency_mode} request("POST", "_api/agency/write", headers: headers, body: body) end |
#allEndpoints(warning: @warning) ⇒ Object
281 282 283 284 |
# File 'lib/Server.rb', line 281 def allEndpoints(warning: @warning) warning_deprecated(warning, "allEndpoints") request("GET", "_api/endpoint") end |
#available? ⇒ Boolean
224 225 226 |
# File 'lib/Server.rb', line 224 def available? request("POST", "_admin/routing/availability", body: {}) end |
#batch(boundary: "XboundaryX", queries: []) ⇒ Object
BATCH ===
361 362 363 |
# File 'lib/Server.rb', line 361 def batch(boundary: "XboundaryX", queries: []) Arango::Batch.new(server: self, boundary: boundary, queries: queries) end |
#cancelAsync(id:) ⇒ Object
319 320 321 |
# File 'lib/Server.rb', line 319 def cancelAsync(id:) request("PUT", "_api/job/#{id}/cancel", key: :result) end |
#changePropertyWAL(allowOversizeEntries: nil, logfileSize: nil, historicLogfiles: nil, reserveLogfiles: nil, throttleWait: nil, throttleWhenPending: nil) ⇒ Object
433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/Server.rb', line 433 def changePropertyWAL(allowOversizeEntries: nil, logfileSize: nil, historicLogfiles: nil, reserveLogfiles: nil, throttleWait: nil, throttleWhenPending: nil) body = { "allowOversizeEntries": allowOversizeEntries, "logfileSize": allowOversizeEntries, "historicLogfiles": historicLogfiles, "reserveLogfiles": reserveLogfiles, "throttleWait": throttleWait, "throttleWhenPending": throttleWhenPending } request("PUT", "_admin/wal/properties", body: body) end |
#checkPort(port: @port) ⇒ Object
CLUSTER ==
195 196 197 |
# File 'lib/Server.rb', line 195 def checkPort(port: @port) request("GET", "_admin/clusterCheckPort", query: {port: port.to_s}) end |
#clusterHealth ⇒ Object
258 259 260 |
# File 'lib/Server.rb', line 258 def clusterHealth request("GET", "_admin/health") end |
#clusterStatistics(dbserver:) ⇒ Object
262 263 264 265 |
# File 'lib/Server.rb', line 262 def clusterStatistics dbserver: query = {DBserver: dbserver} request("GET", "_admin/clusterStatistics", query: query) end |
#createDumpBatch(ttl:, dbserver: nil) ⇒ Object
365 366 367 368 369 370 371 372 |
# File 'lib/Server.rb', line 365 def createDumpBatch(ttl:, dbserver: nil) query = { DBserver: dbserver } body = { ttl: ttl } result = request("POST", "_api/replication/batch", body: body, query: query) return result if return_directly?(result) return result[:id] end |
#database(name:) ⇒ Object
179 180 181 |
# File 'lib/Server.rb', line 179 def database(name:) Arango::Database.new(name: name, server: self) end |
#databases(user: false) ⇒ Object
183 184 185 186 187 188 189 190 191 |
# File 'lib/Server.rb', line 183 def databases(user: false) if user result = request("GET", "_api/database/user", key: :result) else result = request("GET", "_api/database", key: :result) end return result if return_directly?(result) result.map{|db| Arango::Database.new(name: db, server: self)} end |
#databaseVersion ⇒ Object
459 460 461 |
# File 'lib/Server.rb', line 459 def databaseVersion request("GET", "_admin/database/target-version", key: :version) end |
#destroyAllAsync ⇒ Object
334 335 336 |
# File 'lib/Server.rb', line 334 def destroyAllAsync destroyAsyncByType(type: "all") end |
#destroyAsync(id:, stamp: nil) ⇒ Object
323 324 325 326 |
# File 'lib/Server.rb', line 323 def destroyAsync(id:, stamp: nil) query = {"stamp": stamp} request("DELETE", "_api/job/#{id}", query: query, key: :result) end |
#destroyAsyncByType(type:, stamp: nil) ⇒ Object
328 329 330 331 332 |
# File 'lib/Server.rb', line 328 def destroyAsyncByType(type:, stamp: nil) satisfy_category?(type, ["all", "expired"]) query = {"stamp": stamp} request("DELETE", "_api/job/#{type}", query: query) end |
#destroyDumpBatch(id:, dbserver: nil) ⇒ Object
374 375 376 377 378 |
# File 'lib/Server.rb', line 374 def destroyDumpBatch(id:, dbserver: nil) query = {DBserver: dbserver} result = request("DELETE", "_api/replication/batch/#{id}", query: query) return_delete(result) end |
#destroyExpiredAsync ⇒ Object
338 339 340 |
# File 'lib/Server.rb', line 338 def destroyExpiredAsync destroyAsyncByType(type: "expired") end |
#download(*args) ⇒ Object
165 166 167 168 169 170 171 |
# File 'lib/Server.rb', line 165 def download(*args) if @pool @internal_request.with{|request| request.download(*args)} else @request.download(*args) end end |
#echo ⇒ Object
455 456 457 |
# File 'lib/Server.rb', line 455 def echo request("POST", "_admin/echo", body: {}) end |
#endpoint ⇒ Object
ENDPOINT ===
273 274 275 |
# File 'lib/Server.rb', line 273 def endpoint "tcp://#{@server}:#{@port}" end |
#endpoints ⇒ Object
277 278 279 |
# File 'lib/Server.rb', line 277 def endpoints request("GET", "_api/cluster/endpoints") end |
#engine ⇒ Object
416 417 418 |
# File 'lib/Server.rb', line 416 def engine request("GET", "_api/engine") end |
#execute(body:) ⇒ Object
472 473 474 |
# File 'lib/Server.rb', line 472 def execute(body:) request("POST", "_admin/execute", body: body) end |
#fetchAsync(id:) ⇒ Object
ASYNC ===
315 316 317 |
# File 'lib/Server.rb', line 315 def fetchAsync(id:) request("PUT", "_api/job/#{id}") end |
#flushWAL(waitForSync: nil, waitForCollector: nil) ⇒ Object
420 421 422 423 424 425 426 427 |
# File 'lib/Server.rb', line 420 def flushWAL(waitForSync: nil, waitForCollector: nil) body = { "waitForSync": waitForSync, "waitForCollector": waitForCollector } result = request("PUT", "_admin/wal/flush", body: body) return return_directly?(result) ? result: true end |
#log(upto: nil, level: nil, start: nil, size: nil, offset: nil, search: nil, sort: nil) ⇒ Object
MONITORING ===
201 202 203 204 205 206 207 208 209 |
# File 'lib/Server.rb', line 201 def log(upto: nil, level: nil, start: nil, size: nil, offset: nil, search: nil, sort: nil) satisfy_category?(upto, [nil, "fatal", 0, "error", 1, "warning", 2, "info", 3, "debug", 4]) satisfy_category?(sort, [nil, "asc", "desc"]) query = { upto: upto, level: level, start: start, size: size, offset: offset, search: search, sort: sort } request("GET", "_admin/log", query: query) end |
#loglevel ⇒ Object
211 212 213 |
# File 'lib/Server.rb', line 211 def loglevel request("GET", "_admin/log/level") end |
#mode ⇒ Object
248 249 250 |
# File 'lib/Server.rb', line 248 def mode request("GET", "_admin/server/mode") end |
#prolongDumpBatch(id:, ttl:, dbserver: nil) ⇒ Object
380 381 382 383 384 385 386 387 |
# File 'lib/Server.rb', line 380 def prolongDumpBatch(id:, ttl:, dbserver: nil) query = { DBserver: dbserver } body = { ttl: ttl } result = request("PUT", "_api/replication/batch/#{id}", body: body, query: query) return result if return_directly?(result) return true end |
#propertyWAL ⇒ Object
429 430 431 |
# File 'lib/Server.rb', line 429 def propertyWAL request("GET", "_admin/wal/properties") end |
#reload ⇒ Object
219 220 221 222 |
# File 'lib/Server.rb', line 219 def reload request("GET", "_admin/routing/reload") return true end |
#request(*args) ⇒ Object
REQUESTS ===
157 158 159 160 161 162 163 |
# File 'lib/Server.rb', line 157 def request(*args) if @pool @internal_request.with{|request| request.request(*args)} else @request.request(*args) end end |
#restartPool ⇒ Object
66 67 68 69 |
# File 'lib/Server.rb', line 66 def restartPool changePoolStatus(false) changePoolStatus(true) end |
#retrieveAsync(id:) ⇒ Object
342 343 344 |
# File 'lib/Server.rb', line 342 def retrieveAsync(id:) request("GET", "_api/job/#{id}") end |
#retrieveAsyncByType(type:, count: nil) ⇒ Object
346 347 348 349 |
# File 'lib/Server.rb', line 346 def retrieveAsyncByType(type:, count: nil) satisfy_category?(type, ["done", "pending"]) request("GET", "_api/job/#{type}", query: {count: count}) end |
#retrieveDoneAsync(count: nil) ⇒ Object
351 352 353 |
# File 'lib/Server.rb', line 351 def retrieveDoneAsync(count: nil) retrieveAsyncByType(type: "done", count: count) end |
#retrievePendingAsync(count: nil) ⇒ Object
355 356 357 |
# File 'lib/Server.rb', line 355 def retrievePendingAsync(count: nil) retrieveAsyncByType(type: "pending", count: count) end |
#return_delete(result) ⇒ Object
481 482 483 484 |
# File 'lib/Server.rb', line 481 def return_delete(result) return result if @async != false return return_directly?(result) ? result : true end |
#return_directly?(result) ⇒ Boolean
476 477 478 479 |
# File 'lib/Server.rb', line 476 def return_directly?(result) return @async != false || @return_direct_result return result if result == true end |
#role ⇒ Object
240 241 242 |
# File 'lib/Server.rb', line 240 def role request("GET", "_admin/server/role", key: :role) end |
#serverData ⇒ Object
244 245 246 |
# File 'lib/Server.rb', line 244 def serverData request("GET", "_admin/server/id") end |
#serverId ⇒ Object
267 268 269 |
# File 'lib/Server.rb', line 267 def serverId request("GET", "_api/replication/server-id", key: :serverId) end |
#shutdown ⇒ Object
463 464 465 466 |
# File 'lib/Server.rb', line 463 def shutdown result = request("DELETE", "_admin/shutdown") return return_directly?(result) ? result: true end |
#statistics ⇒ Object
228 229 230 |
# File 'lib/Server.rb', line 228 def statistics request("GET", "_admin/statistics") end |
#statisticsDescription ⇒ Object
232 233 234 |
# File 'lib/Server.rb', line 232 def statisticsDescription request("GET", "_admin/statistics-description") end |
#status ⇒ Object
236 237 238 |
# File 'lib/Server.rb', line 236 def status request("GET", "_admin/status") end |
#tasks ⇒ Object
TASKS ==
304 305 306 307 308 309 310 311 |
# File 'lib/Server.rb', line 304 def tasks result = request("GET", "_api/tasks") return result if return_directly?(result) result.map do |task| database = Arango::Database.new(name: task[:database], server: self) Arango::Task.new(body: task, database: database) end end |
#test(body:) ⇒ Object
468 469 470 |
# File 'lib/Server.rb', line 468 def test(body:) request("POST", "_admin/test", body: body) end |
#time ⇒ Object
451 452 453 |
# File 'lib/Server.rb', line 451 def time request("GET", "_admin/time", key: :time) end |
#to_h ⇒ Object
TO HASH ===
140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/Server.rb', line 140 def to_h hash = { "base_uri": @base_uri, "server": @server, "port": @port, "username": @username, "async": @async, "verbose": @verbose, "return_output": @return_output, "warning": @warning, "tls": @tls }.delete_if{|k,v| v.nil?} hash end |
#transactions ⇒ Object
447 448 449 |
# File 'lib/Server.rb', line 447 def transactions request("GET", "_admin/wal/transactions") end |
#updateLoglevel(body:) ⇒ Object
215 216 217 |
# File 'lib/Server.rb', line 215 def updateLoglevel(body:) request("PUT", "_admin/log/level", body: body) end |
#updateMode(mode:) ⇒ Object
252 253 254 255 256 |
# File 'lib/Server.rb', line 252 def updateMode(mode:) satisfy_category?(mode, ["default", "readonly"]) body = {mode: mode} request("PUT", "_admin/server/mode", body: mode) end |
#user(password: "", name:, extra: {}, active: nil) ⇒ Object
USER ===
288 289 290 291 |
# File 'lib/Server.rb', line 288 def user(password: "", name:, extra: {}, active: nil) Arango::User.new(server: self, password: password, name: name, extra: extra, active: active) end |
#users ⇒ Object
293 294 295 296 297 298 299 300 |
# File 'lib/Server.rb', line 293 def users result = request("GET", "_api/user", key: :result) return result if return_directly?(result) result.map do |user| Arango::User.new(name: user[:user], active: user[:active], extra: user[:extra], server: self) end end |
#version(details: nil) ⇒ Object
MISCELLANEOUS FUNCTIONS ===
411 412 413 414 |
# File 'lib/Server.rb', line 411 def version(details: nil) query = {"details": details} request("GET", "_api/version", query: query) end |