13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/sdb_dal/sdb_monkey_patch.rb', line 13
def query_with_attributes(domain, query, max = nil, token = nil)
params = {
'Action' => 'QueryWithAttributes',
'QueryExpression' => query,
'DomainName' => domain.to_s
}
params['NextToken'] =
token unless token.nil? || token.empty?
params['MaxNumberOfItems'] =
max.to_s unless max.nil? || max.to_i == 0
doc = call(:get, params)
results = {}
REXML::XPath.each(doc, '//Item') do |item|
item_attributes={}
item_name = REXML::XPath.first(item, './Name/text()').to_s
REXML::XPath.each(item, "./Attribute") do |attr|
key = REXML::XPath.first(attr, './Name/text()').to_s
value = REXML::XPath.first(attr, './Value/text()').to_s
item_attributes[key]= value
end
results[item_name]=item_attributes
end
return results, REXML::XPath.first(doc, '//NextToken/text()').to_s
end
|