usd 1.3.5 → 1.4.2

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: 70fbd18a6341df303be1897efab57eefae5c72db3f4e94af89cd7da4900281ad
4
- data.tar.gz: ee6882af88f19c208d113bab4d96b2b7725d4e0c635b02c6e885153dd6c95475
3
+ metadata.gz: ad9d4b334ba1e9d009ec6eb8a2192afa40ab2d777669d5cf1c96f9559f288c9a
4
+ data.tar.gz: 488d9459d4f3bbfeaffe54eedc225f6d14505e779019c058c7ca3d5c4bf4e338
5
5
  SHA512:
6
- metadata.gz: a9954d1e3f35a7d2f506e94cf5354f2e3c4ff74b27c855f56fe7e13310bd5cef8e5addc4937e1c01dfee23e803680da3e6c39a32eab22812efb8708279031d88
7
- data.tar.gz: e9f4192677bb57d007d8eb98640e8a5e2de42d8053f906caae1ec3494c314f4ef41753b06151a842c935f8e972740319d7ae65d4bfec2fa7bb8105c4971cd550
6
+ metadata.gz: 91a0ff217c1abbd4f1f6d86bfbe151e9ca757cf6a7d19484773e257b38b4927f57f4f9d917d8cafa011c6952075e8e64cc163af55ee6b84f67dbb91a3124731e
7
+ data.tar.gz: e8132c8e6f4e7f1ad35de70224fd3017616a7503ae9edcd441a5e4294795641a97e578adbaa356717e6d9e00a35854152fdbfcee06ea79f9d4664bdc393bb294
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,8 +232,14 @@ 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
245
  desc "in_add_attachment <in> <file>", "attach a file to an incident or problem"
@@ -514,7 +520,7 @@ class Rusdc < Thor
514
520
  })
515
521
  data = loadcon.update({:type => "json", :data => json})
516
522
  if data.class == RestClient::BadRequest
517
- 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."
518
524
  cn_id = loadcon.search(obj,{'fields' => "@id","wc" => "#{Usd::CN[obj]} = '#{cn}' and delete_flag = 0"})[0]["@id"]
519
525
  value_id = loadcon.search(ref_obj,{'fields' => "@id","wc" => "#{Usd::CN[ref_obj]} = '#{v}' and delete_flag = 0"})[0]["@id"]
520
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.2
4
+
5
+ - count number changed for search method from fixed value of 50 to dynamic value
6
+
7
+ ## 1.4.1
8
+
9
+ - changed some comments
10
+
11
+ ## 1.4.0
12
+
13
+ - remove "warning: URI.escape is obsolete"
14
+
15
+ ## 1.3.7
16
+
17
+ - Bugfix in rusdc-function `get_attachment_of_co`
18
+
19
+ ## 1.3.6
20
+
21
+ - Bugfix : uploaded filename with special character will be renamed with `URI.escape`
22
+
3
23
  ## 1.3.5
4
24
 
5
25
  - new function `nr_add_contact <nr> <email>` to assign a contact to a configuration-item
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"
@@ -271,7 +273,7 @@ class Usd
271
273
  else
272
274
  retArray = res_rdata["collection_#{object}"][object]
273
275
  if total_count > (count + start - 1)
274
- new_params = {"start" => (start + 50)}
276
+ new_params = {"start" => (start + count)}
275
277
  params = params.update new_params
276
278
  retArray += search(object,params)
277
279
  end
@@ -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.5'
4
- spec.date = '2020-09-25'
3
+ spec.version = '1.4.2'
4
+ spec.date = '2020-12-18'
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.5
4
+ version: 1.4.2
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-25 00:00:00.000000000 Z
11
+ date: 2020-12-18 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