usd 0.2.4.1 → 1.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 +16 -6
- data/bin/rusdc +35 -8
- data/change_log.md +99 -0
- data/lib/usd.rb +70 -0
- data/usd.gemspec +2 -2
- 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: 34c19bfe569d436235dd61b312a9f7edcb191c3598daf05f77c94664efda6a5a
|
4
|
+
data.tar.gz: 1e84341f1befdb3eb2dab78e2a0516f7b21b55413e6635da588deefd889d3ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80fa09424ea66980cee551c30dcdc337237c25c125ea66105a43f1672e5da297d9fc64730f4d1e2650ecf2c3692408c22566a447cd3d729a018c2f065276afff
|
7
|
+
data.tar.gz: 19172f70b81b7ede21f11639c6469a3f5d85137499e4611b065a3a6042529b3a1aa213d943114dc7ad86024fb2644b5557c9610b6363c6347c0e90505c845df3
|
data/README.md
CHANGED
@@ -21,6 +21,15 @@ yum group install "Development Tools"
|
|
21
21
|
yum install ruby-devel
|
22
22
|
```
|
23
23
|
|
24
|
+
# documentation
|
25
|
+
|
26
|
+
- see [https://github.com/ogaida/usd/wiki](https://github.com/ogaida/usd/wiki)
|
27
|
+
- 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)
|
28
|
+
|
29
|
+
## bash-completion
|
30
|
+
|
31
|
+
see [https://github.com/ogaida/usd/wiki/bash-completion](https://github.com/ogaida/usd/wiki/bash-completion)
|
32
|
+
|
24
33
|
# external tools
|
25
34
|
|
26
35
|
If you use the `rusdc find` command with `--format mlr` option then you need `mlr`.
|
@@ -38,24 +47,25 @@ rusdc create # p
|
|
38
47
|
rusdc field_names <object-type> [wc] # list all fields of an object including its format
|
39
48
|
rusdc find <object-type> [where-clause] [fields, comma separated] [options] # finds each object which meets the wc-condition
|
40
49
|
rusdc get <object-type> <common_name|id> # shows one object by name or id
|
41
|
-
rusdc get_all_attachments_of_co <co_name> # get all attachments of a changeorder and save all
|
42
|
-
rusdc get_attachment_of_ci <ci_name> <filename> # download an attachment of a CI and print it out on
|
43
|
-
rusdc get_attachment_of_co <co_name> <filename> # download an attachment of a changeorder and print it
|
50
|
+
rusdc get_all_attachments_of_co <co_name> # get all attachments of a changeorder and save all th...
|
51
|
+
rusdc get_attachment_of_ci <ci_name> <filename> # download an attachment of a CI and print it out on s...
|
52
|
+
rusdc get_attachment_of_co <co_name> <filename> # download an attachment of a changeorder and print it...
|
44
53
|
rusdc help [COMMAND] # Describe available commands or one specific command
|
45
54
|
rusdc in_add_2_chg <changeorder> <incident> # add incident to changeorder
|
46
55
|
rusdc in_list_child_ins <in> # list all child-incidents of one incident
|
47
56
|
rusdc list_attachments_of_ci <ci_name> # list all attachments of a CI
|
48
57
|
rusdc list_attachments_of_co <co_name> # list all attachments of a changeorder
|
49
58
|
rusdc nr_add_child <nr-name> <child-name> # add one child CI to another CI
|
59
|
+
rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem
|
50
60
|
rusdc nr_changes <nr> [inactive-too] # list all open changeorders of one CI
|
51
61
|
rusdc nr_childs <ci-name> # lists all childs CIs of a specific CI
|
52
62
|
rusdc nr_incidents <nr> [inactive-too] # lists all incident of a specific CI
|
53
63
|
rusdc nr_parents <ci-name> # lists all parent CIs of a specific CI
|
54
64
|
rusdc update # pipe json-data to update object
|
55
|
-
rusdc update_attr <obj> <common_name|wc> <key> <value> # updates a direct (not referenced) attribute of one
|
56
|
-
rusdc update_attr_by_id <obj> <id> <key> <value> # updates a plain attribute of one object by id, does
|
65
|
+
rusdc update_attr <obj> <common_name|wc> <key> <value> # updates a direct (not referenced) attribute of one o...
|
66
|
+
rusdc update_attr_by_id <obj> <id> <key> <value> # updates a plain attribute of one object by id, does ...
|
57
67
|
rusdc update_ref_attr <obj> <common_name> <key> <value> # updates a referenced attribute of one object.
|
58
|
-
rusdc update_ref_attr_by_id <obj> <id> <key> <value_id> # updates a referenced attribute of one object_id by
|
68
|
+
rusdc update_ref_attr_by_id <obj> <id> <key> <value_id> # updates a referenced attribute of one object_id by v...
|
59
69
|
```
|
60
70
|
|
61
71
|
# environment-variables
|
data/bin/rusdc
CHANGED
@@ -107,7 +107,7 @@ class Rusdc < Thor
|
|
107
107
|
elem.keys.each do |elem_key|
|
108
108
|
if options[:nice_time]
|
109
109
|
if elem_key =~ /(date|last_mod|warranty_start|warranty_end|time_stamp)$/
|
110
|
-
elem[elem_key]=Time.at(elem[elem_key]).to_s
|
110
|
+
elem[elem_key]=Time.at(elem[elem_key]).to_s if elem[elem_key] != "" # not empty
|
111
111
|
end
|
112
112
|
end
|
113
113
|
if fields_array.include?(elem_key)
|
@@ -127,6 +127,7 @@ class Rusdc < Thor
|
|
127
127
|
case options[:format]
|
128
128
|
when "json"
|
129
129
|
puts mlr
|
130
|
+
e
|
130
131
|
exit exitcode
|
131
132
|
when "yaml"
|
132
133
|
# keys not sorted, maybe a todo
|
@@ -186,7 +187,7 @@ class Rusdc < Thor
|
|
186
187
|
def get_attachment_of_ci(ciname, filename)
|
187
188
|
att_nr = loadcon.search("lrel_attachments_nr",{'fields' => "attmnt","wc" => "nr.name = '#{ciname}'"})
|
188
189
|
att_nr.each do |att|
|
189
|
-
attmnt = loadcon.request("/caisd-rest/attmnt
|
190
|
+
attmnt = loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]
|
190
191
|
if attmnt["orig_file_name"] == filename
|
191
192
|
puts loadcon.request("/caisd-rest/attmnt/#{attmnt["@id"]}/file-resource",{:unchanged => true})
|
192
193
|
end
|
@@ -198,7 +199,7 @@ class Rusdc < Thor
|
|
198
199
|
chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
|
199
200
|
att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
|
200
201
|
att_nr.each do |att|
|
201
|
-
attmnt = loadcon.request("/caisd-rest/attmnt
|
202
|
+
attmnt = loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]
|
202
203
|
if attmnt["orig_file_name"] == filename
|
203
204
|
puts loadcon.request("/caisd-rest/attmnt/#{attmnt["@id"]}/file-resource",{:unchanged => true})
|
204
205
|
end
|
@@ -219,7 +220,7 @@ class Rusdc < Thor
|
|
219
220
|
def list_attachments_of_ci(ciname)
|
220
221
|
att_nr = loadcon.search("lrel_attachments_nr",{'fields' => "attmnt","wc" => "nr.name = '#{ciname}'"})
|
221
222
|
att_nr.each do |att|
|
222
|
-
puts loadcon.request("/caisd-rest/attmnt
|
223
|
+
puts loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]["orig_file_name"]
|
223
224
|
end
|
224
225
|
end
|
225
226
|
|
@@ -228,7 +229,7 @@ class Rusdc < Thor
|
|
228
229
|
chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
|
229
230
|
att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
|
230
231
|
att_nr.each do |att|
|
231
|
-
puts loadcon.request("/caisd-rest/attmnt
|
232
|
+
puts loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]["orig_file_name"]
|
232
233
|
end
|
233
234
|
end
|
234
235
|
|
@@ -250,6 +251,24 @@ class Rusdc < Thor
|
|
250
251
|
puts loadcon.create({:type => "json", :data => json})
|
251
252
|
end
|
252
253
|
|
254
|
+
desc "nr_add_org <nr> <org>", "add an Organisation to a ConfigurationItem"
|
255
|
+
def nr_add_org(nr, org)
|
256
|
+
template = ERB.new <<-EOF
|
257
|
+
{
|
258
|
+
"lrel_oenv_orgref": {
|
259
|
+
"nr": {
|
260
|
+
"@id": "<%= uid_nr %>"
|
261
|
+
},
|
262
|
+
"org": {
|
263
|
+
"@id": "<%= uid_org %>"
|
264
|
+
}
|
265
|
+
}
|
266
|
+
}
|
267
|
+
EOF
|
268
|
+
json = template.result_with_hash(:uid_org => loadcon.request("/caisd-rest/org/COMMON_NAME-#{org}")["org"]["@id"], :uid_nr => loadcon.request("/caisd-rest/nr/COMMON_NAME-#{nr}")["nr"]["@id"])
|
269
|
+
puts loadcon.create({:type => "json", :data => json})
|
270
|
+
end
|
271
|
+
|
253
272
|
desc "nr_changes <nr> [inactive-too]", "list all open changeorders of one CI"
|
254
273
|
option :inactive_too, :type => :boolean, :default => false
|
255
274
|
def nr_changes(nr)
|
@@ -365,8 +384,8 @@ class Rusdc < Thor
|
|
365
384
|
puts loadcon.update({:type => "json", :data => json})
|
366
385
|
end
|
367
386
|
|
368
|
-
desc "update_ref_attr <obj> <common_name> <key> <value>", "updates a referenced attribute of one object."
|
369
|
-
def update_ref_attr(obj, cn, k, v)
|
387
|
+
desc "update_ref_attr <obj> <common_name> <key> <value> [ref_obj=nr]", "updates a referenced attribute of one object."
|
388
|
+
def update_ref_attr(obj, cn, k, v, ref_obj = "nr")
|
370
389
|
template = ERB.new <<-EOF
|
371
390
|
{
|
372
391
|
"<%= obj %>": {
|
@@ -383,7 +402,15 @@ class Rusdc < Thor
|
|
383
402
|
:k => k,
|
384
403
|
:v => v
|
385
404
|
})
|
386
|
-
|
405
|
+
data = loadcon.update({:type => "json", :data => json})
|
406
|
+
if data.class == RestClient::BadRequest
|
407
|
+
puts "BadRequest-Response from USD-API, try to update via IDs. be aware to specify a ref_obj if it's not nr."
|
408
|
+
cn_id = loadcon.search(obj,{'fields' => "@id","wc" => "#{Usd::CN[obj]} = '#{cn}' and delete_flag = 0"})[0]["@id"]
|
409
|
+
value_id = loadcon.search(ref_obj,{'fields' => "@id","wc" => "#{Usd::CN[obj]} = '#{v}' and delete_flag = 0"})[0]["@id"]
|
410
|
+
invoke "update_ref_attr_by_id", [obj, cn_id, k, value_id]
|
411
|
+
else
|
412
|
+
puts data
|
413
|
+
end
|
387
414
|
end
|
388
415
|
|
389
416
|
desc "update_ref_attr_by_id <obj> <id> <key> <value_id>", "updates a referenced attribute of one object_id by value-id"
|
data/change_log.md
CHANGED
@@ -1,5 +1,104 @@
|
|
1
1
|
# rusdc changelog
|
2
2
|
|
3
|
+
## 1.0
|
4
|
+
|
5
|
+
- `update_ref_attr` rusdc-function fetches the IDs to update the object by itself.
|
6
|
+
|
7
|
+
## 0.3
|
8
|
+
|
9
|
+
- some common_name resolution
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
class Usd
|
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
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
## 0.2.5.3
|
86
|
+
|
87
|
+
- neu function : `rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem`
|
88
|
+
|
89
|
+
#### fixes:
|
90
|
+
|
91
|
+
- rusdc - line 110: more robust when querying date fields
|
92
|
+
|
93
|
+
## 0.2.4.2
|
94
|
+
|
95
|
+
the same fixes as in 0.2.4.1 for:
|
96
|
+
|
97
|
+
```
|
98
|
+
rusdc list_attachments_of_ci <ci_name>
|
99
|
+
rusdc list_attachments_of_co <co_name>
|
100
|
+
```
|
101
|
+
|
3
102
|
## 0.2.4.1
|
4
103
|
|
5
104
|
### fixes
|
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
|
data/usd.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'usd'
|
3
|
-
spec.version = '
|
4
|
-
spec.date = '2020-
|
3
|
+
spec.version = '1.1'
|
4
|
+
spec.date = '2020-08-31'
|
5
5
|
spec.summary = "SDM REST-API-Calls"
|
6
6
|
spec.description = "a Ruby class and a commandlinetool for SDM REST-API-Calls"
|
7
7
|
spec.authors = ["Oliver Gaida"]
|
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.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-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|