ruby_aem 0.9.0 → 1.0.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.
- checksums.yaml +4 -4
- data/conf/spec.yaml +47 -70
- data/lib/ruby_aem/client.rb +35 -28
- data/lib/ruby_aem/error.rb +28 -0
- data/lib/ruby_aem/handlers/file.rb +8 -10
- data/lib/ruby_aem/handlers/html.rb +8 -11
- data/lib/ruby_aem/handlers/json.rb +25 -28
- data/lib/ruby_aem/handlers/simple.rb +51 -8
- data/lib/ruby_aem/handlers/xml.rb +7 -9
- data/lib/ruby_aem/resources/bundle.rb +50 -0
- data/lib/ruby_aem/resources/config_property.rb +55 -0
- data/lib/ruby_aem/resources/flush_agent.rb +75 -0
- data/lib/ruby_aem/resources/group.rb +102 -0
- data/lib/ruby_aem/resources/node.rb +65 -0
- data/lib/ruby_aem/resources/package.rb +190 -0
- data/lib/ruby_aem/resources/path.rb +48 -0
- data/lib/ruby_aem/resources/replication_agent.rb +79 -0
- data/lib/ruby_aem/resources/repository.rb +47 -0
- data/lib/ruby_aem/resources/user.rb +113 -0
- data/lib/ruby_aem/{repository.rb → response.rb} +14 -21
- data/lib/ruby_aem/result.rb +12 -36
- data/lib/ruby_aem.rb +30 -30
- metadata +17 -15
- data/lib/ruby_aem/bundle.rb +0 -48
- data/lib/ruby_aem/config_property.rb +0 -53
- data/lib/ruby_aem/flush_agent.rb +0 -65
- data/lib/ruby_aem/group.rb +0 -101
- data/lib/ruby_aem/node.rb +0 -63
- data/lib/ruby_aem/package.rb +0 -187
- data/lib/ruby_aem/path.rb +0 -46
- data/lib/ruby_aem/replication_agent.rb +0 -65
- data/lib/ruby_aem/user.rb +0 -110
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright 2016 Shine Solutions
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
=end
|
|
16
|
+
|
|
17
|
+
module RubyAem
|
|
18
|
+
module Resources
|
|
19
|
+
# Package class contains API calls related to managing an AEM package.
|
|
20
|
+
class Package
|
|
21
|
+
|
|
22
|
+
# Initialise a package.
|
|
23
|
+
# Package name and version will then be used to construct the package file in the filesystem.
|
|
24
|
+
# E.g. package name 'somepackage' with version '1.2.3' will translate to somepackage-1.2.3.zip in the filesystem.
|
|
25
|
+
#
|
|
26
|
+
# @param client RubyAem::Client
|
|
27
|
+
# @param group_name the group name of the package, e.g. somepackagegroup
|
|
28
|
+
# @param package_name the name of the package, e.g. somepackage
|
|
29
|
+
# @param package_version the version of the package, e.g. 1.2.3
|
|
30
|
+
# @return new RubyAem::Resources::Package instance
|
|
31
|
+
def initialize(client, group_name, package_name, package_version)
|
|
32
|
+
@client = client
|
|
33
|
+
@call_params = {
|
|
34
|
+
group_name: group_name,
|
|
35
|
+
package_name: package_name,
|
|
36
|
+
package_version: package_version
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Create the package.
|
|
41
|
+
#
|
|
42
|
+
# @return RubyAem::Result
|
|
43
|
+
def create()
|
|
44
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Update the package with specific filter.
|
|
48
|
+
#
|
|
49
|
+
# @param filter package filter JSON string
|
|
50
|
+
# example: [{"root":"/apps/geometrixx","rules":[]},{"root":"/apps/geometrixx-common","rules":[]}]
|
|
51
|
+
# @return RubyAem::Result
|
|
52
|
+
def update(filter)
|
|
53
|
+
@call_params[:filter] = filter
|
|
54
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Delete the package.
|
|
58
|
+
#
|
|
59
|
+
# @return RubyAem::Result
|
|
60
|
+
def delete()
|
|
61
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Build the package.
|
|
65
|
+
#
|
|
66
|
+
# @return RubyAem::Result
|
|
67
|
+
def build()
|
|
68
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Install the package.
|
|
72
|
+
#
|
|
73
|
+
# @return RubyAem::Result
|
|
74
|
+
def install()
|
|
75
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Replicate the package.
|
|
79
|
+
# Package will then be added to replication agents.
|
|
80
|
+
#
|
|
81
|
+
# @return RubyAem::Result
|
|
82
|
+
def replicate()
|
|
83
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Download the package to a specified directory.
|
|
87
|
+
#
|
|
88
|
+
# @param file_path the directory where the package will be downloaded to
|
|
89
|
+
# @return RubyAem::Result
|
|
90
|
+
def download(file_path)
|
|
91
|
+
@call_params[:file_path] = file_path
|
|
92
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Upload the package.
|
|
96
|
+
#
|
|
97
|
+
# @param file_path the directory where the package file to be uploaded is
|
|
98
|
+
# @param force if true, then overwrite if the package already exists
|
|
99
|
+
# @param opts optional parameters:
|
|
100
|
+
# - force: if false then a package file will not be uploaded when the package already exists with the same group, name, and version, default is true (will overwrite existing package file)
|
|
101
|
+
# @return RubyAem::Result
|
|
102
|
+
def upload(file_path,
|
|
103
|
+
opts = {
|
|
104
|
+
force: true
|
|
105
|
+
})
|
|
106
|
+
@call_params[:file_path] = file_path
|
|
107
|
+
@call_params = @call_params.merge(opts)
|
|
108
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Get the package filter value.
|
|
112
|
+
# Filter value is stored as result data as an array of paths.
|
|
113
|
+
#
|
|
114
|
+
# @return RubyAem::Result
|
|
115
|
+
def get_filter()
|
|
116
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Activate all paths within a package filter.
|
|
120
|
+
# Returns an array of results:
|
|
121
|
+
# - the first result is the result from retrieving filter paths
|
|
122
|
+
# - the rest of the results are the results from activating the filter paths, one result for each activation
|
|
123
|
+
#
|
|
124
|
+
# @param ignore_deactivated if true, then deactivated items in the path will not be activated
|
|
125
|
+
# @param modified_only if true, then only modified items in the path will be activated
|
|
126
|
+
# @return an array of RubyAem::Result
|
|
127
|
+
def activate_filter(ignore_deactivated, modified_only)
|
|
128
|
+
result = get_filter()
|
|
129
|
+
|
|
130
|
+
results = [result]
|
|
131
|
+
result.data.each { |filter_path|
|
|
132
|
+
path = RubyAem::Resources::Path.new(@client, filter_path)
|
|
133
|
+
results.push(path.activate(ignore_deactivated, modified_only))
|
|
134
|
+
}
|
|
135
|
+
results
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# List all packages available in AEM instance.
|
|
139
|
+
#
|
|
140
|
+
# @return RubyAem::Result
|
|
141
|
+
def list_all()
|
|
142
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Check if this package is uploaded.
|
|
146
|
+
# True result data indicates that the package is uploaded, false otherwise.
|
|
147
|
+
#
|
|
148
|
+
# @return RubyAem::Result
|
|
149
|
+
def is_uploaded()
|
|
150
|
+
packages = list_all().data
|
|
151
|
+
package = packages.xpath("//packages/package[group=\"#{@call_params[:group_name]}\" and name=\"#{@call_params[:package_name]}\" and version=\"#{@call_params[:package_version]}\"]")
|
|
152
|
+
|
|
153
|
+
if package.to_s != ''
|
|
154
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is uploaded"
|
|
155
|
+
is_uploaded = true
|
|
156
|
+
else
|
|
157
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is not uploaded"
|
|
158
|
+
is_uploaded = false
|
|
159
|
+
end
|
|
160
|
+
result = RubyAem::Result.new(message, nil)
|
|
161
|
+
result.data = is_uploaded
|
|
162
|
+
|
|
163
|
+
result
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Check if this package is installed.
|
|
167
|
+
# True result data indicates that the package is installed, false otherwise.
|
|
168
|
+
#
|
|
169
|
+
# @return RubyAem::Result
|
|
170
|
+
def is_installed()
|
|
171
|
+
packages = list_all().data
|
|
172
|
+
package = packages.xpath("//packages/package[group=\"#{@call_params[:group_name]}\" and name=\"#{@call_params[:package_name]}\" and version=\"#{@call_params[:package_version]}\"]")
|
|
173
|
+
last_unpacked_by = package.xpath('lastUnpackedBy')
|
|
174
|
+
|
|
175
|
+
if not ['<lastUnpackedBy/>', '<lastUnpackedBy>null</lastUnpackedBy>'].include? last_unpacked_by.to_s
|
|
176
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is installed"
|
|
177
|
+
is_installed = true
|
|
178
|
+
else
|
|
179
|
+
message = "Package #{@call_params[:group_name]}/#{@call_params[:package_name]}-#{@call_params[:package_version]} is not installed"
|
|
180
|
+
is_installed = false
|
|
181
|
+
end
|
|
182
|
+
result = RubyAem::Result.new(message, nil)
|
|
183
|
+
result.data = is_installed
|
|
184
|
+
|
|
185
|
+
result
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright 2016 Shine Solutions
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
=end
|
|
16
|
+
|
|
17
|
+
module RubyAem
|
|
18
|
+
module Resources
|
|
19
|
+
# Path class contains API calls related to managing an AEM path.
|
|
20
|
+
class Path
|
|
21
|
+
|
|
22
|
+
# Initialise a path.
|
|
23
|
+
#
|
|
24
|
+
# @param client RubyAem::Client
|
|
25
|
+
# @param name the name of the path, e.g. /etc/designs
|
|
26
|
+
# @return new RubyAem::Resources::Path instance
|
|
27
|
+
def initialize(client, name)
|
|
28
|
+
@client = client
|
|
29
|
+
@call_params = {
|
|
30
|
+
name: name
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Activate a path.
|
|
35
|
+
#
|
|
36
|
+
# @param ignore_deactivated if true, then deactivated items in the path will not be activated
|
|
37
|
+
# @param only_modified if true, then only modified items in the path will be activated
|
|
38
|
+
# @return RubyAem::Result
|
|
39
|
+
def activate(ignore_deactivated, only_modified)
|
|
40
|
+
@call_params[:ignoredeactivated] = ignore_deactivated
|
|
41
|
+
@call_params[:onlymodified] = only_modified
|
|
42
|
+
|
|
43
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright 2016 Shine Solutions
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
=end
|
|
16
|
+
|
|
17
|
+
module RubyAem
|
|
18
|
+
module Resources
|
|
19
|
+
# ReplicationAgent class contains API calls related to managing an AEM replication agent.
|
|
20
|
+
class ReplicationAgent
|
|
21
|
+
|
|
22
|
+
# Initialise a replication agent.
|
|
23
|
+
#
|
|
24
|
+
# @param client RubyAem::Client
|
|
25
|
+
# @param run_mode AEM run mode: author or publish
|
|
26
|
+
# @param name the replication agent's name, e.g. some-replication-agent
|
|
27
|
+
# @return new RubyAem::Resources::ReplicationAgent instance
|
|
28
|
+
def initialize(client, run_mode, name)
|
|
29
|
+
@client = client
|
|
30
|
+
@call_params = {
|
|
31
|
+
run_mode: run_mode,
|
|
32
|
+
name: name
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Create or update a replication agent.
|
|
37
|
+
#
|
|
38
|
+
# @param title replication agent title
|
|
39
|
+
# @param description replication agent description
|
|
40
|
+
# @param dest_base_url base URL of the agent target destination, e.g. https://somepublisher:4503
|
|
41
|
+
# @param opts optional parameters:
|
|
42
|
+
# - transport_user: username for transport user, default is admin
|
|
43
|
+
# - transport_password: username for transport user, default is admin
|
|
44
|
+
# - log_level: error, info, debug, default is error
|
|
45
|
+
# - retry_delay: in milliseconds, default is 30000
|
|
46
|
+
# @return RubyAem::Result
|
|
47
|
+
def create_update(title, description, dest_base_url,
|
|
48
|
+
opts = {
|
|
49
|
+
transport_user: 'admin',
|
|
50
|
+
transport_password: 'admin',
|
|
51
|
+
log_level: 'error',
|
|
52
|
+
retry_delay: 30000
|
|
53
|
+
})
|
|
54
|
+
@call_params[:title] = title
|
|
55
|
+
@call_params[:description] = description
|
|
56
|
+
@call_params[:dest_base_url] = dest_base_url
|
|
57
|
+
@call_params = @call_params.merge(opts)
|
|
58
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Delete the replication agent.
|
|
62
|
+
#
|
|
63
|
+
# @return RubyAem::Result
|
|
64
|
+
def delete()
|
|
65
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Check whether the replication agent exists or not.
|
|
69
|
+
# If the replication agent exists, this method returns a true result data,
|
|
70
|
+
# false otherwise.
|
|
71
|
+
#
|
|
72
|
+
# @return RubyAem::Result
|
|
73
|
+
def exists()
|
|
74
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright 2016 Shine Solutions
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
=end
|
|
16
|
+
|
|
17
|
+
module RubyAem
|
|
18
|
+
module Resources
|
|
19
|
+
# Repository class contains API calls related to managing an AEM repository.
|
|
20
|
+
class Repository
|
|
21
|
+
|
|
22
|
+
# Initialise repository.
|
|
23
|
+
#
|
|
24
|
+
# @param client RubyAem::Client
|
|
25
|
+
# @return new RubyAem::Resources::Repository instance
|
|
26
|
+
def initialize(client)
|
|
27
|
+
@client = client
|
|
28
|
+
@call_params = {}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Block repository writes.
|
|
32
|
+
#
|
|
33
|
+
# @return RubyAem::Result
|
|
34
|
+
def block_writes
|
|
35
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Unblock repository writes.
|
|
39
|
+
#
|
|
40
|
+
# @return RubyAem::Result
|
|
41
|
+
def unblock_writes
|
|
42
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright 2016 Shine Solutions
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
=end
|
|
16
|
+
|
|
17
|
+
module RubyAem
|
|
18
|
+
module Resources
|
|
19
|
+
# User class contains API calls related to managing an AEM user.
|
|
20
|
+
class User
|
|
21
|
+
|
|
22
|
+
# Initialise a user.
|
|
23
|
+
#
|
|
24
|
+
# @param client RubyAem::Client
|
|
25
|
+
# @param path the path to user node, e.g. /home/users/s/
|
|
26
|
+
# @param name the username of the AEM user, e.g. someuser, admin, johncitizen
|
|
27
|
+
# @return new RubyAem::Resources::User instance
|
|
28
|
+
def initialize(client, path, name)
|
|
29
|
+
@client = client
|
|
30
|
+
@call_params = {
|
|
31
|
+
path: path,
|
|
32
|
+
name: name
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Create a new user.
|
|
37
|
+
#
|
|
38
|
+
# @param password the password of the AEM user
|
|
39
|
+
# @return RubyAem::Result
|
|
40
|
+
def create(password)
|
|
41
|
+
@call_params[:password] = password
|
|
42
|
+
if !@call_params[:path].match(/^\//)
|
|
43
|
+
@call_params[:path] = "/#{@call_params[:path]}"
|
|
44
|
+
end
|
|
45
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Delete the user.
|
|
49
|
+
#
|
|
50
|
+
# @return RubyAem::Result
|
|
51
|
+
def delete()
|
|
52
|
+
result = find_authorizable_id
|
|
53
|
+
@call_params[:authorizable_id] = result.data
|
|
54
|
+
@call_params[:path] = RubyAem::Swagger.path(@call_params[:path])
|
|
55
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Check whether the user exists or not.
|
|
59
|
+
# If the user exists, this method returns a true result data, false
|
|
60
|
+
# otherwise.
|
|
61
|
+
#
|
|
62
|
+
# @return RubyAem::Result
|
|
63
|
+
def exists()
|
|
64
|
+
result = find_authorizable_id
|
|
65
|
+
@call_params[:authorizable_id] = result.data
|
|
66
|
+
@call_params[:path] = RubyAem::Swagger.path(@call_params[:path])
|
|
67
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Set the user's permission.
|
|
71
|
+
#
|
|
72
|
+
# @param permission_path the path that the user's permission is to be set against, e.g. /etc/replication
|
|
73
|
+
# @param permission_csv comma-separated-values of the user's permission, e.g. read:true,modify:true
|
|
74
|
+
# @return RubyAem::Result
|
|
75
|
+
def set_permission(permission_path, permission_csv)
|
|
76
|
+
@call_params[:permission_path] = permission_path
|
|
77
|
+
@call_params[:permission_csv] = permission_csv
|
|
78
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Add user to a group.
|
|
82
|
+
#
|
|
83
|
+
# @param group_path the path to group node, e.g. /home/groups/s/
|
|
84
|
+
# @param group_name the name of the AEM group, e.g. somegroup
|
|
85
|
+
# @return RubyAem::Result
|
|
86
|
+
def add_to_group(group_path, group_name)
|
|
87
|
+
group = RubyAem::Resources::Group.new(@client, group_path, group_name)
|
|
88
|
+
group.add_member(@call_params[:name])
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Change the user's password.
|
|
92
|
+
#
|
|
93
|
+
# @param old_password the user's old password to be changed from
|
|
94
|
+
# @param new_password the user's new password to be changed to
|
|
95
|
+
# @return RubyAem::Result
|
|
96
|
+
def change_password(old_password, new_password)
|
|
97
|
+
@call_params[:old_password] = old_password
|
|
98
|
+
@call_params[:new_password] = new_password
|
|
99
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Find the user's authorizable ID.
|
|
103
|
+
# Return authorizable ID as result data, or nil if authorizable ID
|
|
104
|
+
# cannot be found.
|
|
105
|
+
#
|
|
106
|
+
# @return RubyAem::Result
|
|
107
|
+
def find_authorizable_id()
|
|
108
|
+
@client.call(self.class, __callee__.to_s, @call_params)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -15,30 +15,23 @@ limitations under the License.
|
|
|
15
15
|
=end
|
|
16
16
|
|
|
17
17
|
module RubyAem
|
|
18
|
-
#
|
|
19
|
-
class
|
|
18
|
+
# Response wraps HTTP response data returned by swagger_aem.
|
|
19
|
+
class Response
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# @return new RubyAem::Repository instance
|
|
25
|
-
def initialize(client)
|
|
26
|
-
@client = client
|
|
27
|
-
@info = {}
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Block repository writes.
|
|
31
|
-
#
|
|
32
|
-
# @return RubyAem::Result
|
|
33
|
-
def block_writes
|
|
34
|
-
@client.call(self.class, __callee__.to_s, @info)
|
|
35
|
-
end
|
|
21
|
+
attr_accessor :status_code
|
|
22
|
+
attr_accessor :body
|
|
23
|
+
attr_accessor :headers
|
|
36
24
|
|
|
37
|
-
#
|
|
25
|
+
# Initialise a result.
|
|
38
26
|
#
|
|
39
|
-
# @
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
# @param status_code HTTP status code
|
|
28
|
+
# @param body HTTP response body
|
|
29
|
+
# @param headers HTTP headers
|
|
30
|
+
# @return new RubyAem::Response instance
|
|
31
|
+
def initialize(status_code, body, headers)
|
|
32
|
+
@status_code = status_code
|
|
33
|
+
@body = body
|
|
34
|
+
@headers = headers
|
|
42
35
|
end
|
|
43
36
|
|
|
44
37
|
end
|
data/lib/ruby_aem/result.rb
CHANGED
|
@@ -15,51 +15,27 @@ limitations under the License.
|
|
|
15
15
|
=end
|
|
16
16
|
|
|
17
17
|
module RubyAem
|
|
18
|
-
# Result represents the result of a client call.
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
# Result message is stored in message attribute.
|
|
26
|
-
#
|
|
27
|
-
# Some client calls respond with data payload, which is stored in data attribute.
|
|
18
|
+
# Result class represents the result of a client call.
|
|
19
|
+
# It contains the following attributes:
|
|
20
|
+
# - message: a message string containing the description of the result
|
|
21
|
+
# - response: a RubyAem::Response response from AEM
|
|
22
|
+
# - data: the data payload, which can be of any type depending on the API call
|
|
23
|
+
# e.g. is_* and exists method provide result with boolean data.
|
|
24
|
+
# Some API calls result doesn't contain any data.
|
|
28
25
|
class Result
|
|
29
26
|
|
|
30
27
|
attr_reader :message
|
|
28
|
+
attr_reader :response
|
|
31
29
|
attr_accessor :data
|
|
32
30
|
|
|
33
31
|
# Initialise a result.
|
|
34
32
|
#
|
|
35
|
-
# @param
|
|
36
|
-
# @param
|
|
33
|
+
# @param message result message
|
|
34
|
+
# @param response HTTP response
|
|
37
35
|
# @return new RubyAem::Result instance
|
|
38
|
-
def initialize(
|
|
39
|
-
@status = status
|
|
36
|
+
def initialize(message, response)
|
|
40
37
|
@message = message
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# Check whether the client call was successful.
|
|
44
|
-
#
|
|
45
|
-
# @return true when the status is success
|
|
46
|
-
def is_success?
|
|
47
|
-
return @status == 'success'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Check whether the client call was completed
|
|
51
|
-
# with warnings.
|
|
52
|
-
#
|
|
53
|
-
# @return true when the status is warning
|
|
54
|
-
def is_warning?
|
|
55
|
-
return @status == 'warning'
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Check whether the client call failed.
|
|
59
|
-
#
|
|
60
|
-
# @return true when the status is failure
|
|
61
|
-
def is_failure?
|
|
62
|
-
return @status == 'failure'
|
|
38
|
+
@response = response
|
|
63
39
|
end
|
|
64
40
|
|
|
65
41
|
end
|