usd 1.3.1 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/bin/rusdc +27 -40
- data/change_log.md +21 -1
- data/images/vcard.png +0 -0
- data/lib/usd.rb +21 -1
- data/usd.gemspec +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70fbd18a6341df303be1897efab57eefae5c72db3f4e94af89cd7da4900281ad
|
4
|
+
data.tar.gz: ee6882af88f19c208d113bab4d96b2b7725d4e0c635b02c6e885153dd6c95475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9954d1e3f35a7d2f506e94cf5354f2e3c4ff74b27c855f56fe7e13310bd5cef8e5addc4937e1c01dfee23e803680da3e6c39a32eab22812efb8708279031d88
|
7
|
+
data.tar.gz: e9f4192677bb57d007d8eb98640e8a5e2de42d8053f906caae1ec3494c314f4ef41753b06151a842c935f8e972740319d7ae65d4bfec2fa7bb8105c4971cd550
|
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
|
```
|
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
|
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,15 @@ 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
235
|
ids = loadcon.search("lrel_attachments_changes",{'fields' => "*","wc" => "chg.chg_ref_num = 'CO341144' and attmnt.orig_file_name = 'IMAP61A845F524A9D06536_3212.eml'"})
|
238
236
|
puts loadcon.request("/caisd-rest/attmnt/#{ids[0]["@id"]}/file-resource",{:unchanged => true}) if ids.class == Array
|
239
237
|
end
|
240
238
|
|
241
|
-
|
242
|
-
#lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num
|
243
|
-
desc "in_add_attachment <in> <file>", "attach the file to incident"
|
239
|
+
desc "in_add_attachment <in> <file>", "attach a file to an incident or problem"
|
244
240
|
def in_add_attachment(incident, file)
|
245
|
-
response = upload_attachment(file
|
241
|
+
response = loadcon.upload_attachment(file)
|
246
242
|
puts response
|
247
243
|
data = JSON.parse(response)
|
248
244
|
template = ERB.new <<-EOF
|
@@ -261,7 +257,6 @@ class Rusdc < Thor
|
|
261
257
|
:id => data["attmnt"]["@id"],
|
262
258
|
:incident => incident
|
263
259
|
})
|
264
|
-
#puts "create relation to chg with json: #{json}"
|
265
260
|
puts loadcon.create({:type => "json", :data => json})
|
266
261
|
end
|
267
262
|
|
@@ -292,7 +287,7 @@ class Rusdc < Thor
|
|
292
287
|
end
|
293
288
|
end
|
294
289
|
|
295
|
-
desc "list_attachments_of_in <in>", "list all attachments of an
|
290
|
+
desc "list_attachments_of_in <in>", "list all attachments of an incident or problem"
|
296
291
|
def list_attachments_of_in(incident)
|
297
292
|
att_in = loadcon.search("lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num = '#{incident}'"})
|
298
293
|
att_in.each do |att|
|
@@ -302,7 +297,7 @@ class Rusdc < Thor
|
|
302
297
|
|
303
298
|
desc "nr_add_attachment <nr> <file>", "attach the file to nr"
|
304
299
|
def nr_add_attachment(nr, file)
|
305
|
-
response = upload_attachment(file
|
300
|
+
response = loadcon.upload_attachment(file)
|
306
301
|
puts response
|
307
302
|
data = JSON.parse(response)
|
308
303
|
nr_id = loadcon.search("nr",{'fields' => "@id","wc" => "name = '#{nr}'"})[0]["@id"]
|
@@ -344,6 +339,28 @@ class Rusdc < Thor
|
|
344
339
|
puts loadcon.create({:type => "json", :data => json})
|
345
340
|
end
|
346
341
|
|
342
|
+
desc "nr_add_contact <nr> <cnt_email>", "add contact to configuration-item"
|
343
|
+
def nr_add_contact(nr, cnt_email)
|
344
|
+
template = ERB.new <<-EOF
|
345
|
+
{
|
346
|
+
"lrel_cenv_cntref": {
|
347
|
+
"nr": {
|
348
|
+
"@id": "<%= uid_nr %>"
|
349
|
+
},
|
350
|
+
"cnt": {
|
351
|
+
"@id": "<%= uid_cnt %>"
|
352
|
+
}
|
353
|
+
}
|
354
|
+
}
|
355
|
+
EOF
|
356
|
+
json = template.result_with_hash({
|
357
|
+
:uid_nr => loadcon.request("/caisd-rest/nr/COMMON_NAME-#{nr}")["nr"]["@id"],
|
358
|
+
:uid_cnt => loadcon.search("cnt",{'fields' => "@id","wc" => "email_address = '#{cnt_email}'"})[0]["@id"]
|
359
|
+
})
|
360
|
+
#puts "create relation to chg with json: #{json}"
|
361
|
+
puts loadcon.create({:type => "json", :data => json})
|
362
|
+
end
|
363
|
+
|
347
364
|
desc "nr_add_org <nr> <org>", "add an Organisation to a ConfigurationItem"
|
348
365
|
def nr_add_org(nr, org)
|
349
366
|
template = ERB.new <<-EOF
|
@@ -569,36 +586,6 @@ END:VCARD
|
|
569
586
|
end
|
570
587
|
end
|
571
588
|
|
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
|
-
|
602
589
|
end
|
603
590
|
|
604
591
|
Rusdc.start(ARGV)
|
data/change_log.md
CHANGED
@@ -1,11 +1,31 @@
|
|
1
1
|
# rusdc changelog
|
2
2
|
|
3
|
+
## 1.3.5
|
4
|
+
|
5
|
+
- new function `nr_add_contact <nr> <email>` to assign a contact to a configuration-item
|
6
|
+
|
7
|
+
## 1.3.4.1
|
8
|
+
|
9
|
+
- fixed another error in Usd.search. which comes with 1.3.1 .
|
10
|
+
|
11
|
+
## 1.3.4
|
12
|
+
|
13
|
+
- move function `upload_attachment` from `bin/rusdc` to `lib/usd`.
|
14
|
+
|
15
|
+
## 1.3.3
|
16
|
+
|
17
|
+
- private `rusdc`-funktion `upload_attachment` changed. Instead using `base64` and `unix2dos` binaries, we use Base64-Ruby-Class now. It is already required by usd.
|
18
|
+
|
19
|
+
## 1.3.2
|
20
|
+
|
21
|
+
- fixed error in Usd.search. which comes with 1.3.1 .
|
22
|
+
|
3
23
|
## 1.3.1
|
4
24
|
|
5
25
|
- new functions:
|
6
26
|
- `chg_add_attachment`
|
7
27
|
- `nr_add_attachment`
|
8
|
-
- `
|
28
|
+
- `in_add_attachment`
|
9
29
|
- `vcard_via_email`
|
10
30
|
|
11
31
|
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.
|
data/images/vcard.png
ADDED
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 "].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,26 @@ 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
|
+
uri = "/caisd-rest/attmnt?repositoryId=1002&serverName=#{server}&mimeType=Text&description=#{filename}"
|
287
|
+
url = URI("#{baseurl}#{uri}")
|
288
|
+
http = Net::HTTP.new(url.host, url.port);
|
289
|
+
request = Net::HTTP::Post.new(url)
|
290
|
+
request["X-AccessKey"] = ak
|
291
|
+
request["Content-Type"] = "multipart/form-data; BOUNDARY=*****MessageBoundary*****"
|
292
|
+
request["accept"] = "application/json"
|
293
|
+
request["Cache-Control"] = "no-cache"
|
294
|
+
fileObj = File.open(file, "rb")
|
295
|
+
fileContent = fileObj.read
|
296
|
+
fileObj.close
|
297
|
+
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"
|
298
|
+
response = http.request(request)
|
299
|
+
response.read_body
|
300
|
+
end
|
301
|
+
|
282
302
|
end
|
283
303
|
|
284
304
|
module Jsonpretty
|
data/usd.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'usd'
|
3
|
-
spec.version = '1.3.
|
4
|
-
spec.date = '2020-09-
|
3
|
+
spec.version = '1.3.5'
|
4
|
+
spec.date = '2020-09-25'
|
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.
|
4
|
+
version: 1.3.5
|
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
|
+
date: 2020-09-25 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
|