usd 1.3.3 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8341a6edac193e671ccde850088a693d452bd571e7685bdba3ed59b6a10dc9c7
4
- data.tar.gz: f9688b4546873b2b0d1ae35555080d0c965a2897e69823dc633131df4f6ecd63
3
+ metadata.gz: 76168d8702cea6b4f50eb7f35849793c694c5359527bc1643a1e3306ea81aa2b
4
+ data.tar.gz: 0c3ffb3e1e0b880c4d2ef297d19af5d3dcdab2fbf6c88418a55037db77368ab8
5
5
  SHA512:
6
- metadata.gz: ab1cede636c31e94a3b5d4834c894db2d655638c5582e737e00c372617620dce66dc11839ff5d9ce22da4c378b5a91b027591a68d59ef41e0898fe1d1a6961ef
7
- data.tar.gz: ea878deaa14d2ed86591b67b54851584055e11e80b46bf104572f4784b90f16616e154ef779da4d10fdf339cab5550f53a8f48e0165a75396bc128a2097ae807
6
+ metadata.gz: 3521906b5c80e59468a66c0b9ef20c040a81c6b840b105707ca0f29908e39f38aece82fbf1cd3a4de86e5aca6a8ced40265553bb85d206626f53e93e97d5c1e5
7
+ data.tar.gz: 6978d0bf488852d0e5e96c34dccf4e745a9435c0ec1a9707a7940815cc58e0a05d0e6266046d31a15f0ba45a1181cded6e51f8af3a223d65f55a8ca25ba3f8e7
data/README.md CHANGED
@@ -40,8 +40,6 @@ If you use the `rusdc find` command with `--format mlr` option then you need `ml
40
40
 
41
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
42
 
43
- For uloading attachments `unix2dos` and `base64` is used.
44
-
45
43
  # functions from the commandline-tool `rusdc`
46
44
 
47
45
  ```
@@ -58,13 +56,14 @@ rusdc get_attachment_of_co <co_name> <filename> # d
58
56
  rusdc get_attachment_of_in <incident> <filename> # download an attachment of an Incident and print it out on stdout
59
57
  rusdc help [COMMAND] # Describe available commands or one specific command
60
58
  rusdc in_add_2_chg <changeorder> <incident> # add incident to changeorder
61
- rusdc in_add_attachment <in> <file> # attach the file to incident
59
+ rusdc in_add_attachment <in> <file> # attach a file to an incident or problem
62
60
  rusdc in_list_child_ins <in> # list all child-incidents of one incident
63
61
  rusdc list_attachments_of_ci <ci_name> # list all attachments of a CI
64
62
  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
63
+ rusdc list_attachments_of_in <in> # list all attachments of an incident or problem
66
64
  rusdc nr_add_attachment <nr> <file> # attach the file to nr
67
65
  rusdc nr_add_child <nr-name> <child-name> # add one child CI to another CI
66
+ rusdc nr_add_contact <nr> <cnt_email> # add contact to configuration-item
68
67
  rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem
69
68
  rusdc nr_changes <nr> [inactive-too] # list all open changeorders of one CI
70
69
  rusdc nr_childs <ci-name> # lists all childs CIs of a specific CI
