loader_droid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/loader_droid +44 -0
- data/case_manager.rb +59 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7857681d212763c24b2fc247bb3daaa9fe45f414
|
4
|
+
data.tar.gz: a6076627d10312882bf5700e1d4f8ad48fd58fcd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45d62f3387c847eb36fea9da82ce70ea614b659d85b4725771ed66d4a2b756529c98b54ad18d86e60262143b50dc256d564891acf3d5c51f135fc763442ab828
|
7
|
+
data.tar.gz: 891a9a1168b9b5867e33d23db1be048e35728cf0d248e2eabfdbd552a6a953700f1be8bc64b89ac648677fb7eecf31156ca5dd566e9f5d394f0cb72bdb54040d
|
data/bin/loader_droid
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "thor"
|
3
|
+
require "faker"
|
4
|
+
|
5
|
+
require_relative "../case_manager.rb"
|
6
|
+
|
7
|
+
class LoaderDroid < Thor
|
8
|
+
|
9
|
+
desc "solutions URL USERNAME PASSWORD", "List solutions"
|
10
|
+
def solutions(base_url, username, password)
|
11
|
+
c = CaseManager.new(base_url, username, password)
|
12
|
+
response = c.solution_list
|
13
|
+
json = JSON.parse(response.body)
|
14
|
+
json.each do |solution_json|
|
15
|
+
puts "#{solution_json["name"]}\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "create_case YML_FILE PASSWORD", "Create a case"
|
20
|
+
method_options :count => 1
|
21
|
+
def create_case(properties_yml_file, password)
|
22
|
+
config = YAML.load_file(properties_yml_file)
|
23
|
+
c = CaseManager.new(config["server"]["base_url"], config["server"]["username"], password)
|
24
|
+
|
25
|
+
case_properties = config["case_properties"]
|
26
|
+
options[:count].times do
|
27
|
+
dynamic_properties = {}
|
28
|
+
config["dynamic_case_properties"].each_pair do |k,v|
|
29
|
+
dynamic_properties[k] = eval(v)
|
30
|
+
end
|
31
|
+
|
32
|
+
all_case_properties = {}
|
33
|
+
all_case_properties.merge!(dynamic_properties) if dynamic_properties
|
34
|
+
all_case_properties.merge!(case_properties) if case_properties
|
35
|
+
|
36
|
+
puts "** #{all_case_properties}"
|
37
|
+
|
38
|
+
response = c.create_case(config["solution_name"], config["case_type"], all_case_properties)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
LoaderDroid.start
|
data/case_manager.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
class CaseManager
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
#debug_output $stdout
|
7
|
+
|
8
|
+
def initialize(base_url, username, password)
|
9
|
+
@base_url = base_url
|
10
|
+
@username = username
|
11
|
+
@password = password
|
12
|
+
end
|
13
|
+
|
14
|
+
def logon
|
15
|
+
options = {query: {userid: @username, password: @password}}
|
16
|
+
response = self.class.post("#{@base_url}/logon.do", options)
|
17
|
+
json = JSON.parse(response.body[4..-1])
|
18
|
+
@security_token = json['security_token']
|
19
|
+
@cookie = response.headers['Set-Cookie']
|
20
|
+
end
|
21
|
+
|
22
|
+
def solution_list
|
23
|
+
self.logon unless @security_token
|
24
|
+
|
25
|
+
options = query_options("SolutionListService").merge(cookie_options)
|
26
|
+
|
27
|
+
self.class.get("#{@base_url}/plugin.do", options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def solution_details(solution_name)
|
31
|
+
self.logon unless @security_token
|
32
|
+
|
33
|
+
options = query_options("SolutionDetailsService", solution_name).merge(cookie_options)
|
34
|
+
|
35
|
+
self.class.get("#{@base_url}/plugin.do", options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_case(solution_name, case_type, case_properties)
|
39
|
+
self.logon unless @security_token
|
40
|
+
|
41
|
+
options = query_options("CreateCaseService", solution_name)
|
42
|
+
options[:query].merge!({case_type: case_type, case_properties: case_properties.to_json })
|
43
|
+
options.merge!(cookie_options)
|
44
|
+
|
45
|
+
self.class.post("#{@base_url}/plugin.do", options)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def query_options(action, solution_name = nil)
|
50
|
+
options = { query: {security_token: @security_token, plugin: "CaseAccelerator", action: action} }
|
51
|
+
options[:query][:solution_name] = solution_name if solution_name
|
52
|
+
return options
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def cookie_options
|
57
|
+
{ headers: {"Cookie" => @cookie} }
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: loader_droid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Brooke-Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem to help loading cases into Case Manager
|
14
|
+
email: matt@futureworkshops.com
|
15
|
+
executables:
|
16
|
+
- loader_droid
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/loader_droid
|
21
|
+
- case_manager.rb
|
22
|
+
homepage: http://rubygems.org/gems/loader_droid
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.5.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: IBM Case Manager Loader Droid
|
46
|
+
test_files: []
|