usd 1.3.4.1 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2dc7c020bc56752e81b0ca22201b6661e17a1fcf54ffb37295ce19ad779fd7d
4
- data.tar.gz: ef77af20f3e5a2c1b6b71c2f8a78cad5f38da174908c33da9ef6a41c8fcb71be
3
+ metadata.gz: 96c72b434c05223e7b76a1d26c22920f95ced983ce6641f89b3fc3c0e22d5b81
4
+ data.tar.gz: 6fa9a8022c88a580c23063299efb14be72432871e36f08360479b7b88ca0cd6d
5
5
  SHA512:
6
- metadata.gz: 0edea409a25f20dac2a91f5ecdacfaf9fbf5b954d7d30801a5c12cf23080789c3f616f2d08947632cf90efdd55cb1ed1fc1bf46870921789e759782739d51344
7
- data.tar.gz: 972f687caeea7d9a6b71a1704018ff67cc2da94e81849fbc0aaca93f27eb1b43c7f9b3a44a4917c095e8344f48caa277a76faf7a79bb04262539338e97c9cc66
6
+ metadata.gz: 47aed70bac5221913bdb28bd1a9534af9a4770fbe48fb45461242289873c8fa0c68855c8ff2ade0f457f490397cf3d6c64694db872536d4a1d114453a4afa216
7
+ data.tar.gz: 8ea6c8a638e56326a273cb09df3911ac9ac19f53bd3b048d4bae8e60d02db1190ae2ec6ef94c861c9127b477eaee17407b8fafb72e89926a7f7630f379eb769e
data/LICENSE.md CHANGED
File without changes
data/README.md CHANGED
@@ -56,13 +56,14 @@ rusdc get_attachment_of_co <co_name> <filename> # d
56
56
  rusdc get_attachment_of_in <incident> <filename> # download an attachment of an Incident and print it out on stdout
57
57
  rusdc help [COMMAND] # Describe available commands or one specific command
58
58
  rusdc in_add_2_chg <changeorder> <incident> # add incident to changeorder
59
- 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
60
60
  rusdc in_list_child_ins <in> # list all child-incidents of one incident
61
61
  rusdc list_attachments_of_ci <ci_name> # list all attachments of a CI
62
62
  rusdc list_attachments_of_co <co_name> # list all attachments of a changeorder
63
- 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
64
64
  rusdc nr_add_attachment <nr> <file> # attach the file to nr
65
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
66
67
  rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem
67
68
  rusdc nr_changes <nr> [inactive-too] # list all open changeorders of one CI
68
69
  rusdc nr_childs <ci-name> # lists all childs CIs of a specific CI