@@ -114,3 +113,7 @@ foo2 foo TEST
114
113
  ```
115
114
 
116
115
  more examples under [find examples-Wikipage](https://github.com/ogaida/usd/wiki/find-examples) or in the [change_log](https://github.com/ogaida/usd/blob/master/change_log.md)
116
+
117
+ # senarios
118
+
119
+ <img src="https://yuml.me/diagram/scruffy/class/[SDM%20REST-API{bg:red}]<->[usd-gem{bg:green}]<->[rusdc{bg:orange}],[ruby-script{bg:orange}]<->[usd-gem],[sinatra%20web-app{bg:orange}]<->[usd-gem],[bash commands]<->[rusdc],[shell-scripts]<->[rusdc],[import]->[ruby-script],[ruby-script]->[export],[reports]<-[sinatra%20web-app]<-[drop datafiles/emails/create objects]">
data/bin/rusdc CHANGED
@@ -9,7 +9,7 @@ class Rusdc < Thor
9
9
 
10
10
  desc "chg_add_attachment <co> <file>", "attach the file to co"
11
11
  def chg_add_attachment(co, file)
12
- response = upload_attachment(file, loadcon.base_url, loadcon.access_key)
12
+ response = loadcon.upload_attachment(file)
13
13
  puts response
14
14
  data = JSON.parse(response)
15
15
  template = ERB.new <<-EOF
@@ -230,19 +230,21 @@ class Rusdc < Thor
230
230
  end
231
231
  end
232
232
 
233
- # in: lrel_attachments_requests ?
234
-
235
233
  desc "get_attachment_of_co <co_name> <filename>", "download an attachment of a changeorder and print it out on stdout"
236
234
  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
235
+ chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
236
+ att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
237
+ att_nr.each do |att|
238
+ attmnt = loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]
239
+ if attmnt["orig_file_name"] == filename
240
+ puts loadcon.request("/caisd-rest/attmnt/#{attmnt["@id"]}/file-resource",{:unchanged => true})
241
+ end
242
+ end
239
243
  end
240
244
 
241
-
242
- #lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num
243
- desc "in_add_attachment <in> <file>", "attach the file to incident"
245
+ desc "in_add_attachment <in> <file>", "attach a file to an incident or problem"
244
246
  def in_add_attachment(incident, file)
245
- response = upload_attachment(file, loadcon.base_url, loadcon.access_key)
247
+ response = loadcon.upload_attachment(file)
246
248
  puts response
247
249
  data = JSON.parse(response)
248
250
  template = ERB.new <<-EOF
@@ -261,7 +263,6 @@ class Rusdc < Thor
261
263
  :id => data["attmnt"]["@id"],
262
264
  :incident => incident
263
265
  })
264
- #puts "create relation to chg with json: #{json}"
265
266
  puts loadcon.create({:type => "json", :data => json})
266
267
  end
267
268
 
@@ -292,7 +293,7 @@ class Rusdc < Thor
292
293
  end
293
294
  end
294
295
 
295
- desc "list_attachments_of_in <in>", "list all attachments of an Incident"
296
+ desc "list_attachments_of_in <in>", "list all attachments of an incident or problem"
296
297
  def list_attachments_of_in(incident)
297
298
  att_in = loadcon.search("lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num = '#{incident}'"})
298
299
  att_in.each do |att|
@@ -302,7 +303,7 @@ class Rusdc < Thor
302
303
 
303
304
  desc "nr_add_attachment <nr> <file>", "attach the file to nr"
304
305
  def nr_add_attachment(nr, file)
305
- response = upload_attachment(file, loadcon.base_url, loadcon.access_key)
306
+ response = loadcon.upload_attachment(file)
306
307
  puts response
307
308
  data = JSON.parse(response)
308
309
  nr_id = loadcon.search("nr",{'fields' => "@id","wc" => "name = '#{nr}'"})[0]["@id"]
@@ -344,6 +345,28 @@ class Rusdc < Thor
344
345
  puts loadcon.create({:type => "json", :data => json})
345
346
  end
346
347
 
348
+ desc "nr_add_contact <nr> <cnt_email>", "add contact to configuration-item"
349
+ def nr_add_contact(nr, cnt_email)
350
+ template = ERB.new <<-EOF
351
+ {
352
+ "lrel_cenv_cntref": {
353
+ "nr": {
354
+ "@id": "<%= uid_nr %>"
355
+ },
356
+ "cnt": {
357
+ "@id": "<%= uid_cnt %>"
358
+ }
359
+ }
360
+ }
361
+ EOF
362
+ json = template.result_with_hash({
363
+ :uid_nr => loadcon.request("/caisd-rest/nr/COMMON_NAME-#{nr}")["nr"]["@id"],
364
+ :uid_cnt => loadcon.search("cnt",{'fields' => "@id","wc" => "email_address = '#{cnt_email}'"})[0]["@id"]
365
+ })
366
+ #puts "create relation to chg with json: #{json}"
367
+ puts loadcon.create({:type => "json", :data => json})
368
+ end
369
+
347
370
  desc "nr_add_org <nr> <org>", "add an Organisation to a ConfigurationItem"
348
371
  def nr_add_org(nr, org)
349
372
  template = ERB.new <<-EOF
@@ -569,26 +592,6 @@ END:VCARD
569
592
  end
570
593
  end
571
594
 
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
- http = Net::HTTP.new(url.host, url.port);
579
- request = Net::HTTP::Post.new(url)
580
- request["X-AccessKey"] = ak
581
- request["Content-Type"] = "multipart/form-data; BOUNDARY=*****MessageBoundary*****"
582
- request["accept"] = "application/json"
583
- request["Cache-Control"] = "no-cache"
584
- fileObj = File.open(file, "rb")
585
- fileContent = fileObj.read
586
- fileObj.close
587
- 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#{Base64.encode64(fileContent)}\r\n\r\n \r\n--*****MessageBoundary*****--\r\n"
588
- response = http.request(request)
589
- response.read_body
590
- end
591
-
592
595
  end
593
596
 
594
597
  Rusdc.start(ARGV)
@@ -1,8 +1,28 @@
1
1
  # rusdc changelog
2
2
 
3
+ ## 1.3.7
4
+
5
+ - Bugfix in rusdc-function `get_attachment_of_co`
6
+
7
+ ## 1.3.6
8
+
9
+ - Bugfix : uploaded filename with special character will be renamed with `URI.escape`
10
+
11
+ ## 1.3.5
12
+
13
+ - new function `nr_add_contact <nr> <email>` to assign a contact to a configuration-item
14
+
15
+ ## 1.3.4.1
16
+
17
+ - fixed another error in Usd.search. which comes with 1.3.1 .
18
+
19
+ ## 1.3.4
20
+
21
+ - move function `upload_attachment` from `bin/rusdc` to `lib/usd`.
22
+
3
23
  ## 1.3.3
4
24
 
5
- - private `Usd` Class funktion changed. Instead using `base64` and `unix2dos` binaries, we use Base64-Ruby-Class now. It is already required by usd.
25
+ - private `rusdc`-funktion `upload_attachment` changed. Instead using `base64` and `unix2dos` binaries, we use Base64-Ruby-Class now. It is already required by usd.
6
26
 
7
27
  ## 1.3.2
8
28
 
Binary file
data/lib/usd.rb CHANGED
@@ -251,7 +251,7 @@ class Usd
251
251
  # if wc contains no sql-compare operater, it will be changed to "COMMON_NAME like '%<wc-before>%'"
252
252
  wc = attr.pop
253
253
  wc.gsub!(/^WC=/,'')
254
- if ([" like ","<",">","="," is "," in "].find {|e| wc =~ /#{e}/}).nil?
254
+ if ([" like ","<",">","="," is "," in "," LIKE ", " IS ", " IN "].find {|e| wc =~ /#{e}/}).nil?
255
255
  wc = "#{CN[object]} like '%#{wc}%'"
256
256
  end
257
257
  attr.push "WC=#{wc}"
@@ -279,6 +279,27 @@ class Usd
279
279
  end
280
280
  end
281
281
 
282
+ def upload_attachment(file, baseurl = @base_url, ak = @access_key)
283
+ baseurl =~ /^([^:]+):/
284
+ server = $1
285
+ filename = File.basename(file)
286
+ filename_escaped = URI.escape(filename)
287
+ uri = "/caisd-rest/attmnt?repositoryId=1002&serverName=#{server}&mimeType=Text&description=#{filename_escaped}"
288
+ url = URI("#{baseurl}#{uri}")
289
+ http = Net::HTTP.new(url.host, url.port);
290
+ request = Net::HTTP::Post.new(url)
291
+ request["X-AccessKey"] = ak
292
+ request["Content-Type"] = "multipart/form-data; BOUNDARY=*****MessageBoundary*****"
293
+ request["accept"] = "application/json"
294
+ request["Cache-Control"] = "no-cache"
295
+ fileObj = File.open(file, "rb")
296
+ fileContent = fileObj.read
297
+ fileObj.close
298
+ 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_escaped}</orig_file_name> \r\n<attmnt_name>#{filename_escaped}</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_escaped}\"; filename=\"#{filename_escaped}\" \r\nContent-Type: application/octet-stream \r\nContent-Transfer-Encoding: base64\r\n\r\n#{Base64.encode64(fileContent)}\r\n\r\n \r\n--*****MessageBoundary*****--\r\n"
299
+ response = http.request(request)
300
+ response.read_body
301
+ end
302
+
282
303
  end
283
304
 
284
305
  module Jsonpretty
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'usd'
3
- spec.version = '1.3.3'
4
- spec.date = '2020-09-11'
3
+ spec.version = '1.3.7'
4
+ spec.date = '2020-09-29'
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: 1.3.3
4
+ version: 1.3.7
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-09-11 00:00:00.000000000 Z
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -82,6 +82,7 @@ files:
82
82
  - bin/rusdc
83
83
  - bin/set_env
84
84
  - change_log.md
85
+ - images/vcard.png
85
86
  - lib/usd.rb
86
87
  - usd.gemspec
87
88
  homepage: https://github.com/ogaida/usd