usd 0.2.5.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -10
- data/bin/rusdc +172 -15
- data/change_log.md +97 -0
- data/lib/usd.rb +78 -0
- data/usd.gemspec +16 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4448a1b65d863520eea90c9fd76f4bc27f437871697c5d5efc150a7cdf6fe30b
|
4
|
+
data.tar.gz: a8e0416e4e629b95add9bdf050fab5a3e8f77d9369147dd006b26a2910bb9a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2982682a3d2df44517df1129aa2754bc9824b56c170c0af053272ac4f89ac1404832d94062058620c6b3668902b78cc99e1d2d55604eb511664204839d799a39
|
7
|
+
data.tar.gz: 155b49fb190294484d453b90716c1a8b6da0d9715a617d634be775e4a221991451b03c8f9948c7dce2a6008f13f6c373bd91d64c79deece02a48fdfe28df2921
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
There is a ruby class and a commandline tool rusdc.
|
5
5
|
|
6
|
+
[![asciicast](https://asciinema.org/a/7zw3RLpikFluqX9XJMxCpMEmS.svg)](https://asciinema.org/a/7zw3RLpikFluqX9XJMxCpMEmS)
|
7
|
+
|
6
8
|
# installation
|
7
9
|
|
8
10
|
just install the gem:
|
@@ -23,37 +25,45 @@ yum install ruby-devel
|
|
23
25
|
|
24
26
|
# documentation
|
25
27
|
|
26
|
-
see [https://github.com/ogaida/usd/wiki](https://github.com/ogaida/usd/wiki)
|
28
|
+
- see [https://github.com/ogaida/usd/wiki](https://github.com/ogaida/usd/wiki)
|
29
|
+
- if you are looking for dependencies in between the objects, objectnames or relational objects, then have a look at [techdocs.broadcom.com](https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/business-management/ca-service-management/14-1/reference/ca-service-desk-manager-reference-commands/objects-and-attributes.html)
|
27
30
|
|
28
31
|
## bash-completion
|
29
32
|
|
30
33
|
see [https://github.com/ogaida/usd/wiki/bash-completion](https://github.com/ogaida/usd/wiki/bash-completion)
|
31
34
|
|
32
|
-
# external tools
|
35
|
+
# external tools / requirements
|
33
36
|
|
34
37
|
If you use the `rusdc find` command with `--format mlr` option then you need `mlr`.
|
35
38
|
|
36
39
|
- [mlr - Miller](http://johnkerl.org/miller/doc/index.html) - a great tool for data-transforming to and from json, csv and many more
|
37
40
|
|
38
|
-
Place the `mlr`-binary in a path, which is in your PATH-Environment. Download-Url for mlr-releases: [https://github.com/johnkerl/miller/releases](https://github.com/johnkerl/miller/releases)
|
41
|
+
Place the `mlr`-binary in a path, which is in your PATH-Environment. Download-Url for mlr-releases: [https://github.com/johnkerl/miller/releases](https://github.com/johnkerl/miller/releases).
|
42
|
+
|
43
|
+
For uloading attachments `unix2dos` and `base64` is used.
|
39
44
|
|
40
45
|
# functions from the commandline-tool `rusdc`
|
41
46
|
|
42
47
|
```
|
48
|
+
rusdc chg_add_attachment <co> <file> # attach the file to co
|
43
49
|
rusdc chg_add_nr <co> <ci> # add a CI to a changeorder
|
44
50
|
rusdc chg_list_nr <co> # list all CIs of one changeorder
|
45
51
|
rusdc create # pipe json-data to create object
|
46
52
|
rusdc field_names <object-type> [wc] # list all fields of an object including its format
|
47
53
|
rusdc find <object-type> [where-clause] [fields, comma separated] [options] # finds each object which meets the wc-condition
|
48
54
|
rusdc get <object-type> <common_name|id> # shows one object by name or id
|
49
|
-
rusdc get_all_attachments_of_co <co_name> # get all attachments of a changeorder and save all
|
50
|
-
rusdc get_attachment_of_ci <ci_name> <filename> # download an attachment of a CI and print it out on
|
51
|
-
rusdc get_attachment_of_co <co_name> <filename> # download an attachment of a changeorder and print it
|
55
|
+
rusdc get_all_attachments_of_co <co_name> # get all attachments of a changeorder and save all these to current folder
|
56
|
+
rusdc get_attachment_of_ci <ci_name> <filename> # download an attachment of a CI and print it out on stdout
|
57
|
+
rusdc get_attachment_of_co <co_name> <filename> # download an attachment of a changeorder and print it out on stdout
|
58
|
+
rusdc get_attachment_of_in <incident> <filename> # download an attachment of an Incident and print it out on stdout
|
52
59
|
rusdc help [COMMAND] # Describe available commands or one specific command
|
53
60
|
rusdc in_add_2_chg <changeorder> <incident> # add incident to changeorder
|
61
|
+
rusdc in_add_attachment <in> <file> # attach the file to incident
|
54
62
|
rusdc in_list_child_ins <in> # list all child-incidents of one incident
|
55
63
|
rusdc list_attachments_of_ci <ci_name> # list all attachments of a CI
|
56
64
|
rusdc list_attachments_of_co <co_name> # list all attachments of a changeorder
|
65
|
+
rusdc list_attachments_of_in <in> # list all attachments of an Incident
|
66
|
+
rusdc nr_add_attachment <nr> <file> # attach the file to nr
|
57
67
|
rusdc nr_add_child <nr-name> <child-name> # add one child CI to another CI
|
58
68
|
rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem
|
59
69
|
rusdc nr_changes <nr> [inactive-too] # list all open changeorders of one CI
|
@@ -61,10 +71,11 @@ rusdc nr_childs <ci-name> # l
|
|
61
71
|
rusdc nr_incidents <nr> [inactive-too] # lists all incident of a specific CI
|
62
72
|
rusdc nr_parents <ci-name> # lists all parent CIs of a specific CI
|
63
73
|
rusdc update # pipe json-data to update object
|
64
|
-
rusdc update_attr <obj> <common_name|wc> <key> <value> # updates a direct (not referenced) attribute of one
|
65
|
-
rusdc update_attr_by_id <obj> <id> <key> <value> # updates a plain attribute of one object by id, does
|
66
|
-
rusdc update_ref_attr <obj> <common_name> <key> <value>
|
67
|
-
rusdc update_ref_attr_by_id <obj> <id> <key> <value_id> # updates a referenced attribute of one object_id by
|
74
|
+
rusdc update_attr <obj> <common_name|wc> <key> <value> # updates a direct (not referenced) attribute of one or more objects.
|
75
|
+
rusdc update_attr_by_id <obj> <id> <key> <value> # updates a plain attribute of one object by id, does not work
|
76
|
+
rusdc update_ref_attr <obj> <common_name> <key> <value> [ref_obj=nr] # updates a referenced attribute of one object.
|
77
|
+
rusdc update_ref_attr_by_id <obj> <id> <key> <value_id> # updates a referenced attribute of one object_id by value-id
|
78
|
+
rusdc vcard_via_email <email> # creates a vcard from the given email-address and saves it in the /tmp directory.
|
68
79
|
```
|
69
80
|
|
70
81
|
# environment-variables
|
data/bin/rusdc
CHANGED
@@ -7,6 +7,31 @@ require "usd"
|
|
7
7
|
|
8
8
|
class Rusdc < Thor
|
9
9
|
|
10
|
+
desc "chg_add_attachment <co> <file>", "attach the file to co"
|
11
|
+
def chg_add_attachment(co, file)
|
12
|
+
response = upload_attachment(file, loadcon.base_url, loadcon.access_key)
|
13
|
+
puts response
|
14
|
+
data = JSON.parse(response)
|
15
|
+
template = ERB.new <<-EOF
|
16
|
+
{
|
17
|
+
"lrel_attachments_changes": {
|
18
|
+
"attmnt": {
|
19
|
+
"@id": "<%= id %>"
|
20
|
+
},
|
21
|
+
"chg": {
|
22
|
+
"@COMMON_NAME": "<%= co %>"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
EOF
|
27
|
+
json = template.result_with_hash({
|
28
|
+
:id => data["attmnt"]["@id"],
|
29
|
+
:co => co
|
30
|
+
})
|
31
|
+
#puts "create relation to chg with json: #{json}"
|
32
|
+
puts loadcon.create({:type => "json", :data => json})
|
33
|
+
end
|
34
|
+
|
10
35
|
desc "chg_add_nr <co> <ci>", "add a CI to a changeorder"
|
11
36
|
def chg_add_nr(co, ci)
|
12
37
|
template = ERB.new <<-EOF
|
@@ -127,6 +152,7 @@ class Rusdc < Thor
|
|
127
152
|
case options[:format]
|
128
153
|
when "json"
|
129
154
|
puts mlr
|
155
|
+
e
|
130
156
|
exit exitcode
|
131
157
|
when "yaml"
|
132
158
|
# keys not sorted, maybe a todo
|
@@ -193,11 +219,10 @@ class Rusdc < Thor
|
|
193
219
|
end
|
194
220
|
end
|
195
221
|
|
196
|
-
desc "
|
197
|
-
def
|
198
|
-
|
199
|
-
|
200
|
-
att_nr.each do |att|
|
222
|
+
desc "get_attachment_of_in <incident> <filename>", "download an attachment of an Incident and print it out on stdout"
|
223
|
+
def get_attachment_of_in(incident, filename)
|
224
|
+
att_in = loadcon.search("lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num = '#{incident}'"})
|
225
|
+
att_in.each do |att|
|
201
226
|
attmnt = loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]
|
202
227
|
if attmnt["orig_file_name"] == filename
|
203
228
|
puts loadcon.request("/caisd-rest/attmnt/#{attmnt["@id"]}/file-resource",{:unchanged => true})
|
@@ -205,6 +230,41 @@ class Rusdc < Thor
|
|
205
230
|
end
|
206
231
|
end
|
207
232
|
|
233
|
+
# in: lrel_attachments_requests ?
|
234
|
+
|
235
|
+
desc "get_attachment_of_co <co_name> <filename>", "download an attachment of a changeorder and print it out on stdout"
|
236
|
+
def get_attachment_of_co(coname, filename)
|
237
|
+
ids = loadcon.search("lrel_attachments_changes",{'fields' => "*","wc" => "chg.chg_ref_num = 'CO341144' and attmnt.orig_file_name = 'IMAP61A845F524A9D06536_3212.eml'"})
|
238
|
+
puts loadcon.request("/caisd-rest/attmnt/#{ids[0]["@id"]}/file-resource",{:unchanged => true}) if ids.class == Array
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
#lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num
|
243
|
+
desc "in_add_attachment <in> <file>", "attach the file to incident"
|
244
|
+
def in_add_attachment(incident, file)
|
245
|
+
response = upload_attachment(file, loadcon.base_url, loadcon.access_key)
|
246
|
+
puts response
|
247
|
+
data = JSON.parse(response)
|
248
|
+
template = ERB.new <<-EOF
|
249
|
+
{
|
250
|
+
"lrel_attachments_requests": {
|
251
|
+
"attmnt": {
|
252
|
+
"@id": "<%= id %>"
|
253
|
+
},
|
254
|
+
"cr": {
|
255
|
+
"@COMMON_NAME": "<%= incident %>"
|
256
|
+
}
|
257
|
+
}
|
258
|
+
}
|
259
|
+
EOF
|
260
|
+
json = template.result_with_hash({
|
261
|
+
:id => data["attmnt"]["@id"],
|
262
|
+
:incident => incident
|
263
|
+
})
|
264
|
+
#puts "create relation to chg with json: #{json}"
|
265
|
+
puts loadcon.create({:type => "json", :data => json})
|
266
|
+
end
|
267
|
+
|
208
268
|
desc "in_add_2_chg <changeorder> <incident>", "add incident to changeorder"
|
209
269
|
def in_add_2_chg(chg, incident)
|
210
270
|
invoke('update_ref_attr',['in', incident, 'change', chg])
|
@@ -226,12 +286,46 @@ class Rusdc < Thor
|
|
226
286
|
desc "list_attachments_of_co <co_name>", "list all attachments of a changeorder"
|
227
287
|
def list_attachments_of_co(coname)
|
228
288
|
chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
|
229
|
-
|
230
|
-
|
289
|
+
att_chg = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
|
290
|
+
att_chg.each do |att|
|
291
|
+
puts loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]["orig_file_name"]
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
desc "list_attachments_of_in <in>", "list all attachments of an Incident"
|
296
|
+
def list_attachments_of_in(incident)
|
297
|
+
att_in = loadcon.search("lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num = '#{incident}'"})
|
298
|
+
att_in.each do |att|
|
231
299
|
puts loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]["orig_file_name"]
|
232
300
|
end
|
233
301
|
end
|
234
302
|
|
303
|
+
desc "nr_add_attachment <nr> <file>", "attach the file to nr"
|
304
|
+
def nr_add_attachment(nr, file)
|
305
|
+
response = upload_attachment(file, loadcon.base_url, loadcon.access_key)
|
306
|
+
puts response
|
307
|
+
data = JSON.parse(response)
|
308
|
+
nr_id = loadcon.search("nr",{'fields' => "@id","wc" => "name = '#{nr}'"})[0]["@id"]
|
309
|
+
template = ERB.new <<-EOF
|
310
|
+
{
|
311
|
+
"lrel_attachments_nr": {
|
312
|
+
"attmnt": {
|
313
|
+
"@id": "<%= id %>"
|
314
|
+
},
|
315
|
+
"nr": {
|
316
|
+
"@id": "<%= nr_id %>"
|
317
|
+
}
|
318
|
+
}
|
319
|
+
}
|
320
|
+
EOF
|
321
|
+
json = template.result_with_hash({
|
322
|
+
:id => data["attmnt"]["@id"],
|
323
|
+
:nr_id => nr_id
|
324
|
+
})
|
325
|
+
#puts "create relation to chg with json: #{json}"
|
326
|
+
puts loadcon.create({:type => "json", :data => json})
|
327
|
+
end
|
328
|
+
|
235
329
|
desc "nr_add_child <nr-name> <child-name>", "add one child CI to another CI"
|
236
330
|
def nr_add_child(nr, child)
|
237
331
|
template = ERB.new <<-EOF
|
@@ -250,11 +344,6 @@ class Rusdc < Thor
|
|
250
344
|
puts loadcon.create({:type => "json", :data => json})
|
251
345
|
end
|
252
346
|
|
253
|
-
# $ rusdc find lrel_oenv_orgref "nr.name like 'servername1'" org
|
254
|
-
# [{
|
255
|
-
# "org": "Orname1"
|
256
|
-
# }]
|
257
|
-
|
258
347
|
desc "nr_add_org <nr> <org>", "add an Organisation to a ConfigurationItem"
|
259
348
|
def nr_add_org(nr, org)
|
260
349
|
template = ERB.new <<-EOF
|
@@ -388,8 +477,8 @@ class Rusdc < Thor
|
|
388
477
|
puts loadcon.update({:type => "json", :data => json})
|
389
478
|
end
|
390
479
|
|
391
|
-
desc "update_ref_attr <obj> <common_name> <key> <value>", "updates a referenced attribute of one object."
|
392
|
-
def update_ref_attr(obj, cn, k, v)
|
480
|
+
desc "update_ref_attr <obj> <common_name> <key> <value> [ref_obj=nr]", "updates a referenced attribute of one object."
|
481
|
+
def update_ref_attr(obj, cn, k, v, ref_obj = "nr")
|
393
482
|
template = ERB.new <<-EOF
|
394
483
|
{
|
395
484
|
"<%= obj %>": {
|
@@ -406,7 +495,15 @@ class Rusdc < Thor
|
|
406
495
|
:k => k,
|
407
496
|
:v => v
|
408
497
|
})
|
409
|
-
|
498
|
+
data = loadcon.update({:type => "json", :data => json})
|
499
|
+
if data.class == RestClient::BadRequest
|
500
|
+
puts "BadRequest-Response from USD-API, try to update via IDs. be aware to specify a ref_obj if it's not nr."
|
501
|
+
cn_id = loadcon.search(obj,{'fields' => "@id","wc" => "#{Usd::CN[obj]} = '#{cn}' and delete_flag = 0"})[0]["@id"]
|
502
|
+
value_id = loadcon.search(ref_obj,{'fields' => "@id","wc" => "#{Usd::CN[ref_obj]} = '#{v}' and delete_flag = 0"})[0]["@id"]
|
503
|
+
invoke "update_ref_attr_by_id", [obj, cn_id, k, value_id]
|
504
|
+
else
|
505
|
+
puts data
|
506
|
+
end
|
410
507
|
end
|
411
508
|
|
412
509
|
desc "update_ref_attr_by_id <obj> <id> <key> <value_id>", "updates a referenced attribute of one object_id by value-id"
|
@@ -430,6 +527,36 @@ class Rusdc < Thor
|
|
430
527
|
puts loadcon.update({:type => "json", :data => json})
|
431
528
|
end
|
432
529
|
|
530
|
+
desc "vcard_via_email <email>", "creates a vcard from the given email-address and saves it in the /tmp directory."
|
531
|
+
def vcard_via_email(email)
|
532
|
+
cnt = loadcon.search("cnt",{'fields' => "*","wc" => "email_address = '#{email}' and delete_flag = 0"})[0]
|
533
|
+
template = ERB.new <<-EOF
|
534
|
+
BEGIN:VCARD
|
535
|
+
VERSION:2.1
|
536
|
+
N;LANGUAGE=de:;<%= last_name %>;<%= first_name %>
|
537
|
+
FN:<%= last_name %>, <%= first_name %>
|
538
|
+
TEL;WORK;VOICE:<%= phone_number %>
|
539
|
+
TEL;CELL;VOICE:<%= mobile_phone %>
|
540
|
+
EMAIL;PREF;INTERNET:<%= email_address %>
|
541
|
+
X-MS-OL-DEFAULT-POSTAL-ADDRESS:0
|
542
|
+
X-MS-OL-DESIGN;CHARSET=utf-8:<card xmlns="http://schemas.microsoft.com/office/outlook/12/electronicbusinesscards" ver="1.0" layout="left" bgcolor="ffffff"><img xmlns="" align="fit" area="16" use="cardpicture"/><fld xmlns="" prop="name" align="left" dir="ltr" style="b" color="000000" size="10"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="telwork" align="left" dir="ltr" color="d48d2a" size="8"><label align="right" color="626262">Geschäftlich</label></fld><fld xmlns="" prop="telcell" align="left" dir="ltr" color="d48d2a" size="8"><label align="right" color="626262">Mobiltelefon</label></fld><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/><fld xmlns="" prop="blank" size="8"/></card>
|
543
|
+
REV:<%= time %>
|
544
|
+
END:VCARD
|
545
|
+
EOF
|
546
|
+
vcard=template.result_with_hash({
|
547
|
+
:last_name => cnt["last_name"],
|
548
|
+
:first_name => cnt["first_name"],
|
549
|
+
:email_address => cnt["email_address"],
|
550
|
+
:phone_number => cnt["phone_number"],
|
551
|
+
:mobile_phone => cnt["mobile_phone"],
|
552
|
+
:time => Time.now.strftime("%Y%m%dT%H%M%SZ")
|
553
|
+
})
|
554
|
+
file = `mktemp /tmp/#{cnt["last_name"]}-XXXXX.vcf`.chop
|
555
|
+
f = File.open(file,"w+")
|
556
|
+
f.puts vcard
|
557
|
+
f.close
|
558
|
+
puts "the vcard for #{cnt["first_name"]} #{cnt["last_name"]} was created under: #{file}"
|
559
|
+
end
|
433
560
|
|
434
561
|
private
|
435
562
|
|
@@ -442,6 +569,36 @@ class Rusdc < Thor
|
|
442
569
|
end
|
443
570
|
end
|
444
571
|
|
572
|
+
def upload_attachment(file, baseurl, ak)
|
573
|
+
baseurl =~ /^([^:]+):/
|
574
|
+
server = $1
|
575
|
+
filename = File.basename(file)
|
576
|
+
uri = "/caisd-rest/attmnt?repositoryId=1002&serverName=#{server}&mimeType=Text&description=#{filename}"
|
577
|
+
url = URI("#{baseurl}#{uri}")
|
578
|
+
tempfile = Tempfile.new('base64_encoding')
|
579
|
+
temp_path=tempfile.path
|
580
|
+
tempfile.write("")
|
581
|
+
tempfile.close
|
582
|
+
cmd = %(base64 "#{file}" > #{temp_path})
|
583
|
+
`#{cmd}`
|
584
|
+
cmd = %(unix2dos #{tempfile.path})
|
585
|
+
`#{cmd}`
|
586
|
+
fileObj = File.open(temp_path, "rb")
|
587
|
+
fileContent = fileObj.read
|
588
|
+
fileObj.close
|
589
|
+
tempfile.unlink
|
590
|
+
http = Net::HTTP.new(url.host, url.port);
|
591
|
+
request = Net::HTTP::Post.new(url)
|
592
|
+
request["X-AccessKey"] = ak
|
593
|
+
request["Content-Type"] = "multipart/form-data; BOUNDARY=*****MessageBoundary*****"
|
594
|
+
request["accept"] = "application/json"
|
595
|
+
request["Cache-Control"] = "no-cache"
|
596
|
+
request.body = "--*****MessageBoundary*****\r\n \r\nContent-Disposition: form-data; name=\"payload\" \r\nContent-Type: application/xml; CHARACTERSET=UTF-8 \r\n\r\n \r\n<attmnt> \r\n<repository id=\"1002\"></repository> \r\n<orig_file_name>#{filename}</orig_file_name> \r\n<attmnt_name>#{filename}</attmnt_name> \r\n<description>Uploaded with rusdc from rubygem usd</description> \r\n</attmnt> \r\n\r\n \r\n--*****MessageBoundary*****\r\n \r\nContent-Disposition: form-data; name=\"#{filename}\"; filename=\"#{filename}\" \r\nContent-Type: application/octet-stream \r\nContent-Transfer-Encoding: base64\r\n\r\n#{fileContent}\r\n\r\n \r\n--*****MessageBoundary*****--\r\n"
|
597
|
+
|
598
|
+
response = http.request(request)
|
599
|
+
response.read_body
|
600
|
+
end
|
601
|
+
|
445
602
|
end
|
446
603
|
|
447
604
|
Rusdc.start(ARGV)
|
data/change_log.md
CHANGED
@@ -1,5 +1,102 @@
|
|
1
1
|
# rusdc changelog
|
2
2
|
|
3
|
+
## 1.3.1
|
4
|
+
|
5
|
+
- new functions:
|
6
|
+
- `chg_add_attachment`
|
7
|
+
- `nr_add_attachment`
|
8
|
+
- `in_chg_add_attachment`
|
9
|
+
- `vcard_via_email`
|
10
|
+
|
11
|
+
with the first three funtions you are able to upload files to changeorders, configurationitems and incidents and it does not matter if it is text or binary. the last new function creates vcards in version 2.1 from a contact via its email as identifier.
|
12
|
+
|
13
|
+
## 1.2
|
14
|
+
|
15
|
+
- now in Usd.search function:
|
16
|
+
- whereclause is enriched with "common_name like '% wc%'" if it is not a valid whereclause.
|
17
|
+
|
18
|
+
## 1.0 and 1.1
|
19
|
+
|
20
|
+
- `update_ref_attr` rusdc-function fetches the IDs to update the object by itself.
|
21
|
+
|
22
|
+
## 0.3
|
23
|
+
|
24
|
+
- some common_name resolution
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
class Usd
|
28
|
+
CN={
|
29
|
+
"chg" => "chg_ref_num",
|
30
|
+
"cnt" => "combo_name",
|
31
|
+
"arcpur_rule" => "name",
|
32
|
+
"ca_tou" => "name",
|
33
|
+
"cost_cntr" => "name",
|
34
|
+
"country" => "name",
|
35
|
+
"dept" => "name",
|
36
|
+
"gl_code" => "name",
|
37
|
+
"job_func" => "name",
|
38
|
+
"loc" => "name",
|
39
|
+
"nr" => "name",
|
40
|
+
"opsys" => "name",
|
41
|
+
"org" => "name",
|
42
|
+
"tab" => "name",
|
43
|
+
"auto_close" => "sym",
|
44
|
+
"aty" => "sym",
|
45
|
+
"act_type_assoc" => "sym",
|
46
|
+
"ca_cmpny" => "sym",
|
47
|
+
"closure_code" => "sym",
|
48
|
+
"cmth" => "sym",
|
49
|
+
"symptom_code" => "sym",
|
50
|
+
"state" => "sym",
|
51
|
+
"crt" => "sym",
|
52
|
+
"ctab" => "sym",
|
53
|
+
"ctp" => "sym",
|
54
|
+
"dcon_typ" => "sym",
|
55
|
+
"dlgsrvr" => "sym",
|
56
|
+
"dmn" => "sym",
|
57
|
+
"doc_rep" => "sym",
|
58
|
+
"fmgrp" => "sym",
|
59
|
+
"ical_alarm" => "sym",
|
60
|
+
"ical_event_template" => "sym",
|
61
|
+
"imp" => "sym",
|
62
|
+
"intfc" => "sym",
|
63
|
+
"kwrd" => "sym",
|
64
|
+
"mfrmod" => "sym",
|
65
|
+
"mgsstat" => "sym",
|
66
|
+
"nrf" => "sym",
|
67
|
+
"options" => "sym",
|
68
|
+
"outage_type" => "sym",
|
69
|
+
"perscnt" => "sym",
|
70
|
+
"position" => "sym",
|
71
|
+
"pr_trans" => "sym",
|
72
|
+
"prod" => "sym",
|
73
|
+
"quick_tpl_types" => "sym",
|
74
|
+
"rc" => "sym",
|
75
|
+
"resocode" => "sym",
|
76
|
+
"resomethod" => "sym",
|
77
|
+
"response" => "sym",
|
78
|
+
"rrf" => "sym",
|
79
|
+
"rss" => "sym",
|
80
|
+
"seq" => "sym",
|
81
|
+
"sev" => "sym",
|
82
|
+
"site" => "sym",
|
83
|
+
"slatpl" => "sym",
|
84
|
+
"special_handling" => "sym",
|
85
|
+
"svc_contract" => "sym",
|
86
|
+
"typecnt" => "sym",
|
87
|
+
"tz" => "sym",
|
88
|
+
"tspan" => "sym",
|
89
|
+
"transition_type" => "sym",
|
90
|
+
"urg" => "sym",
|
91
|
+
"vpt" => "sym",
|
92
|
+
"wrkshft" => "sym",
|
93
|
+
"cr" => "ref_num",
|
94
|
+
"in" => "ref_num",
|
95
|
+
"pr" => "ref_num"
|
96
|
+
}
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
3
100
|
## 0.2.5.3
|
4
101
|
|
5
102
|
- neu function : `rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem`
|
data/lib/usd.rb
CHANGED
@@ -10,6 +10,76 @@ require 'tempfile'
|
|
10
10
|
|
11
11
|
class Usd
|
12
12
|
|
13
|
+
CN={
|
14
|
+
"chg" => "chg_ref_num",
|
15
|
+
"cnt" => "combo_name",
|
16
|
+
"arcpur_rule" => "name",
|
17
|
+
"ca_tou" => "name",
|
18
|
+
"cost_cntr" => "name",
|
19
|
+
"country" => "name",
|
20
|
+
"dept" => "name",
|
21
|
+
"gl_code" => "name",
|
22
|
+
"job_func" => "name",
|
23
|
+
"loc" => "name",
|
24
|
+
"nr" => "name",
|
25
|
+
"opsys" => "name",
|
26
|
+
"org" => "name",
|
27
|
+
"tab" => "name",
|
28
|
+
"auto_close" => "sym",
|
29
|
+
"aty" => "sym",
|
30
|
+
"act_type_assoc" => "sym",
|
31
|
+
"ca_cmpny" => "sym",
|
32
|
+
"closure_code" => "sym",
|
33
|
+
"cmth" => "sym",
|
34
|
+
"symptom_code" => "sym",
|
35
|
+
"state" => "sym",
|
36
|
+
"crt" => "sym",
|
37
|
+
"ctab" => "sym",
|
38
|
+
"ctp" => "sym",
|
39
|
+
"dcon_typ" => "sym",
|
40
|
+
"dlgsrvr" => "sym",
|
41
|
+
"dmn" => "sym",
|
42
|
+
"doc_rep" => "sym",
|
43
|
+
"fmgrp" => "sym",
|
44
|
+
"ical_alarm" => "sym",
|
45
|
+
"ical_event_template" => "sym",
|
46
|
+
"imp" => "sym",
|
47
|
+
"intfc" => "sym",
|
48
|
+
"kwrd" => "sym",
|
49
|
+
"mfrmod" => "sym",
|
50
|
+
"mgsstat" => "sym",
|
51
|
+
"nrf" => "sym",
|
52
|
+
"options" => "sym",
|
53
|
+
"outage_type" => "sym",
|
54
|
+
"perscnt" => "sym",
|
55
|
+
"position" => "sym",
|
56
|
+
"pr_trans" => "sym",
|
57
|
+
"prod" => "sym",
|
58
|
+
"quick_tpl_types" => "sym",
|
59
|
+
"rc" => "sym",
|
60
|
+
"resocode" => "sym",
|
61
|
+
"resomethod" => "sym",
|
62
|
+
"response" => "sym",
|
63
|
+
"rrf" => "sym",
|
64
|
+
"rss" => "sym",
|
65
|
+
"seq" => "sym",
|
66
|
+
"sev" => "sym",
|
67
|
+
"site" => "sym",
|
68
|
+
"slatpl" => "sym",
|
69
|
+
"special_handling" => "sym",
|
70
|
+
"svc_contract" => "sym",
|
71
|
+
"typecnt" => "sym",
|
72
|
+
"tz" => "sym",
|
73
|
+
"tspan" => "sym",
|
74
|
+
"transition_type" => "sym",
|
75
|
+
"urg" => "sym",
|
76
|
+
"vpt" => "sym",
|
77
|
+
"wrkshft" => "sym",
|
78
|
+
"cr" => "ref_num",
|
79
|
+
"in" => "ref_num",
|
80
|
+
"pr" => "ref_num"
|
81
|
+
}
|
82
|
+
|
13
83
|
RestClient.proxy = ""
|
14
84
|
|
15
85
|
attr_reader :base_url, :user, :access_key, :expiration_date, :debug
|
@@ -178,6 +248,14 @@ class Usd
|
|
178
248
|
attr.push set_url_parm(params,"start","1")
|
179
249
|
attr.push set_url_parm(params,"size","50")
|
180
250
|
attr.push set_url_parm(params,"WC","")
|
251
|
+
# if wc contains no sql-compare operater, it will be changed to "COMMON_NAME like '%<wc-before>%'"
|
252
|
+
wc = attr.pop
|
253
|
+
wc.gsub!(/^WC=/,'')
|
254
|
+
if ([" like ","<",">","="," is "].find {|e| wc =~ /#{e}/}).nil?
|
255
|
+
wc = "#{CN[object]} like '%#{wc}%'"
|
256
|
+
end
|
257
|
+
attr.push "WC=#{wc}"
|
258
|
+
# puts attr.jp # debug
|
181
259
|
fields = set_param(params,"fields","COMMON_NAME,id")
|
182
260
|
query_string=attr.join("&")
|
183
261
|
res_rdata = request("/caisd-rest/#{object}?#{query_string}",{:method => "get", :header => header({'X-Obj-Attrs' => fields})})
|
data/usd.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
Gem::Specification.new do |spec|
|
2
|
-
spec.name = 'usd'
|
3
|
-
spec.version = '
|
4
|
-
spec.date = '2020-
|
5
|
-
spec.summary = "SDM REST-API-Calls"
|
6
|
-
spec.description = "a Ruby class and a commandlinetool for SDM REST-API-Calls"
|
7
|
-
spec.authors = ["Oliver Gaida"]
|
8
|
-
spec.email = 'oliver.gaida@sycor.de'
|
9
|
-
#spec.files = ["bin/rusdc", "bin/set_env", "lib/usd.rb"] # Dir["*/*"]
|
10
|
-
spec.files = `git ls-files`.split($/)
|
11
|
-
spec.homepage = 'https://github.com/ogaida/usd'
|
12
|
-
spec.executables = %w(rusdc)
|
13
|
-
spec.add_runtime_dependency 'thor', '~> 0.20', '>= 0.20.3'
|
14
|
-
spec.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
|
15
|
-
spec.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
16
|
-
end
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'usd'
|
3
|
+
spec.version = '1.3.1'
|
4
|
+
spec.date = '2020-09-10'
|
5
|
+
spec.summary = "SDM REST-API-Calls"
|
6
|
+
spec.description = "a Ruby class and a commandlinetool for SDM REST-API-Calls"
|
7
|
+
spec.authors = ["Oliver Gaida"]
|
8
|
+
spec.email = 'oliver.gaida@sycor.de'
|
9
|
+
#spec.files = ["bin/rusdc", "bin/set_env", "lib/usd.rb"] # Dir["*/*"]
|
10
|
+
spec.files = `git ls-files`.split($/)
|
11
|
+
spec.homepage = 'https://github.com/ogaida/usd'
|
12
|
+
spec.executables = %w(rusdc)
|
13
|
+
spec.add_runtime_dependency 'thor', '~> 0.20', '>= 0.20.3'
|
14
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
|
15
|
+
spec.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Gaida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|