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/User.rb
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
# === USER ===
|
2
|
+
|
3
|
+
module Arango
|
4
|
+
class User
|
5
|
+
include Arango::Helper_Error
|
6
|
+
include Arango::Helper_Return
|
7
|
+
include Arango::Server_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
|
14
|
+
cache_name = hash[:name]
|
15
|
+
cached = database.server.cache.cache.dig(:user, cache_name)
|
16
|
+
if cached.nil?
|
17
|
+
hash[:cache_name] = cache_name
|
18
|
+
return super
|
19
|
+
else
|
20
|
+
body = {}
|
21
|
+
[:password, :extra, :active].each{|k| body[k] ||= hash[k]}
|
22
|
+
cached.assign_attributes(body)
|
23
|
+
return cached
|
24
|
+
end
|
25
|
+
end
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(server:, password: "", name:, extra: {}, active: nil, cache_name: nil)
|
30
|
+
assign_server(server)
|
31
|
+
unless cache_name.nil?
|
32
|
+
@cache_name = cache_name
|
33
|
+
@server.cache.save(:user, cache_name, self)
|
34
|
+
end
|
35
|
+
@password = password
|
36
|
+
@name = name
|
37
|
+
@extra = extra
|
38
|
+
@active = active
|
39
|
+
end
|
40
|
+
|
41
|
+
# === DEFINE ===
|
42
|
+
|
43
|
+
attr_accessor :name, :extra, :active
|
44
|
+
attr_reader :server, :body, :cache_name
|
45
|
+
attr_writer :password
|
46
|
+
alias user name
|
47
|
+
alias user= name=
|
48
|
+
|
49
|
+
def body=(result)
|
50
|
+
@body = result
|
51
|
+
@password = result[:password] || @password
|
52
|
+
@name = result[:user] || @name
|
53
|
+
@extra = result[:extra] || @extra
|
54
|
+
@active = result[:active].nil? ? @active : result[:active]
|
55
|
+
if @server.active_cache && @cache_name.nil?
|
56
|
+
@cache_name = @name
|
57
|
+
@server.cache.save(:user, @cache_name, self)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
alias assign_attributes body=
|
61
|
+
|
62
|
+
# === TO HASH ===
|
63
|
+
|
64
|
+
def to_h
|
65
|
+
{
|
66
|
+
"user": @name,
|
67
|
+
"extra": @extra,
|
68
|
+
"active": @active,
|
69
|
+
"cache_name": @cache_name,
|
70
|
+
"server": @server.base_uri
|
71
|
+
}.delete_if{|k,v| v.nil?}
|
72
|
+
end
|
73
|
+
|
74
|
+
def [](database)
|
75
|
+
if self.databases[database.to_sym] == "rw"
|
76
|
+
Arango::Database.new name: database, server: @server
|
77
|
+
else
|
78
|
+
"This User does not have access to Database #{database}."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
alias database []
|
82
|
+
|
83
|
+
# == USER ACTION ==
|
84
|
+
|
85
|
+
def create(password: @password, active: @active, extra: @extra)
|
86
|
+
body = {
|
87
|
+
"user": @name,
|
88
|
+
"passwd": password,
|
89
|
+
"extra": extra,
|
90
|
+
"active": active
|
91
|
+
}
|
92
|
+
result = @server.request("POST", "_api/user", body: body)
|
93
|
+
return_element(result)
|
94
|
+
end
|
95
|
+
|
96
|
+
def retrieve
|
97
|
+
result = @server.request("GET", "_api/user/#{@name}", body: body)
|
98
|
+
return_element(result)
|
99
|
+
end
|
100
|
+
|
101
|
+
def replace(password: @password, active: @active, extra: @extra)
|
102
|
+
body = {
|
103
|
+
"passwd": password,
|
104
|
+
"active": active,
|
105
|
+
"extra": extra
|
106
|
+
}
|
107
|
+
result = @server.request("PUT", "_api/user/#{@name}", body: body)
|
108
|
+
@password = password
|
109
|
+
return_element(result)
|
110
|
+
end
|
111
|
+
|
112
|
+
def update(password: @password, active: @active, extra: @extra)
|
113
|
+
body = {
|
114
|
+
"passwd": password,
|
115
|
+
"active": active,
|
116
|
+
"extra": extra
|
117
|
+
}
|
118
|
+
result = @server.request("PATCH", "_api/user/#{@name}", body: body)
|
119
|
+
@password = password
|
120
|
+
return_element(result)
|
121
|
+
end
|
122
|
+
|
123
|
+
def destroy
|
124
|
+
result = @server.request("DELETE", "_api/user/#{@name}")
|
125
|
+
return return_directly?(result) ? result : true
|
126
|
+
end
|
127
|
+
|
128
|
+
# == ACCESS ==
|
129
|
+
|
130
|
+
def addDatabaseAccess(grant:, database:)
|
131
|
+
satisfy_category?(grant, ["rw", "ro", "none"])
|
132
|
+
satisfy_class?(database, [Arango::Database, String])
|
133
|
+
database = database.name if database.is_a?(Arango::Database)
|
134
|
+
body = {"grant": grant}
|
135
|
+
result = @server.request("PUT", "_api/user/#{@name}/database/#{database}",
|
136
|
+
body: body)
|
137
|
+
return return_directly?(result) ? result : result[database.to_sym]
|
138
|
+
end
|
139
|
+
|
140
|
+
def grant(database:)
|
141
|
+
addDatabaseAccess(grant: "rw", database: database)
|
142
|
+
end
|
143
|
+
|
144
|
+
def addCollectionAccess(grant:, database:, collection:)
|
145
|
+
satisfy_category?(grant, ["rw", "ro", "none"])
|
146
|
+
satisfy_class?(database, [Arango::Database, String])
|
147
|
+
satisfy_class?(collection, [Arango::Collection, String])
|
148
|
+
database = database.name if database.is_a?(Arango::Database)
|
149
|
+
collection = collection.name if collection.is_a?(Arango::Collection)
|
150
|
+
body = {"grant": grant}
|
151
|
+
result = @server.request("PUT", "_api/user/#{@name}/database/#{database}/#{collection}",
|
152
|
+
body: body)
|
153
|
+
return return_directly?(result) ? result : result[:"#{database}/#{collection}"]
|
154
|
+
end
|
155
|
+
|
156
|
+
def revokeDatabaseAccess(database:)
|
157
|
+
satisfy_class?(database, [Arango::Database, String])
|
158
|
+
database = database.name if database.is_a?(Arango::Database)
|
159
|
+
result = @server.request("DELETE", "_api/user/#{@name}/database/#{database}")
|
160
|
+
return return_directly?(result) ? result : true
|
161
|
+
end
|
162
|
+
alias revoke revokeDatabaseAccess
|
163
|
+
|
164
|
+
def revokeCollectionAccess(database:, collection:)
|
165
|
+
satisfy_class?(database, [Arango::Database, String])
|
166
|
+
satisfy_class?(collection, [Arango::Collection, String])
|
167
|
+
database = database.name if database.is_a?(Arango::Database)
|
168
|
+
collection = collection.name if collection.is_a?(Arango::Collection)
|
169
|
+
result = @server.request("DELETE", "_api/user/#{@name}/database/#{database}/#{collection}")
|
170
|
+
return return_directly?(result) ? result : true
|
171
|
+
end
|
172
|
+
|
173
|
+
def listAccess(full: nil)
|
174
|
+
query = {"full": full}
|
175
|
+
result = @server.request("GET", "_api/user/#{@name}/database", query: query)
|
176
|
+
return return_directly?(result) ? result : result[:result]
|
177
|
+
end
|
178
|
+
alias databases listAccess
|
179
|
+
|
180
|
+
def databaseAccess(database:)
|
181
|
+
satisfy_class?(database, [Arango::Database, String])
|
182
|
+
database = database.name if database.is_a?(Arango::Database)
|
183
|
+
result = @server.request("GET", "_api/user/#{@name}/database/#{database}")
|
184
|
+
return return_directly?(result) ? result : result[:result]
|
185
|
+
end
|
186
|
+
|
187
|
+
def collectionAccess(database:, collection:)
|
188
|
+
satisfy_class?(database, [Arango::Database, String])
|
189
|
+
satisfy_class?(collection, [Arango::Collection, String])
|
190
|
+
database = database.name if database.is_a?(Arango::Database)
|
191
|
+
collection = collection.name if collection.is_a?(Arango::Collection)
|
192
|
+
result = @server.request("GET", "_api/user/#{@name}/database/#{database}/#{collection}",
|
193
|
+
body: body)
|
194
|
+
return return_directly?(result) ? result : result[:result]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
data/lib/Vertex.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# === GRAPH VERTEX ===
|
2
|
+
|
3
|
+
module Arango
|
4
|
+
class Vertex < Arango::Document
|
5
|
+
def initialize(name: nil, collection:, body: {}, rev: nil, cache_name: nil)
|
6
|
+
assign_collection(collection)
|
7
|
+
unless cache_name.nil?
|
8
|
+
@cache_name = cache_name
|
9
|
+
@server.cache.save(:document, cache_name, self)
|
10
|
+
end
|
11
|
+
body[:_key] ||= name
|
12
|
+
body[:_rev] ||= rev
|
13
|
+
body[:_id] ||= "#{@collection.name}/#{name}" unless name.nil?
|
14
|
+
assign_attributes(body)
|
15
|
+
end
|
16
|
+
|
17
|
+
# === DEFINE ===
|
18
|
+
|
19
|
+
attr_reader :collection, :database, :server, :graph
|
20
|
+
|
21
|
+
def collection=(collection)
|
22
|
+
satisfy_class?(collection, [Arango::Collection])
|
23
|
+
if collection.graph.nil?
|
24
|
+
raise Arango::Error.new err: :collection_does_not_have_a_graph, data:
|
25
|
+
{"name_collection": collection.name, "graph": nil}
|
26
|
+
end
|
27
|
+
@collection = collection
|
28
|
+
@graph = @collection.graph
|
29
|
+
@database = @collection.database
|
30
|
+
@server = @database.server
|
31
|
+
end
|
32
|
+
alias assign_collection collection=
|
33
|
+
|
34
|
+
# == GET ==
|
35
|
+
|
36
|
+
def retrieve(if_match: false)
|
37
|
+
headers = {}
|
38
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
39
|
+
result = @graph.request("GET", "vertex/#{@collection.name}/#{@body[:_key]}",
|
40
|
+
headers: headers, key: :vertex)
|
41
|
+
return_element(result)
|
42
|
+
end
|
43
|
+
|
44
|
+
# == POST ==
|
45
|
+
|
46
|
+
def create(body: {}, waitForSync: nil)
|
47
|
+
body = @body.merge(body)
|
48
|
+
query = {"waitForSync": waitForSync}
|
49
|
+
result = @graph.request("POST", "vertex/#{@collection.name}", body: body,
|
50
|
+
query: query, key: :vertex)
|
51
|
+
return result if @server.async != false
|
52
|
+
body2 = result.clone
|
53
|
+
body = body.merge(body2)
|
54
|
+
assign_attributes(body)
|
55
|
+
return return_directly?(result) ? result : self
|
56
|
+
end
|
57
|
+
|
58
|
+
# == PUT ==
|
59
|
+
|
60
|
+
def replace(body: {}, waitForSync: nil, keepNull: nil, if_match: false)
|
61
|
+
query = {
|
62
|
+
"waitForSync": waitForSync,
|
63
|
+
"keepNull": keepNull
|
64
|
+
}
|
65
|
+
headers = {}
|
66
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
67
|
+
result = @graph.request("PUT", "vertex/#{@collection.name}/#{@body[:_key]}",
|
68
|
+
body: body, query: query, headers: headers, key: :vertex)
|
69
|
+
return result if @server.async != false
|
70
|
+
body2 = result.clone
|
71
|
+
body = body.merge(body2)
|
72
|
+
assign_attributes(body)
|
73
|
+
return return_directly?(result) ? result : self
|
74
|
+
end
|
75
|
+
|
76
|
+
def update(body: {}, waitForSync: nil, if_match: false, keepNull: nil)
|
77
|
+
query = {"waitForSync": waitForSync, "keepNull": keepNull}
|
78
|
+
headers = {}
|
79
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
80
|
+
result = @graph.request("PATCH", "vertex/#{@collection.name}/#{@body[:_key]}", body: body,
|
81
|
+
query: query, headers: headers, key: :vertex)
|
82
|
+
return result if @server.async != false
|
83
|
+
body2 = result.clone
|
84
|
+
body = body.merge(body2)
|
85
|
+
body = @body.merge(body)
|
86
|
+
assign_attributes(body)
|
87
|
+
return return_directly?(result) ? result : self
|
88
|
+
end
|
89
|
+
|
90
|
+
# === DELETE ===
|
91
|
+
|
92
|
+
def destroy(waitForSync: nil, if_match: false)
|
93
|
+
query = {"waitForSync": waitForSync}
|
94
|
+
headers = {}
|
95
|
+
headers[:"If-Match"] = @body[:_rev] if if_match
|
96
|
+
result = @graph.request("DELETE", "vertex/#{@collection.name}/#{@body[:_key]}",
|
97
|
+
query: query, headers: headers)
|
98
|
+
return_delete(result)
|
99
|
+
end
|
100
|
+
|
101
|
+
# === TRAVERSAL ===
|
102
|
+
|
103
|
+
def traversal(body: {}, sort: nil, direction: nil, minDepth: nil,
|
104
|
+
visitor: nil, itemOrder: nil, strategy: nil,
|
105
|
+
filter: nil, init: nil, maxIterations: nil, maxDepth: nil,
|
106
|
+
uniqueness: nil, order: nil, expander: nil,
|
107
|
+
edgeCollection: nil)
|
108
|
+
Arango::Traversal.new(body: body,
|
109
|
+
sort: sort, direction: direction, minDepth: minDepth,
|
110
|
+
vertex: self, visitor: visitor,itemOrder: itemOrder,
|
111
|
+
strategy: strategy, filter: filter, init: init,
|
112
|
+
maxIterations: maxIterations, maxDepth: maxDepth,
|
113
|
+
uniqueness: uniqueness, order: order,
|
114
|
+
expander: expander, edgeCollection: edgeCollection)
|
115
|
+
end
|
116
|
+
|
117
|
+
# === WRONG ===
|
118
|
+
|
119
|
+
def from=(arg)
|
120
|
+
raise Arango::Error.new err: you_cannot_assign_from_or_to_to_a_vertex
|
121
|
+
end
|
122
|
+
alias to= from=
|
123
|
+
alias to from=
|
124
|
+
alias toR from=
|
125
|
+
alias fromR from=
|
126
|
+
end
|
127
|
+
end
|
data/lib/View.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
# ==== DOCUMENT ====
|
2
|
+
|
3
|
+
module Arango
|
4
|
+
class View
|
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[:id].nil?
|
14
|
+
cache_name = "#{database.name}/#{hash[:id]}"
|
15
|
+
cached = database.server.cache.cache.dig(:view, cache_name)
|
16
|
+
if cached.nil?
|
17
|
+
hash[:cache_name] = cache_name
|
18
|
+
return super
|
19
|
+
else
|
20
|
+
body = {}
|
21
|
+
[:type, :name].each{|k| body[k] ||= hash[k]}
|
22
|
+
cached.assign_attributes(body)
|
23
|
+
return cached
|
24
|
+
end
|
25
|
+
end
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(database:, type: "arangosearch", name:, id: nil, cache_name: nil)
|
30
|
+
assign_database(database)
|
31
|
+
unless cache_name.nil?
|
32
|
+
@cache_name = cache_name
|
33
|
+
@server.cache.save(:view, cache_name, self)
|
34
|
+
end
|
35
|
+
satisfy_category?(type, ["arangosearch"])
|
36
|
+
@type = type
|
37
|
+
@name = name
|
38
|
+
@links = {}
|
39
|
+
@id = id
|
40
|
+
end
|
41
|
+
|
42
|
+
# === DEFINE ===
|
43
|
+
|
44
|
+
attr_reader :type, :links, :database, :cache_name
|
45
|
+
attr_accessor :id, :name
|
46
|
+
|
47
|
+
def type=(type)
|
48
|
+
satisfy_category?(type, ["arangosearch"])
|
49
|
+
@type = type
|
50
|
+
end
|
51
|
+
alias assign_type type=
|
52
|
+
|
53
|
+
def addLink(collection:, analyzers: nil, fields: {}, includeAllFields: nil, trackListPositions: nil, storeValues: nil)
|
54
|
+
satisfy_class?(collection, [Arango::Collection, String])
|
55
|
+
collection_name = collection.is_a?(String) ? collection : collection.name
|
56
|
+
satisfy_category?(storeValues, ["none", "id", nil])
|
57
|
+
@links[collection_name] = {
|
58
|
+
analyzers: analyzers,
|
59
|
+
fields: fields,
|
60
|
+
includeAllFields: includeAllFields,
|
61
|
+
trackListPositions: trackListPositions,
|
62
|
+
storeValues: storeValues
|
63
|
+
}
|
64
|
+
@links[collection_name].delete_if{|k,v| v.nil?}
|
65
|
+
end
|
66
|
+
|
67
|
+
def to_h
|
68
|
+
{
|
69
|
+
"name": @name,
|
70
|
+
"id": @id,
|
71
|
+
"type": @type,
|
72
|
+
"links": @links,
|
73
|
+
"cache_name": @cache_name,
|
74
|
+
"database": @database.name
|
75
|
+
}.delete_if{|k,v| v.nil?}
|
76
|
+
end
|
77
|
+
|
78
|
+
def body=(result)
|
79
|
+
@body = result
|
80
|
+
@id = result[:id] || @id
|
81
|
+
@type = assign_type(result[:type] || @type)
|
82
|
+
@links = result[:links] || @links
|
83
|
+
@name = result[:name] || name
|
84
|
+
if @server.active_cache && @cache_name.nil?
|
85
|
+
@cache_name = "#{@database.name}/#{@id}"
|
86
|
+
@server.cache.save(:task, @cache_name, self)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
alias assign_attributes body=
|
90
|
+
|
91
|
+
# === COMMANDS ===
|
92
|
+
|
93
|
+
def retrieve
|
94
|
+
result = @database.request("GET", "_api/view/#{@name}")
|
95
|
+
return result.headers[:"x-arango-async-id"] if @server.async == :store
|
96
|
+
return_element(result)
|
97
|
+
end
|
98
|
+
|
99
|
+
def manage_properties(method, url, consolidationIntervalMsec: nil, threshold: nil, segmentThreshold: nil, cleanupIntervalStep: nil)
|
100
|
+
body = {
|
101
|
+
properties: {
|
102
|
+
links: @links.empty? ? nil : @links,
|
103
|
+
consolidationIntervalMsec: consolidationIntervalMsec,
|
104
|
+
consolidationPolicy: {
|
105
|
+
threshold: threshold,
|
106
|
+
segmentThreshold: segmentThreshold
|
107
|
+
},
|
108
|
+
cleanupIntervalStep: cleanupIntervalStep
|
109
|
+
}
|
110
|
+
}
|
111
|
+
if method == "POST"
|
112
|
+
body[:type] = @type
|
113
|
+
body[:name] = @name
|
114
|
+
end
|
115
|
+
body[:properties][:consolidationPolicy].delete_if{|k,v| v.nil?}
|
116
|
+
body[:properties].delete(:consolidationPolicy) if body[:properties][:consolidationPolicy].empty?
|
117
|
+
body[:properties].delete_if{|k,v| v.nil?}
|
118
|
+
body.delete(:properties) if body[:properties].empty?
|
119
|
+
body.delete_if{|k,v| v.nil?}
|
120
|
+
result = @database.request(method, url, body: body)
|
121
|
+
return_element(result)
|
122
|
+
end
|
123
|
+
private :manage_properties
|
124
|
+
|
125
|
+
def create(consolidationIntervalMsec: nil, threshold: nil, segmentThreshold: nil, cleanupIntervalStep: nil)
|
126
|
+
manage_properties("POST", "_api/view", consolidationIntervalMsec: consolidationIntervalMsec, threshold: threshold, segmentThreshold: segmentThreshold, cleanupIntervalStep: cleanupIntervalStep)
|
127
|
+
end
|
128
|
+
|
129
|
+
def replaceProperties(consolidationIntervalMsec: nil, threshold: nil, segmentThreshold: nil, cleanupIntervalStep: nil)
|
130
|
+
manage_properties("PUT", "_api/view/#{@name}/properties", consolidationIntervalMsec: consolidationIntervalMsec, threshold: threshold, segmentThreshold: segmentThreshold, cleanupIntervalStep: cleanupIntervalStep)
|
131
|
+
end
|
132
|
+
|
133
|
+
def updateProperties(consolidationIntervalMsec: nil, threshold: nil, segmentThreshold: nil, cleanupIntervalStep: nil)
|
134
|
+
manage_properties("PATCH", "_api/view/#{@name}/properties", consolidationIntervalMsec: consolidationIntervalMsec, threshold: threshold, segmentThreshold: segmentThreshold, cleanupIntervalStep: cleanupIntervalStep)
|
135
|
+
end
|
136
|
+
|
137
|
+
def rename name:
|
138
|
+
body = {name: name}
|
139
|
+
result = @database.request("PUT", "_api/view/#{@name}/rename", body: body)
|
140
|
+
return_element(result)
|
141
|
+
end
|
142
|
+
|
143
|
+
def properties
|
144
|
+
@database.request("GET", "_api/view/#{@name}/properties")
|
145
|
+
end
|
146
|
+
|
147
|
+
def destroy
|
148
|
+
@database.request("DELETE", "_api/view/#{@name}", key: :result)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|