@@ -112,3 +113,11 @@ foo2 foo TEST
112
113
  ```
113
114
 
114
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]">
120
+
121
+ # feedback
122
+
123
+ Since I could only test this gem in a 14.1 environment, I would be interested to know whether it also works in a version 17 environment of CA Service Management. Any kind of feedback is very welcome.
data/bin/rusdc CHANGED
@@ -232,11 +232,17 @@ class Rusdc < Thor
232
232
 
233
233
  desc "get_attachment_of_co <co_name> <filename>", "download an attachment of a changeorder and print it out on stdout"
234
234
  def get_attachment_of_co(coname, filename)
235
- ids = loadcon.search("lrel_attachments_changes",{'fields' => "*","wc" => "chg.chg_ref_num = 'CO341144' and attmnt.orig_file_name = 'IMAP61A845F524A9D06536_3212.eml'"})
236
- 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
237
243
  end
238
244
 
239
- 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"
240
246
  def in_add_attachment(incident, file)
241
247
  response = loadcon.upload_attachment(file)
242
248
  puts response
@@ -287,7 +293,7 @@ class Rusdc < Thor
287
293
  end
288
294
  end
289
295
 
290
- 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"
291
297
  def list_attachments_of_in(incident)
292
298
  att_in = loadcon.search("lrel_attachments_requests",{'fields' => "attmnt","wc" => "cr.ref_num = '#{incident}'"})
293
299
  att_in.each do |att|
@@ -339,6 +345,28 @@ class Rusdc < Thor
339
345
  puts loadcon.create({:type => "json", :data => json})
340
346
  end
341
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
+
342
370
  desc "nr_add_org <nr> <org>", "add an Organisation to a ConfigurationItem"
343
371
  def nr_add_org(nr, org)
344
372
  template = ERB.new <<-EOF
@@ -492,7 +520,7 @@ class Rusdc < Thor
492
520
  })
493
521
  data = loadcon.update({:type => "json", :data => json})
494
522
  if data.class == RestClient::BadRequest
495
- puts "BadRequest-Response from USD-API, try to update via IDs. be aware to specify a ref_obj if it's not nr."
523
+ puts "Hint: Do not panic, I got a bad Request-Response from USD-API. Now I try again to update via IDs of COMMON_NAME arguments. Be aware to specify a ref_obj if it's not nr."
496
524
  cn_id = loadcon.search(obj,{'fields' => "@id","wc" => "#{Usd::CN[obj]} = '#{cn}' and delete_flag = 0"})[0]["@id"]
497
525
  value_id = loadcon.search(ref_obj,{'fields' => "@id","wc" => "#{Usd::CN[ref_obj]} = '#{v}' and delete_flag = 0"})[0]["@id"]
498
526
  invoke "update_ref_attr_by_id", [obj, cn_id, k, value_id]
File without changes
@@ -1,5 +1,25 @@
1
1
  # rusdc changelog
2
2
 
3
+ ## 1.4.1
4
+
5
+ - changed some comments
6
+
7
+ ## 1.4.0
8
+
9
+ - remove "warning: URI.escape is obsolete"
10
+
11
+ ## 1.3.7
12
+
13
+ - Bugfix in rusdc-function `get_attachment_of_co`
14
+
15
+ ## 1.3.6
16
+
17
+ - Bugfix : uploaded filename with special character will be renamed with `URI.escape`
18
+
19
+ ## 1.3.5
20
+
21
+ - new function `nr_add_contact <nr> <email>` to assign a contact to a configuration-item
22
+
3
23
  ## 1.3.4.1
4
24
 
5
25
  - fixed another error in Usd.search. which comes with 1.3.1 .
File without changes
data/lib/usd.rb CHANGED
@@ -11,6 +11,7 @@ require 'tempfile'
11
11
  class Usd
12
12
 
13
13
  CN={
14
+ "grc" => "type",
14
15
  "chg" => "chg_ref_num",
15
16
  "cnt" => "combo_name",
16
17
  "arcpur_rule" => "name",
@@ -160,10 +161,11 @@ class Usd
160
161
  RestClient.log = STDOUT if @debug
161
162
  hash = {:method => "get", :header => header(), :unchanged => false, :json => "", :base_url => @base_url}.update hash
162
163
  puts "request - hash: #{JSON.pretty_generate(hash)}" if @debug
164
+ parser = URI::RFC2396_Parser.new
163
165
  if (uri !~ /^http/)
164
- url = URI.escape("#{hash[:base_url]}#{uri}")
166
+ url = parser.escape("#{hash[:base_url]}#{uri}")
165
167
  else
166
- url = URI.escape(uri)
168
+ url = parser.escape(uri)
167
169
  end
168
170
  begin
169
171
  if hash[:method] == "get"
@@ -283,7 +285,9 @@ class Usd
283
285
  baseurl =~ /^([^:]+):/
284
286
  server = $1
285
287
  filename = File.basename(file)
286
- uri = "/caisd-rest/attmnt?repositoryId=1002&serverName=#{server}&mimeType=Text&description=#{filename}"
288
+ #filename_escaped = URI.escape(filename)
289
+ filename_escaped = filename.gsub(/[^0-9A-Za-z.\-]/, '_')
290
+ uri = "/caisd-rest/attmnt?repositoryId=1002&serverName=#{server}&mimeType=Text&description=#{filename_escaped}"
287
291
  url = URI("#{baseurl}#{uri}")
288
292
  http = Net::HTTP.new(url.host, url.port);
289
293
  request = Net::HTTP::Post.new(url)
@@ -294,7 +298,7 @@ class Usd
294
298
  fileObj = File.open(file, "rb")
295
299
  fileContent = fileObj.read
296
300
  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"
301
+ 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"
298
302
  response = http.request(request)
299
303
  response.read_body
300
304
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'usd'
3
- spec.version = '1.3.4.1'
4
- spec.date = '2020-09-11'
3
+ spec.version = '1.4.1'
4
+ spec.date = '2020-12-01'
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"]
@@ -13,4 +13,5 @@ Gem::Specification.new do |spec|
13
13
  spec.add_runtime_dependency 'thor', '~> 0.20', '>= 0.20.3'
14
14
  spec.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
15
15
  spec.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
16
+ spec.license = 'MIT'
16
17
  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: 1.3.4.1
4
+ version: 1.4.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-09-11 00:00:00.000000000 Z
11
+ date: 2020-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -86,7 +86,8 @@ files:
86
86
  - lib/usd.rb
87
87
  - usd.gemspec
88
88
  homepage: https://github.com/ogaida/usd
89
- licenses: []
89
+ licenses:
90
+ - MIT
90
91
  metadata: {}
91
92
  post_install_message:
92
93
  rdoc_options: []
@@ -103,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.6
107
+ rubygems_version: 3.1.2
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: SDM REST-API-Calls