usd 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -18
  3. data/bin/rusdc +79 -37
  4. data/change_log.md +45 -0
  5. data/usd.gemspec +2 -2
  6. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a40de31eb7297c78b71fb376ff889a28c3f0acfc05438ccd479aac0f34449bef
4
- data.tar.gz: 67ab3c12bfa279a46585d038f5cddba79a89d7d621dfe690e44ba27c92ac3aeb
3
+ metadata.gz: dd923f3b1814841074968b4308bed67f1103d612445254ffad801f762ddbc6bf
4
+ data.tar.gz: 531ef12b97b305293082b3252c00625529c1f79a47f2bd06505f9b0e1f3f78b9
5
5
  SHA512:
6
- metadata.gz: a7f9424391b67229c60961a7d2faa0ef1427092ff563009caca0e833b214f75e350c7ba35df172c96578f7467412cda136872d93d0f2b70056fbe8543b19f3f7
7
- data.tar.gz: 7ebe4cb38d95badc3b619afc0df2094005d30f0f07cdd587425af0a3366099f3ab9c7572223428a32edb324b01d15f878bc58142f7ec32e3a7574dc53a71a384
6
+ metadata.gz: d2ffbea196cef1e974dd9f8bafb43b6076c807e24caa81a96a733bc2062aec830f6956de00bbda984fe7320e1fd756a829b63214cf9b32dfe11159d5b2f496fe
7
+ data.tar.gz: 77531ebb77a005a9dba2f9954faa8dafafc05c68df97c9e7824b2fe964fcc5526f2243e6407eda4544d9704370031b5decb1c774f65bfdc53157881a0c55d549
data/README.md CHANGED
@@ -34,24 +34,26 @@ Place the `mlr`-binary in a path, which is in your PATH-Environment.
34
34
  ```
35
35
  rusdc
36
36
  Commands:
37
- rusdc chg_add_nr # <CO> <CI> - add a CI to a changeorder
38
- rusdc chg_list_nr # <CO> - list all CIs of one changeorder
39
- rusdc create # pipe json-data to create object
40
- rusdc field_names # <object-type> list all fields of an object including its format
41
- rusdc find # <object-type> <where-clause> [fields - Komma getrennt (id,name)] - finds each object which meets the wc-condition
42
- rusdc get # <object-type> <common_name> shows one object
43
- rusdc get_attachment_of_ci # <ci_name> <filename>, download an attachment of a CI and print it out on stdout
44
- rusdc get_attachment_of_co # <co_name> <filename>, download an attachment of a changeorder and print it out on stdout
45
- rusdc help [COMMAND] # Describe available commands or one specific command
46
- rusdc in_list_child_ins # <in> - list all child-incidents of one incident
47
- rusdc list_attachments_of_ci # <ci_name>, list all attachments of a CI
48
- rusdc list_attachments_of_co # <co_name>, list all attachments of a changeorder
49
- rusdc nr_add_child # <nr-name> <child-name>, add one child CI to another CI
50
- rusdc nr_changes # <nr> [inactive-too] - list all open changeorders of one CI
51
- rusdc nr_childs # <ci-name> , lists all childs CIs of a specific CI
52
- rusdc nr_incidents # <nr> [inactive-too] - lists all incident of a specific CI
53
- rusdc nr_parents # nr_parents <ci-name> , lists all parent CIs of a specific CI
54
- rusdc update # pipe json-data to update object
37
+ rusdc chg_add_nr <co> <ci> # add a CI to a changeorder
38
+ rusdc chg_list_nr <co> # list all CIs of one changeorder
39
+ rusdc create # pipe json-data to create object
40
+ rusdc field_names <object-type> # list all fields of an object including its format
41
+ rusdc find <object-type> [where-clause] [fields, comma separated] [options] # finds each object which meets the wc-condition
42
+ rusdc get <object-type> <common_name> # shows one object
43
+ rusdc get_attachment_of_ci <ci_name> <filename> # download an attachment of a CI and print it out on stdout
44
+ rusdc get_attachment_of_co <co_name> <filename> # download an attachment of a changeorder and print it out on stdout
45
+ rusdc help [COMMAND] # Describe available commands or one specific command
46
+ rusdc in_list_child_ins <in> # list all child-incidents of one incident
47
+ rusdc list_attachments_of_ci <ci_name> # list all attachments of a CI
48
+ rusdc list_attachments_of_co <co_name> # list all attachments of a changeorder
49
+ rusdc nr_add_child <nr-name> <child-name> # add one child CI to another CI
50
+ rusdc nr_changes <nr> [inactive-too] # list all open changeorders of one CI
51
+ rusdc nr_childs <ci-name> # lists all childs CIs of a specific CI
52
+ rusdc nr_incidents <nr> [inactive-too] # lists all incident of a specific CI
53
+ rusdc nr_parents <ci-name> # lists all parent CIs of a specific CI
54
+ rusdc update # pipe json-data to update object
55
+ rusdc update_attr <obj> <common_name> <key> <value> # updates a direct (not referenced) attribute of one object.
56
+ rusdc update_ref_attr <obj> <common_name> <key> <value> # updates a referenced attribute of one object.
55
57
  ```
