usd 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rusdc +63 -22
- data/change_log.md +1 -1
- data/lib/usd.rb +7 -2
- data/usd.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3fcd67e1d03c8438152bd6a247c644d72b4d7300ae8e434d5e0920772df6473
|
4
|
+
data.tar.gz: 49289a822d2906027417ac0d56d621a1cd1b53766ff651b5069858a8bb221d6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e4f7fde898d1b6477b9c08e96811b738d45e40fffffd16f3c0d474c1629d3e2a0ba4079b453623917a1d111f11b6989e83378b63e728c334936c4ecce271f5b
|
7
|
+
data.tar.gz: b517f049992b629a745e23c0af441814a7f45486a9a0617b6a69ae319cd6c68df9cf0561ac1033d1d4bc63e045d281836067f40e24fc6ca6c2985d9f401967e0
|
data/bin/rusdc
CHANGED
@@ -280,36 +280,77 @@ class Rusdc < Thor
|
|
280
280
|
puts loadcon.update({:type => "json", :data => STDIN.read})
|
281
281
|
end
|
282
282
|
|
283
|
-
desc "update_attr <obj> <common_name> <key> <value>", "updates a direct (not referenced) attribute of one
|
283
|
+
desc "update_attr <obj> <common_name|wc> <key> <value>", "updates a direct (not referenced) attribute of one or more objects."
|
284
284
|
option :plain_text, :type => :boolean, :default => false
|
285
285
|
def update_attr(obj, cn, k, v)
|
286
286
|
if k =~ /(date|last_mod|warranty_start|warranty_end|time_stamp)$/
|
287
287
|
v=Time.parse(v).to_i
|
288
288
|
end
|
289
|
-
if
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
289
|
+
if cn =~ /([<>=]| like )/
|
290
|
+
obj_arr=loadcon.search(obj,{'fields' => "@id","wc"=>"#{cn} and delete_flag.sym = 'Active'"})
|
291
|
+
obj_arr.each do |inner_obj|
|
292
|
+
inner_id=inner_obj["@id"]
|
293
|
+
template = ERB.new <<-EOF
|
294
|
+
{
|
295
|
+
"<%= obj %>": {
|
296
|
+
"@id": "<%= id %>",
|
297
|
+
"<%= k %>": "<%= v %>"
|
298
|
+
}
|
299
|
+
}
|
300
|
+
EOF
|
301
|
+
json = template.result_with_hash({
|
302
|
+
:obj => obj,
|
303
|
+
:id => inner_id,
|
304
|
+
:k => k,
|
305
|
+
:v => v
|
306
|
+
})
|
307
|
+
puts loadcon.update({:type => "json", :data => json})
|
308
|
+
end
|
297
309
|
else
|
298
|
-
|
299
|
-
{
|
300
|
-
|
301
|
-
"@COMMON_NAME"
|
302
|
-
|
310
|
+
if options[:plain_text]
|
311
|
+
data={
|
312
|
+
obj => {
|
313
|
+
"@COMMON_NAME" => cn,
|
314
|
+
k => v
|
303
315
|
}
|
304
316
|
}
|
305
|
-
|
306
|
-
|
317
|
+
json = JSON.pretty_generate(data)
|
318
|
+
else
|
319
|
+
template = ERB.new <<-EOF
|
320
|
+
{
|
321
|
+
"<%= obj %>": {
|
322
|
+
"@COMMON_NAME": "<%= cn %>",
|
323
|
+
"<%= k %>": "<%= v %>"
|
324
|
+
}
|
325
|
+
}
|
326
|
+
EOF
|
327
|
+
json = template.result_with_hash({
|
328
|
+
:obj => obj,
|
329
|
+
:cn => cn,
|
330
|
+
:k => k,
|
331
|
+
:v => v
|
332
|
+
})
|
333
|
+
end
|
334
|
+
puts loadcon.update({:type => "json", :data => json})
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
desc "update_attr_by_id <obj> <id> <key> <value>", "updates a plain attribute of one object by id, does not work"
|
339
|
+
def update_attr_by_id(obj, id, k, v)
|
340
|
+
template = ERB.new <<-EOF
|
341
|
+
{
|
342
|
+
"<%= obj %>": {
|
343
|
+
"@id": "<%= id %>",
|
344
|
+
"<%= k %>": "<%= v %>"
|
345
|
+
}
|
346
|
+
}
|
347
|
+
EOF
|
348
|
+
json = template.result_with_hash({
|
307
349
|
:obj => obj,
|
308
|
-
:
|
350
|
+
:id => id,
|
309
351
|
:k => k,
|
310
352
|
:v => v
|
311
353
|
})
|
312
|
-
end
|
313
354
|
puts loadcon.update({:type => "json", :data => json})
|
314
355
|
end
|
315
356
|
|
@@ -334,12 +375,12 @@ class Rusdc < Thor
|
|
334
375
|
puts loadcon.update({:type => "json", :data => json})
|
335
376
|
end
|
336
377
|
|
337
|
-
desc "update_ref_attr_by_id <obj> <
|
338
|
-
def update_ref_attr_by_id(obj,
|
378
|
+
desc "update_ref_attr_by_id <obj> <id> <key> <value>", "updates a referenced attribute of one object by id"
|
379
|
+
def update_ref_attr_by_id(obj, id, k, v)
|
339
380
|
template = ERB.new <<-EOF
|
340
381
|
{
|
341
382
|
"<%= obj %>": {
|
342
|
-
"@
|
383
|
+
"@id": "<%= id %>",
|
343
384
|
"<%= k %>": {
|
344
385
|
"@id": "<%= v %>"
|
345
386
|
}
|
@@ -348,7 +389,7 @@ class Rusdc < Thor
|
|
348
389
|
EOF
|
349
390
|
json = template.result_with_hash({
|
350
391
|
:obj => obj,
|
351
|
-
:
|
392
|
+
:id => id,
|
352
393
|
:k => k,
|
353
394
|
:v => v
|
354
395
|
})
|
data/change_log.md
CHANGED
data/lib/usd.rb
CHANGED
@@ -147,8 +147,13 @@ class Usd
|
|
147
147
|
end
|
148
148
|
puts "update - data: #{JSON.pretty_generate(data)}" if @debug
|
149
149
|
object = data.keys[0]
|
150
|
-
|
151
|
-
|
150
|
+
if data[object].has_key?("@id")
|
151
|
+
request("/caisd-rest/#{object}/#{data[object]["@id"]}",{:method => "put", :json => data.to_json, :header => header({'X-Obj-Attrs' => 'COMMON_NAME'})})
|
152
|
+
elsif data[object].has_key?("@COMMON_NAME")
|
153
|
+
request("/caisd-rest/#{object}/COMMON_NAME-#{data[object]["@COMMON_NAME"]}",{:method => "put", :json => data.to_json, :header => header({'X-Obj-Attrs' => 'COMMON_NAME'})})
|
154
|
+
else
|
155
|
+
puts "specify @COMMON_NAME or @id at least."
|
156
|
+
end
|
152
157
|
end
|
153
158
|
|
154
159
|
def set_url_parm(params_hash,attribute_name,default)
|
data/usd.gemspec
CHANGED