hmx_client 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -4
- data/Gemfile +4 -4
- data/Rakefile +1 -1
- data/bin/hmx +33 -33
- data/hmx_client.gemspec +27 -27
- data/lib/hmx/client.rb +167 -167
- data/lib/hmx/command.rb +140 -140
- data/lib/hmx/command/base.rb +195 -194
- data/lib/hmx/command/bootstrap.rb +18 -18
- data/lib/hmx/command/check.rb +170 -0
- data/lib/hmx/command/clone.rb +77 -77
- data/lib/hmx/command/config.rb +67 -67
- data/lib/hmx/command/dump.rb +67 -67
- data/lib/hmx/command/fn.rb +125 -43
- data/lib/hmx/command/fountain.rb +46 -46
- data/lib/hmx/command/get.rb +20 -20
- data/lib/hmx/command/getContent.rb +20 -20
- data/lib/hmx/command/help.rb +114 -114
- data/lib/hmx/command/partition.rb +38 -38
- data/lib/hmx/command/query.rb +22 -22
- data/lib/hmx/command/session.rb +35 -35
- data/lib/hmx/command/task.rb +32 -32
- data/lib/hmx/command/type.rb +45 -45
- data/lib/hmx/command/user.rb +68 -68
- data/lib/hmx/command/view.rb +161 -155
- data/lib/hmx/helpers.rb +76 -61
- data/lib/hmx/hmx.rb +148 -215
- data/lib/hmx/version.rb +3 -3
- data/lib/hmx_client.rb +7 -7
- data/sampleCommands.txt +5 -5
- metadata +12 -11
data/lib/hmx/command/type.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
module HmxClient::Command
|
5
|
-
|
6
|
-
# Display and manage type information in hmx
|
7
|
-
#
|
8
|
-
class Type < Base
|
9
|
-
|
10
|
-
# type
|
11
|
-
#
|
12
|
-
# Display information about a HMX type
|
13
|
-
def index
|
14
|
-
puts JSON.pretty_generate(hmx.
|
15
|
-
end
|
16
|
-
|
17
|
-
# type:create
|
18
|
-
#
|
19
|
-
# Create a type with default settings - no triggers, no entitlements
|
20
|
-
def create
|
21
|
-
typeInfo = { "name" => args.shift, "triggers" => [], "typeNature" => "CONTENT", "typeIndexScript" => ""
|
22
|
-
hmx.
|
23
|
-
puts "Done..."
|
24
|
-
end
|
25
|
-
|
26
|
-
# type:clone-ent
|
27
|
-
#
|
28
|
-
# Clone the entitlements from one type to another
|
29
|
-
#
|
30
|
-
# <srcType> <targType>
|
31
|
-
def clone
|
32
|
-
# We basically load the documents for sys.ent/type/[source]/query and sys.ent/type/[source]/query and copy them to the target
|
33
|
-
sourceType = args.shift
|
34
|
-
targetType = args.shift
|
35
|
-
arr = JSON.parse(hmx.
|
36
|
-
arr["MXEntitlement"]["entitlementPath"] = "type/#{ targetType }/get"
|
37
|
-
hmx.
|
38
|
-
|
39
|
-
arr = JSON.parse(hmx.
|
40
|
-
arr["MXEntitlement"]["entitlementPath"] = "type/#{ targetType }/query"
|
41
|
-
hmx.
|
42
|
-
puts "Done..."
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module HmxClient::Command
|
5
|
+
|
6
|
+
# Display and manage type information in hmx
|
7
|
+
#
|
8
|
+
class Type < Base
|
9
|
+
|
10
|
+
# type
|
11
|
+
#
|
12
|
+
# Display information about a HMX type
|
13
|
+
def index
|
14
|
+
puts JSON.pretty_generate(hmx.doGetType(args))
|
15
|
+
end
|
16
|
+
|
17
|
+
# type:create
|
18
|
+
#
|
19
|
+
# Create a type with default settings - no triggers, no entitlements
|
20
|
+
def create
|
21
|
+
typeInfo = { "name" => args.shift, "triggers" => [], "typeNature" => "CONTENT", "typeIndexScript" => "" }
|
22
|
+
hmx.doUpdateType([typeInfo])
|
23
|
+
puts "Done..."
|
24
|
+
end
|
25
|
+
|
26
|
+
# type:clone-ent
|
27
|
+
#
|
28
|
+
# Clone the entitlements from one type to another
|
29
|
+
#
|
30
|
+
# <srcType> <targType>
|
31
|
+
def clone
|
32
|
+
# We basically load the documents for sys.ent/type/[source]/query and sys.ent/type/[source]/query and copy them to the target
|
33
|
+
sourceType = args.shift
|
34
|
+
targetType = args.shift
|
35
|
+
arr = JSON.parse(hmx.doGetContent(["sys.ent/type/#{ sourceType }/get"]))
|
36
|
+
arr["MXEntitlement"]["entitlementPath"] = "type/#{ targetType }/get"
|
37
|
+
hmx.doPutSimpleData([ "sys.ent/type/#{ targetType}/get", JSON.generate(arr)])
|
38
|
+
|
39
|
+
arr = JSON.parse(hmx.doGetContent(["sys.ent/type/#{ sourceType }/query"]))
|
40
|
+
arr["MXEntitlement"]["entitlementPath"] = "type/#{ targetType }/query"
|
41
|
+
hmx.doPutSimpleData([ "sys.ent/type/#{ targetType}/query", JSON.generate(arr)])
|
42
|
+
puts "Done..."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/hmx/command/user.rb
CHANGED
@@ -1,68 +1,68 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
module HmxClient::Command
|
4
|
-
|
5
|
-
# Manipulate user entities in hmx
|
6
|
-
#
|
7
|
-
class User < Base
|
8
|
-
|
9
|
-
# user
|
10
|
-
#
|
11
|
-
# manipulate user enties in hMX
|
12
|
-
#
|
13
|
-
#
|
14
|
-
def index
|
15
|
-
unless args.size > 0
|
16
|
-
raise CommandFailed, "Usage: hmx user <userId>"
|
17
|
-
end
|
18
|
-
userName = args.shift
|
19
|
-
dout JSON.pretty_generate(hmx.
|
20
|
-
end
|
21
|
-
|
22
|
-
# user:list
|
23
|
-
#
|
24
|
-
# Lists all of the users in the system
|
25
|
-
|
26
|
-
def list
|
27
|
-
views = hmx.
|
28
|
-
views.each { | v |
|
29
|
-
display v.rpartition('/')[2]
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
# user:get
|
34
|
-
#
|
35
|
-
# Retrieves the definition of a user
|
36
|
-
#
|
37
|
-
def get
|
38
|
-
index
|
39
|
-
end
|
40
|
-
|
41
|
-
# user:password
|
42
|
-
#
|
43
|
-
# Sets the password for a user
|
44
|
-
#
|
45
|
-
def password
|
46
|
-
unless args.size > 1
|
47
|
-
raise CommandFailed, "Usage: hmx user:password <userId> <newPassword>"
|
48
|
-
end
|
49
|
-
user = args.shift
|
50
|
-
userName = "sys.user/#{user}"
|
51
|
-
password = Digest::MD5.hexdigest(args.shift)
|
52
|
-
dataDocument = hmx.
|
53
|
-
dataDocument['document']['MXUser']['hashPassword'] = password
|
54
|
-
display hmx.
|
55
|
-
end
|
56
|
-
|
57
|
-
# user:delete
|
58
|
-
#
|
59
|
-
# Removes a user
|
60
|
-
#
|
61
|
-
def delete
|
62
|
-
# We also need to remove the user reference from any groups they belong to (sys.entgroup)
|
63
|
-
# We should be clever and use a custom view for that purpose
|
64
|
-
# something like
|
65
|
-
# (fn[param] (fn[x] (contains (param "user" (.get x '(:document :MXEntitlementGroup :users ))))))
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
module HmxClient::Command
|
4
|
+
|
5
|
+
# Manipulate user entities in hmx
|
6
|
+
#
|
7
|
+
class User < Base
|
8
|
+
|
9
|
+
# user
|
10
|
+
#
|
11
|
+
# manipulate user enties in hMX
|
12
|
+
#
|
13
|
+
#
|
14
|
+
def index
|
15
|
+
unless args.size > 0
|
16
|
+
raise CommandFailed, "Usage: hmx user <userId>"
|
17
|
+
end
|
18
|
+
userName = args.shift
|
19
|
+
dout JSON.pretty_generate(hmx.doGetData(["sys.user/#{userName}"]))
|
20
|
+
end
|
21
|
+
|
22
|
+
# user:list
|
23
|
+
#
|
24
|
+
# Lists all of the users in the system
|
25
|
+
|
26
|
+
def list
|
27
|
+
views = hmx.doQuery(["sys.user", nil])
|
28
|
+
views.each { | v |
|
29
|
+
display v.rpartition('/')[2]
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# user:get
|
34
|
+
#
|
35
|
+
# Retrieves the definition of a user
|
36
|
+
#
|
37
|
+
def get
|
38
|
+
index
|
39
|
+
end
|
40
|
+
|
41
|
+
# user:password
|
42
|
+
#
|
43
|
+
# Sets the password for a user
|
44
|
+
#
|
45
|
+
def password
|
46
|
+
unless args.size > 1
|
47
|
+
raise CommandFailed, "Usage: hmx user:password <userId> <newPassword>"
|
48
|
+
end
|
49
|
+
user = args.shift
|
50
|
+
userName = "sys.user/#{user}"
|
51
|
+
password = Digest::MD5.hexdigest(args.shift)
|
52
|
+
dataDocument = hmx.doGetData([userName])
|
53
|
+
dataDocument['document']['MXUser']['hashPassword'] = password
|
54
|
+
display hmx.doPutData([JSON.generate(dataDocument)])
|
55
|
+
end
|
56
|
+
|
57
|
+
# user:delete
|
58
|
+
#
|
59
|
+
# Removes a user
|
60
|
+
#
|
61
|
+
def delete
|
62
|
+
# We also need to remove the user reference from any groups they belong to (sys.entgroup)
|
63
|
+
# We should be clever and use a custom view for that purpose
|
64
|
+
# something like
|
65
|
+
# (fn[param] (fn[x] (contains (param "user" (.get x '(:document :MXEntitlementGroup :users ))))))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/hmx/command/view.rb
CHANGED
@@ -1,155 +1,161 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
module HmxClient::Command
|
4
|
-
|
5
|
-
# Display the results of a view and list all views
|
6
|
-
#
|
7
|
-
class View < Base
|
8
|
-
|
9
|
-
# view
|
10
|
-
#
|
11
|
-
# run a view in hmx, passing in a view name and an input to the filter function
|
12
|
-
#
|
13
|
-
#
|
14
|
-
def index
|
15
|
-
unless args.size > 0
|
16
|
-
raise CommandFailed, "Usage: hmx view <viewName> <filterContext>"
|
17
|
-
end
|
18
|
-
viewData = hmx.
|
19
|
-
resp = ''
|
20
|
-
viewData.each { | line |
|
21
|
-
line.each { | cell |
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
module HmxClient::Command
|
4
|
+
|
5
|
+
# Display the results of a view and list all views
|
6
|
+
#
|
7
|
+
class View < Base
|
8
|
+
|
9
|
+
# view
|
10
|
+
#
|
11
|
+
# run a view in hmx, passing in a view name and an input to the filter function
|
12
|
+
#
|
13
|
+
#
|
14
|
+
def index
|
15
|
+
unless args.size > 0
|
16
|
+
raise CommandFailed, "Usage: hmx view <viewName> <filterContext>"
|
17
|
+
end
|
18
|
+
viewData = hmx.doRunView([args.shift, JSON.parse(args.shift)])
|
19
|
+
resp = ''
|
20
|
+
viewData.each { | line |
|
21
|
+
line.each { | cell |
|
22
|
+
if (cell.is_a? Array)
|
23
|
+
cell.each { | inner | resp = resp + "%20.20s\t" % inner }
|
24
|
+
else
|
25
|
+
resp = resp + "%20.20s\t" % cell
|
26
|
+
end
|
27
|
+
}
|
28
|
+
resp = resp + "\n"
|
29
|
+
}
|
30
|
+
dout resp
|
31
|
+
end
|
32
|
+
|
33
|
+
# view:list
|
34
|
+
#
|
35
|
+
# Lists all of the views in the system
|
36
|
+
|
37
|
+
def list
|
38
|
+
views = hmx.doQuery(["sys.view", nil])
|
39
|
+
views.each { | v |
|
40
|
+
display v.rpartition('/')[2]
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
# view:get
|
45
|
+
#
|
46
|
+
# Retrieves the definition of a view
|
47
|
+
#
|
48
|
+
def get
|
49
|
+
unless args.size > 0
|
50
|
+
raise CommandFailed, "Usage: hmx view:get <viewName>"
|
51
|
+
end
|
52
|
+
typeName = "sys.view/#{args.shift}"
|
53
|
+
display "Retrieving #{ typeName }"
|
54
|
+
dout JSON.pretty_generate(hmx.doGetData([typeName]))
|
55
|
+
end
|
56
|
+
|
57
|
+
# view:create
|
58
|
+
#
|
59
|
+
# Create a new (initially blank) view.
|
60
|
+
# You will then need to call update to set the filter function, map function, query params and
|
61
|
+
# result columns.
|
62
|
+
#
|
63
|
+
# Views are based on types, for create define a name and the type
|
64
|
+
def create
|
65
|
+
unless args.size > 1
|
66
|
+
raise CommanFailed, "Usage: hmx view:create <viewName> <typeName>"
|
67
|
+
end
|
68
|
+
view = args.shift
|
69
|
+
viewName = "sys.view/#{view}"
|
70
|
+
typeName = args.shift
|
71
|
+
|
72
|
+
dataDocument = {
|
73
|
+
"MXView" => {
|
74
|
+
:typeName => typeName,
|
75
|
+
:parameterNames => [],
|
76
|
+
:filterFn => "",
|
77
|
+
:mappingFn => "",
|
78
|
+
:resultColumns => [],
|
79
|
+
:viewName => view
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
dout JSON.pretty_generate(hmx.doPutSimpleData([viewName, JSON.generate(dataDocument)]))
|
84
|
+
end
|
85
|
+
|
86
|
+
# view:updateFilter
|
87
|
+
#
|
88
|
+
# Set the filter function for a view
|
89
|
+
#
|
90
|
+
def updateFilter
|
91
|
+
unless args.size > 1
|
92
|
+
raise CommandFailed, "Usage: hmx view:updateFilter <viewName> <filterFn>"
|
93
|
+
end
|
94
|
+
view = args.shift
|
95
|
+
viewName = "sys.view/#{view}"
|
96
|
+
filterFn = args.shift
|
97
|
+
|
98
|
+
dataDocument = hmx.doGetData([viewName])
|
99
|
+
puts dataDocument
|
100
|
+
dataDocument['document']['MXView']['filterFn'] = filterFn
|
101
|
+
display hmx.doPutData([JSON.generate(dataDocument)])
|
102
|
+
end
|
103
|
+
# view:updateMap
|
104
|
+
#
|
105
|
+
# Set the map function for a view
|
106
|
+
#
|
107
|
+
def updateMap
|
108
|
+
unless args.size > 1
|
109
|
+
raise CommandFailed, "Usage: hmx view:updateMap <viewName> <filterFn>"
|
110
|
+
end
|
111
|
+
view = args.shift
|
112
|
+
viewName = "sys.view/#{view}"
|
113
|
+
mapFn = args.shift
|
114
|
+
dataDocument = hmx.doGetData([viewName])
|
115
|
+
dataDocument['document']['MXView']['mappingFn'] = mapFn
|
116
|
+
display hmx.doPutData([JSON.generate(dataDocument)])
|
117
|
+
end
|
118
|
+
# view:updateParam
|
119
|
+
#
|
120
|
+
# Set the parameter names for a view
|
121
|
+
#
|
122
|
+
def updateParam
|
123
|
+
unless args.size > 1
|
124
|
+
raise CommandFailed, "Usage: hmx view:updateParam <viewName> <param> [<param2> ...]"
|
125
|
+
end
|
126
|
+
view = args.shift
|
127
|
+
viewName = "sys.view/#{view}"
|
128
|
+
dataDocument = hmx.doGetData([viewName])
|
129
|
+
dataDocument['document']['MXView']['parameterNames'] = args
|
130
|
+
display hmx.doPutData([JSON.generate(dataDocument)])
|
131
|
+
end
|
132
|
+
# view:updateResult
|
133
|
+
#
|
134
|
+
# Set the result names for a view
|
135
|
+
#
|
136
|
+
def updateResult
|
137
|
+
unless args.size > 1
|
138
|
+
raise CommandFailed, "Usage: hmx view:updateResult <viewName> <param> [<param2> ...]"
|
139
|
+
end
|
140
|
+
view = args.shift
|
141
|
+
viewName = "sys.view/#{view}"
|
142
|
+
|
143
|
+
dataDocument = hmx.doGetData([viewName])
|
144
|
+
dataDocument['document']['MXView']['resultColumns'] = args
|
145
|
+
display hmx.doPutData([JSON.generate(dataDocument)])
|
146
|
+
end
|
147
|
+
# view:delete
|
148
|
+
#
|
149
|
+
# Delete a view definition
|
150
|
+
#
|
151
|
+
def delete
|
152
|
+
unless args.size >0
|
153
|
+
raise CommandFailed, "Usage: hmx view:delete <viewName>"
|
154
|
+
end
|
155
|
+
view = args.shift
|
156
|
+
viewName = "sys.view/#{view}"
|
157
|
+
display hmx.doDeleteData([viewName])
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
end
|