56
58
 
57
59
  # environment-variables
data/bin/rusdc CHANGED
@@ -7,7 +7,7 @@ require "usd"
7
7
 
8
8
  class Rusdc < Thor
9
9
 
10
- desc "chg_add_nr", "<CO> <CI> - add a CI to a changeorder"
10
+ desc "chg_add_nr <co> <ci>", "add a CI to a changeorder"
11
11
  def chg_add_nr(co, ci)
12
12
  template = ERB.new <<-EOF
13
13
  {
@@ -25,7 +25,7 @@ class Rusdc < Thor
25
25
  puts loadcon.create({:type => "json", :data => json})
26
26
  end
27
27
 
28
- desc "chg_list_nr", "<CO> - list all CIs of one changeorder"
28
+ desc "chg_list_nr <co>", "list all CIs of one changeorder"
29
29
  def chg_list_nr(co)
30
30
  invoke 'find', ['lrel_asset_chgnr', %(chg.chg_ref_num = '#{co}'), "nr"], {:format => "mlr"}
31
31
  end
@@ -35,7 +35,7 @@ class Rusdc < Thor
35
35
  puts loadcon.create({:type => "json", :data => STDIN.read})
36
36
  end
37
37
 
38
- desc "field_names","<object-type> list all fields of an object including its format"
38
+ desc "field_names <object-type>","list all fields of an object including its format"
39
39
  def field_names(object)
40
40
  e = loadcon.search(object,{'fields' => "*","start" => "1", "size" => "1"})[0]
41
41
  e.keys.sort.each do |k|
@@ -46,46 +46,49 @@ class Rusdc < Thor
46
46
  end
47
47
  end
48
48
 
49
- desc "find", "<object-type> <where-clause> [fields - Komma getrennt (id,name)] - finds each object which meets the wc-condition"
49
+ desc "find <object-type> [where-clause] [fields, comma separated] [options]", "finds each object which meets the wc-condition"
50
50
  long_desc <<-LONGDESC
51
51
 
52
52
 
53
- Mit --mlr_format kann man das output-Format von Miller (mlr) ändern auf csv, md (markdown), xtab (sehr übersichtlich), dkvp (Delimited key-value pairs) ..., siehe `mlr --help`
53
+ with --mlr_format you may change the output-format of Miller (mlr) to csv, md (markdown), xtab , dkvp (delimited key-value pairs) ..., refer `mlr --help`
54
54
 
55
- Beispiele:
55
+ Examples:
56
56
 
57
- - alle aktiven CIs die mit sygosrv beginnen und die Zahl 58 enthalten:
58
- ./rusdc find nr "name like 'servername' and delete_flag.sym = 'Active' " "id,name" --format mlr
57
+ - all grc objects (! don't use this kind of query for objecttype like nr, in, chg etc., whose number of objects is too big)
58
+ rusdc find grc
59
59
 
60
- - meine aktiven Incidents:
61
- ./rusdc find --format mlr in "assignee.last_name = 'gaida' and status.sym in ('Service pending','Work in progress.','Customer Pending','Open','Hold','Resolved')" ref_num,z_project,summary,status,call_back_date,affected_resource,orig_user_organization
60
+ - all aktive ci which start with the string `servername`, only print the fields @id and name:
61
+ rusdc find nr "name like 'servername%' and delete_flag.sym = 'Active' " "@id,name" --format mlr
62
62
 
63
- - Activity-Log eines Incidents:
64
- ./rusdc find alg "call_req_id.ref_num = 'I00001'" "call_req_id,action_desc,analyst,description,time_stamp,type" --format mlr --mlr_format xtab
63
+ - my active incidents with most importent fields:
64
+ rusdc find --format mlr in "assignee.last_name = 'gaida' and status.sym in ('Service pending','Work in progress.','Customer Pending','Open','Hold','Resolved')" ref_num,z_project,summary,status,call_back_date,affected_resource,orig_user_organization
65
65
 
66
- - nur die Beschreibungen Activity-Log eines Incidents:
67
- ./rusdc find alg "call_req_id.ref_num = 'I00001'" "description" --format mlr --mlr_format csv
66
+ - activity-Log of an incident in xtab format:
67
+ rusdc find alg "call_req_id.ref_num = 'I00001'" "call_req_id,action_desc,analyst,description,time_stamp,type" --format mlr --mlr_format xtab
68
68
 
69
- - Incidents einer Maschine
70
- ./rusdc find in "affected_resource.name = 'servername'" "ref_num,summary" --format mlr
69
+ - the same but only the field description in csv-format:
70
+ rusdc find alg "call_req_id.ref_num = 'I00001'" "description" --format mlr --mlr_format csv
71
71
 
72
- - Kombiniert, alle Activity-Log-Beschreibungen aller Incidents einer Maschine:
73
- ./rusdc find alg "call_req_id.affected_resource.name = 'servername'" "description" --format mlr
72
+ - incidents of the ci with the name `servername`
73
+ rusdc find in "affected_resource.name = 'servername'" "ref_num,summary" --format mlr
74
74
 
75
- - Changes einer Maschine:
75
+ - combination of all activity-log-description of all incidents of a specific ci in pprint-Miller-format:
76
+ rusdc find alg "call_req_id.affected_resource.name = 'servername'" "description" --format mlr
77
+
78
+ - changeorders of a secific ci:
76
79
  rusdc find chg "asset.nr.name = 'servername'" "@COMMON_NAME,summary,status" --format mlr
77
80
 
78
- - Alle Maschinen finden die mit goes beginnen und deren childs auf Linux und Windows prüfen:
81
+ - find all active ci whose name start with dc and check if they have children like Windows or Linux server:
79
82
  for ci in $(rusdc find nr "name like 'dc%' and delete_flag.sym = 'active'" "name" --format mlr | sed '1 d'); do rusdc nr_childs $ci > help ; echo "$ci: $(grep -iP '^(Linux|.*MS windows).*server' help)" ; done
80
83
 
81
84
  LONGDESC
82
- option :format, :type => :string, :default => "json"
83
- option :mlr_format, :type => :string, :default => "pprint"
84
- option :nice_time, :type => :boolean, :default => true
85
- option :debug, :type => :boolean, :default => false
86
- def find(object, wc, fields="*")
85
+ option :format, :type => :string, :default => "json", :banner => "[json|yaml|mlr]"
86
+ option :mlr_format, :type => :string, :default => "pprint",:banner => "[pprint|json|md|csv|xtab]"
87
+ option :nice_time, :type => :boolean, :default => true,:banner => "[true|false]"
88
+ option :debug, :type => :boolean, :default => false,:banner => "[true|false]"
89
+ def find(object, wc="", fields="@COMMON_NAME")
87
90
  unless (fields =~ /^[\w\_,@]+$/)
88
- puts "fields-problem: there must be only letters, numbers, comma and underscore, nothing else!"
91
+ puts "fields-problem: there must be only letters, numbers, comma, the @-sign or underscore, nothing else!"
89
92
  else
90
93
  con = loadcon
91
94
  mlr_array = []
@@ -137,7 +140,7 @@ class Rusdc < Thor
137
140
  end # fields check
138
141
  end
139
142
 
140
- desc "get", "<object-type> <common_name> shows one object"
143
+ desc "get <object-type> <common_name>", "shows one object"
141
144
  option :yaml, :type => :boolean, :default => false
142
145
  def get(object, cn)
143
146
  e = loadcon.request("/caisd-rest/#{object}/COMMON_NAME-#{cn}")
@@ -150,7 +153,7 @@ class Rusdc < Thor
150
153
  end
151
154
  end
152
155
 
153
- desc "get_attachment_of_ci", "<ci_name> <filename>, download an attachment of a CI and print it out on stdout"
156
+ desc "get_attachment_of_ci <ci_name> <filename>", "download an attachment of a CI and print it out on stdout"
154
157
  def get_attachment_of_ci(ciname, filename)
155
158
  att_nr = loadcon.search("lrel_attachments_nr",{'fields' => "attmnt","wc" => "nr.name = '#{ciname}'"})
156
159
  att_nr.each do |att|
@@ -161,7 +164,7 @@ class Rusdc < Thor
161
164
  end
162
165
  end
163
166
 
164
- desc "get_attachment_of_co", "<co_name> <filename>, download an attachment of a changeorder and print it out on stdout"
167
+ desc "get_attachment_of_co <co_name> <filename>", "download an attachment of a changeorder and print it out on stdout"
165
168
  def get_attachment_of_co(coname, filename)
166
169
  chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
167
170
  att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
@@ -173,12 +176,12 @@ class Rusdc < Thor
173
176
  end
174
177
  end
175
178
 
176
- desc "in_list_child_ins", "<in> - list all child-incidents of one incident"
179
+ desc "in_list_child_ins <in>", "list all child-incidents of one incident"
177
180
  def in_list_child_ins(incident)
178
181
  invoke('find',['cr', "parent.ref_num = '#{incident}'", "ref_num"], {:format => "mlr"})
179
182
  end
180
183
 
181
- desc "list_attachments_of_ci", "<ci_name>, list all attachments of a CI"
184
+ desc "list_attachments_of_ci <ci_name>", "list all attachments of a CI"
182
185
  def list_attachments_of_ci(ciname)
183
186
  att_nr = loadcon.search("lrel_attachments_nr",{'fields' => "attmnt","wc" => "nr.name = '#{ciname}'"})
184
187
  att_nr.each do |att|
@@ -186,7 +189,7 @@ class Rusdc < Thor
186
189
  end
187
190
  end
188
191
 
189
- desc "list_attachments_of_co", "<co_name>, list all attachments of a changeorder"
192
+ desc "list_attachments_of_co <co_name>", "list all attachments of a changeorder"
190
193
  def list_attachments_of_co(coname)
191
194
  chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
192
195
  att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
@@ -195,7 +198,7 @@ class Rusdc < Thor
195
198
  end
196
199
  end
197
200
 
198
- desc "nr_add_child", "<nr-name> <child-name>, add one child CI to another CI"
201
+ desc "nr_add_child <nr-name> <child-name>", "add one child CI to another CI"
199
202
  def nr_add_child(nr, child)
200
203
  template = ERB.new <<-EOF
201
204
  {
@@ -213,7 +216,7 @@ class Rusdc < Thor
213
216
  puts loadcon.create({:type => "json", :data => json})
214
217
  end
215
218
 
216
- desc "nr_changes", "<nr> [inactive-too] - list all open changeorders of one CI"
219
+ desc "nr_changes <nr> [inactive-too]", "list all open changeorders of one CI"
217
220
  option :inactive_too, :type => :boolean, :default => false
218
221
  def nr_changes(nr)
219
222
  wc_add = (options[:inactive_too] ? "" : " and status.sym in ('Service pending','Work in progress','Customer Pending','Open','Hold')")
@@ -221,20 +224,20 @@ class Rusdc < Thor
221
224
  invoke 'find', ['chg', wc, 'chg_ref_num,summary,status'], {:format => "mlr"}
222
225
  end
223
226
 
224
- desc "nr_childs", "<ci-name> , lists all childs CIs of a specific CI"
227
+ desc "nr_childs <ci-name>", "lists all childs CIs of a specific CI"
225
228
  def nr_childs(name)
226
229
  loadcon.search("hier",{'fields' => "*","wc" => "parent.name = '#{name}'"}).each do |c|
227
230
  puts c["child"]["@COMMON_NAME"]
228
231
  end
229
232
  end
230
233
 
231
- desc "nr_incidents", "<nr> [inactive-too] - lists all incident of a specific CI"
234
+ desc "nr_incidents <nr> [inactive-too]", "lists all incident of a specific CI"
232
235
  option :inactive_too, :type => :boolean, :default => false
233
236
  def nr_incidents(nr)
234
237
  invoke 'find', ['in', %(affected_resource.name = '#{nr}'#{options[:inactive_too] ? "" : " and not status.sym in ('Cancelled','Closed')"}), "ref_num,summary,status"], {:format => "mlr"}
235
238
  end
236
239
 
237
- desc "nr_parents", "nr_parents <ci-name> , lists all parent CIs of a specific CI"
240
+ desc "nr_parents <ci-name>", "lists all parent CIs of a specific CI"
238
241
  def nr_parents(name)
239
242
  loadcon.search("hier",{'fields' => "*","wc" => "child.name = '#{name}'"}).each do |c|
240
243
  puts c["parent"]["@COMMON_NAME"]
@@ -254,6 +257,45 @@ class Rusdc < Thor
254
257
  puts loadcon.update({:type => "json", :data => STDIN.read})
255
258
  end
256
259
 
260
+ desc "update_attr <obj> <common_name> <key> <value>", "updates a direct (not referenced) attribute of one object."
261
+ def update_attr(obj, cn, k, v)
262
+ template = ERB.new <<-EOF
263
+ {
264
+ "<%= obj %>": {
265
+ "@COMMON_NAME": "<%= cn %>",
266
+ "<%= k %>": "<%= v %>"
267
+ }
268
+ }
269
+ EOF
270
+ json = template.result_with_hash({
271
+ :obj => obj,
272
+ :cn => cn,
273
+ :k => k,
274
+ :v => v
275
+ })
276
+ puts loadcon.update({:type => "json", :data => json})
277
+ end
278
+
279
+ desc "update_ref_attr <obj> <common_name> <key> <value>", "updates a referenced attribute of one object."
280
+ def update_ref_attr(obj, cn, k, v)
281
+ template = ERB.new <<-EOF
282
+ {
283
+ "<%= obj %>": {
284
+ "@COMMON_NAME": "<%= cn %>",
285
+ "<%= k %>": {
286
+ "@COMMON_NAME": "<%= v %>"
287
+ }
288
+ }
289
+ }
290
+ EOF
291
+ json = template.result_with_hash({
292
+ :obj => obj,
293
+ :cn => cn,
294
+ :k => k,
295
+ :v => v
296
+ })
297
+ puts loadcon.update({:type => "json", :data => json})
298
+ end
257
299
 
258
300
  private
259
301
 
@@ -0,0 +1,45 @@
1
+ # changelog
2
+
3
+ ## 0.1.8
4
+
5
+ - new function in rusdc `update_attr`
6
+
7
+ Example for `update_attr`:
8
+
9
+ ```bash
10
+ > rusdc help update_attr
11
+ Usage:
12
+ rusdc update_attr <obj> <common_name> <key> <value>
13
+
14
+ updates a direct (not referenced) attribute of one object.
15
+
16
+ > rusdc get cnt 'gaida, oliver' | grep alt_phone
17
+ "alt_phone": "",
18
+ > rusdc update_attr cnt 'gaida, oliver' alt_phone "+49123456789"
19
+ > rusdc get cnt 'gaida, oliver' | grep alt_phone
20
+ "alt_phone": "+49123456789",
21
+ ```
22
+
23
+ - new function in rusdc `update_ref_attr`
24
+
25
+ Example for `update_ref_attr`:
26
+
27
+ ```bash
28
+ > rusdc help update_ref_attr
29
+ Usage:
30
+ rusdc update_ref_attr <obj> <common_name> <key> <value>
31
+
32
+ updates a referenced attribute of one object.
33
+ > rusdc find chg "chg_ref_num = 'CO000001'" status --format mlr
34
+ status
35
+ Work in progress
36
+ > rusdc update_ref_attr chg CO000001 status "Service pending"
37
+ > rusdc find chg "chg_ref_num = 'CO000001'" status --format mlr
38
+ status
39
+ Service pending
40
+ ```
41
+
42
+ ## 0.1.7
43
+
44
+ - fix sorting the output of `rusdc find`
45
+ - add new rusdc function `rusdc in_list_child_ins`
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'usd'
3
- spec.version = '0.1.7'
4
- spec.date = '2019-11-01'
3
+ spec.version = '0.1.8'
4
+ spec.date = '2019-11-04'
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: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Gaida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2019-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,7 @@ files:
80
80
  - README.md
81
81
  - bin/rusdc
82
82
  - bin/set_env
83
+ - change_log.md
83
84
  - lib/usd.rb
84
85
  - usd.gemspec
85
86
  homepage: https://github.com/ogaida/usd