pvdgm-svc-client 0.2.2 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/Gemfile.lock +91 -56
- data/VERSION +1 -1
- data/lib/pvdgm-svc-client/prompters/configured_user_prompter.rb +30 -0
- data/lib/pvdgm-svc-client/prompters/user_mapping_prompter.rb +26 -0
- data/lib/pvdgm-svc-client/resources/configured_user.rb +117 -0
- data/lib/pvdgm-svc-client/resources/third_party.rb +7 -4
- data/lib/pvdgm-svc-client/resources/user_mapping.rb +83 -0
- data/pvdgm-svc-client.gemspec +32 -28
- metadata +37 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0bff17742c0880a08daa3dba2f4112ef43312cc
|
4
|
+
data.tar.gz: 65b9fc1294fe5a79a7df56a7707f80cfafcee48b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f50d06523644cb503aa6caea9b0c45990de36d332bc76de5d2c833d77745619a7912e95a466571688456931d08fd13cb58f5733670a5377e04be4738d886a549
|
7
|
+
data.tar.gz: 67d66f9cdf6e123dfbf385b1d370cc9a38fdb4ef9df10cb6ec9cd82241ce9f5a51a98f91c1c8751b60d7e0970b0425d0331a7f6c3ad63eb9c1e818f456d363e6
|
data/Gemfile
CHANGED
@@ -2,16 +2,16 @@ source "http://rubygems.org"
|
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
|
-
gem "activesupport", "
|
6
|
-
gem "rest-client",
|
7
|
-
gem 'terminal-table'
|
8
|
-
gem 'highline'
|
5
|
+
gem "activesupport", ">= 4.2.7", :require => 'active_support'
|
6
|
+
gem "rest-client", '~> 1.8.0'
|
7
|
+
gem 'terminal-table'
|
8
|
+
gem 'highline'
|
9
9
|
|
10
10
|
# Add dependencies to develop your gem here.
|
11
11
|
# Include everything needed to run rake, tests, features, etc.
|
12
12
|
group :development do
|
13
|
-
gem "rspec", "
|
14
|
-
gem "rdoc"
|
15
|
-
gem "bundler"
|
16
|
-
gem "jeweler"
|
13
|
+
gem "rspec", ">= 3.5"
|
14
|
+
gem "rdoc"
|
15
|
+
gem "bundler"
|
16
|
+
gem "jeweler"
|
17
17
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,73 +1,108 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
activesupport (5.0.1)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (~> 0.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
tzinfo (~> 1.1)
|
9
|
+
addressable (2.5.0)
|
10
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
11
|
+
builder (3.2.3)
|
12
|
+
concurrent-ruby (1.0.4)
|
13
|
+
descendants_tracker (0.0.4)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
domain_name (0.5.20161129)
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
18
|
+
faraday (0.9.2)
|
19
|
+
multipart-post (>= 1.2, < 3)
|
20
|
+
git (1.3.0)
|
21
|
+
github_api (0.11.3)
|
22
|
+
addressable (~> 2.3)
|
23
|
+
descendants_tracker (~> 0.0.1)
|
24
|
+
faraday (~> 0.8, < 0.10)
|
16
25
|
hashie (>= 1.2)
|
17
|
-
multi_json (
|
18
|
-
nokogiri (~> 1.
|
26
|
+
multi_json (>= 1.7.5, < 2.0)
|
27
|
+
nokogiri (~> 1.6.0)
|
19
28
|
oauth2
|
20
|
-
hashie (
|
21
|
-
highline (1.
|
22
|
-
|
23
|
-
|
29
|
+
hashie (3.4.6)
|
30
|
+
highline (1.7.8)
|
31
|
+
http-cookie (1.0.3)
|
32
|
+
domain_name (~> 0.5)
|
33
|
+
i18n (0.7.0)
|
34
|
+
jeweler (2.3.3)
|
24
35
|
builder
|
25
|
-
bundler (
|
36
|
+
bundler (>= 1.0)
|
26
37
|
git (>= 1.2.5)
|
27
|
-
github_api (
|
38
|
+
github_api (~> 0.11.0)
|
28
39
|
highline (>= 1.6.15)
|
29
|
-
nokogiri (
|
40
|
+
nokogiri (>= 1.5.10)
|
41
|
+
psych (~> 2.2)
|
30
42
|
rake
|
31
43
|
rdoc
|
32
|
-
|
33
|
-
jwt (
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
44
|
+
semver2
|
45
|
+
jwt (1.5.6)
|
46
|
+
mime-types (2.99.3)
|
47
|
+
mini_portile2 (2.1.0)
|
48
|
+
minitest (5.10.1)
|
49
|
+
multi_json (1.12.1)
|
50
|
+
multi_xml (0.6.0)
|
51
|
+
multipart-post (2.0.0)
|
52
|
+
netrc (0.11.0)
|
53
|
+
nokogiri (1.6.8.1)
|
54
|
+
mini_portile2 (~> 2.1.0)
|
55
|
+
oauth2 (1.3.0)
|
56
|
+
faraday (>= 0.8, < 0.11)
|
57
|
+
jwt (~> 1.0)
|
43
58
|
multi_json (~> 1.3)
|
44
59
|
multi_xml (~> 0.5)
|
45
|
-
rack (
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
rspec-
|
60
|
-
|
60
|
+
rack (>= 1.2, < 3)
|
61
|
+
psych (2.2.2)
|
62
|
+
public_suffix (2.0.5)
|
63
|
+
rack (2.0.1)
|
64
|
+
rake (12.0.0)
|
65
|
+
rdoc (5.0.0)
|
66
|
+
rest-client (1.8.0)
|
67
|
+
http-cookie (>= 1.0.2, < 2.0)
|
68
|
+
mime-types (>= 1.16, < 3.0)
|
69
|
+
netrc (~> 0.7)
|
70
|
+
rspec (3.5.0)
|
71
|
+
rspec-core (~> 3.5.0)
|
72
|
+
rspec-expectations (~> 3.5.0)
|
73
|
+
rspec-mocks (~> 3.5.0)
|
74
|
+
rspec-core (3.5.4)
|
75
|
+
rspec-support (~> 3.5.0)
|
76
|
+
rspec-expectations (3.5.0)
|
77
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
+
rspec-support (~> 3.5.0)
|
79
|
+
rspec-mocks (3.5.0)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.5.0)
|
82
|
+
rspec-support (3.5.0)
|
83
|
+
semver2 (3.4.2)
|
84
|
+
terminal-table (1.7.3)
|
85
|
+
unicode-display_width (~> 1.1.1)
|
86
|
+
thread_safe (0.3.5)
|
87
|
+
tzinfo (1.2.2)
|
88
|
+
thread_safe (~> 0.1)
|
89
|
+
unf (0.1.4)
|
90
|
+
unf_ext
|
91
|
+
unf_ext (0.0.7.2)
|
92
|
+
unicode-display_width (1.1.3)
|
61
93
|
|
62
94
|
PLATFORMS
|
63
95
|
ruby
|
64
96
|
|
65
97
|
DEPENDENCIES
|
66
|
-
activesupport (
|
67
|
-
bundler
|
68
|
-
highline
|
69
|
-
jeweler
|
70
|
-
rdoc
|
71
|
-
rest-client (~> 1.
|
72
|
-
rspec (
|
73
|
-
terminal-table
|
98
|
+
activesupport (>= 4.2.7)
|
99
|
+
bundler
|
100
|
+
highline
|
101
|
+
jeweler
|
102
|
+
rdoc
|
103
|
+
rest-client (~> 1.8.0)
|
104
|
+
rspec (>= 3.5)
|
105
|
+
terminal-table
|
106
|
+
|
107
|
+
BUNDLED WITH
|
108
|
+
1.14.2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.2
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ConfiguredUserPrompter
|
2
|
+
|
3
|
+
def configured_user_id(allow_none=false)
|
4
|
+
return options[:configured_user_id] if options[:configured_user_id]
|
5
|
+
return options[:configured_user_id] = ENV['CONFIGURED_USER_ID'] if ENV['CONFIGURED_USER_ID']
|
6
|
+
return options[:configured_user_id] = prompt_for_configured_user_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_configured_user_id(allow_none)
|
12
|
+
if respond_to?(:third_party_id)
|
13
|
+
result = get("services/third_parties/#{third_party_id}/service_definitions/#{service_definition_id}/configured_users")
|
14
|
+
elsif respond_to?(:service_id)
|
15
|
+
result = get("services/services/#{service_id}/service_definitions/#{service_definition_id}/configured_users")
|
16
|
+
end
|
17
|
+
|
18
|
+
(puts "No users have been configured for this service/third party. Cannot continue"; exit 1) if result.empty?
|
19
|
+
|
20
|
+
# Build a menu of the services
|
21
|
+
puts
|
22
|
+
return prompter.choose do | menu |
|
23
|
+
menu.prompt = "Select the Configured User: "
|
24
|
+
menu.choice("No Selection") { -1 } if allow_none
|
25
|
+
result.each do | configured_user |
|
26
|
+
menu.choice("#{configured_user['user_name']} (#{configured_user['user_id']}) - #{configured_user['enabled']}") { configured_user['id'] }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module UserMappingPrompter
|
2
|
+
|
3
|
+
def user_mapping_id(allow_none=false)
|
4
|
+
return options[:user_mapping_id] if options[:user_mapping_id]
|
5
|
+
return options[:user_mapping_id] = ENV['USER_MAPPING_ID'] if ENV['USER_MAPPING_ID']
|
6
|
+
return options[:user_mapping_id] = prompt_for_user_mapping_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_user_mapping_id(allow_none)
|
12
|
+
result = get("services/third_parties/#{third_party_id}/user_mappings")
|
13
|
+
|
14
|
+
(puts "No third-parties are defined. Cannot continue"; exit 1) if result.empty?
|
15
|
+
|
16
|
+
# Build a menu of the user mappings
|
17
|
+
puts
|
18
|
+
return prompter.choose do | menu |
|
19
|
+
menu.prompt = "Select the User Mapping: "
|
20
|
+
menu.choice("No Selection") { -1 } if allow_none
|
21
|
+
result.each do | user_mapping |
|
22
|
+
menu.choice("#{user_mapping['user_name']} (#{user_mapping['user_id']}) - #{user_mapping['user_code']}") { user_mapping['id'] }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module Resources
|
2
|
+
|
3
|
+
class ConfiguredUser < BaseResource
|
4
|
+
include ThirdPartyPrompter
|
5
|
+
include ServiceDefinitionPrompter
|
6
|
+
include ConfiguredUserPrompter
|
7
|
+
|
8
|
+
def list
|
9
|
+
tp_id = third_party_id
|
10
|
+
sd_id = service_definition_id
|
11
|
+
result = get("services/third_parties/#{tp_id}/service_definitions/#{sd_id}/configured_users")
|
12
|
+
puts "\nConfigured users for third party: #{tp_id}, service definition: #{sd_id}"
|
13
|
+
table = Terminal::Table.new headings: [ 'Service Def ID', 'User ID', 'User Name', 'Enabled', 'Password', 'Token' ] do |t|
|
14
|
+
result.each do | configured_user |
|
15
|
+
t << [ configured_user['service_definition_id'],
|
16
|
+
"#{configured_user['user_name']} (#{configured_user['user_id']})",
|
17
|
+
configured_user['username'],
|
18
|
+
configured_user['enabled'],
|
19
|
+
configured_user['password'],
|
20
|
+
configured_user['token'] ]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
prompter.say table.to_s
|
24
|
+
puts
|
25
|
+
end
|
26
|
+
|
27
|
+
def show
|
28
|
+
tp_id = third_party_id
|
29
|
+
sd_id = service_definition_id
|
30
|
+
cu_id = configured_user_id
|
31
|
+
configured_user = get("services/third_parties/#{tp_id}/service_definitions/#{sd_id}/configured_users/#{cu_id}")
|
32
|
+
@cu_user_id = configured_user['user_id']
|
33
|
+
@cu_username = configured_user['username']
|
34
|
+
@cu_enabled = configured_user['enabled']
|
35
|
+
@cu_password = configured_user['password']
|
36
|
+
@cu_token = configured_user['token']
|
37
|
+
puts "\nConfigured user for third party: #{tp_id}/#{options[:id]}"
|
38
|
+
table = Terminal::Table.new headings: [ 'Service Def Id', 'User ID', 'User Name', 'Enabled', 'Password', 'Token' ] do |t|
|
39
|
+
t << [ configured_user['service_definition_id'],
|
40
|
+
"#{configured_user['user_name']} (#{configured_user['user_id']})",
|
41
|
+
configured_user['username'],
|
42
|
+
configured_user['enabled'],
|
43
|
+
configured_user['password'],
|
44
|
+
configured_user['token'] ]
|
45
|
+
end
|
46
|
+
puts table
|
47
|
+
puts
|
48
|
+
end
|
49
|
+
|
50
|
+
def create
|
51
|
+
tp_id = third_party_id
|
52
|
+
sd_id = service_definition_id
|
53
|
+
params = {
|
54
|
+
configured_user: {
|
55
|
+
user_id: prompter.ask("\nUser ID: ", Integer) { |q| q.validate = lambda { |a| is_valid_object?('User', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid User ID" },
|
56
|
+
username: prompter.ask("\nUser name: ") { |q| q.validate = /\A.{0,255}\z/; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nInvalid user name" },
|
57
|
+
enabled: prompter.agree("\nEnabled? (y/n) ", true)
|
58
|
+
}
|
59
|
+
}
|
60
|
+
puts
|
61
|
+
password = prompter.ask("\nPassword: ")
|
62
|
+
token = prompter.ask("\nToken: ")
|
63
|
+
if (password && password.size > 0) || (token && token.size > 0)
|
64
|
+
params[:credential] = {
|
65
|
+
}
|
66
|
+
params[:credential][:password] = password if password && password.size > 0
|
67
|
+
params[:credential][:token] = token if token && token.size > 0
|
68
|
+
end
|
69
|
+
result = post("services/third_parties/#{tp_id}/service_definitions/#{sd_id}/configured_users", params)
|
70
|
+
puts "\nID of new configured user: #{result['id']}"
|
71
|
+
puts
|
72
|
+
end
|
73
|
+
|
74
|
+
def update
|
75
|
+
clear_default = ->(field) { field == "^" ? '' : field }
|
76
|
+
tp_id = third_party_id
|
77
|
+
sd_id = service_definition_id
|
78
|
+
cu_id = configured_user_id
|
79
|
+
show
|
80
|
+
params = {
|
81
|
+
configured_user: {
|
82
|
+
user_id: prompter.ask("\nUser ID: ", Integer) { |q| q.default = @cu_user_id; q.validate = lambda { |a| is_valid_object?('User', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid User ID" },
|
83
|
+
username: prompter.ask("\nUser name (^ to clear): ", clear_default) { |q| q.default = @cu_username; q.validate = /\A.{0,255}\z/; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nInvalid user name" },
|
84
|
+
enabled: prompter.agree("\nEnabled? ", true) { |q| q.default = @cu_enabled }
|
85
|
+
}
|
86
|
+
}
|
87
|
+
puts
|
88
|
+
password = prompter.ask("\nPassword (^ to clear): ", clear_default) { |q| q.default = @cu_password }
|
89
|
+
token = prompter.ask("\nToken (^ to clear): ", clear_default) { |q| q.default = @cu_token }
|
90
|
+
if (password && password.size > 0) || (token && token.size > 0)
|
91
|
+
params[:credential] = {
|
92
|
+
}
|
93
|
+
params[:credential][:password] = password if password && password.size > 0
|
94
|
+
params[:credential][:token] = token if token && token.size > 0
|
95
|
+
end
|
96
|
+
result = put("services/third_parties/#{tp_id}/service_definitions/#{sd_id}/configured_users/#{cu_id}", params)
|
97
|
+
puts "\nID of updated configured user: #{result['id']}"
|
98
|
+
puts
|
99
|
+
end
|
100
|
+
|
101
|
+
def destroy
|
102
|
+
tp_id = third_party_id
|
103
|
+
sd_id = service_definition_id
|
104
|
+
cu_id = configured_user_id
|
105
|
+
show
|
106
|
+
if prompter.agree("\nAre you sure you want to destroy this configured user? (y/n) ", true)
|
107
|
+
puts
|
108
|
+
result = delete("services/third_parties/#{tp_id}/service_definitions/#{sd_id}/configured_users/#{cu_id}")
|
109
|
+
puts "\nID of deleted configured user: #{result['id']}"
|
110
|
+
else
|
111
|
+
puts "\nCancelled deletion"
|
112
|
+
end
|
113
|
+
puts
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
@@ -8,9 +8,9 @@ module Resources
|
|
8
8
|
def list
|
9
9
|
result = get("services/third_parties")
|
10
10
|
puts "\nThird Parties:"
|
11
|
-
table = Terminal::Table.new headings: [ 'Name', 'Key', 'Contact Email' ] do |t|
|
11
|
+
table = Terminal::Table.new headings: [ 'Name', 'Key', 'Account ID', 'Contact Email' ] do |t|
|
12
12
|
result.each do | third_party |
|
13
|
-
t << [ third_party['name'], third_party['key'], third_party['contact_email'] ]
|
13
|
+
t << [ third_party['name'], third_party['key'], third_party['account_id'].present? ? "#{third_party['account_name']} (#{third_party['account_id']})" : '' , third_party['contact_email'] ]
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -23,10 +23,11 @@ module Resources
|
|
23
23
|
result = get("services/third_parties/#{tp_id}")
|
24
24
|
@third_party_name = result['name']
|
25
25
|
@third_party_key = result['key']
|
26
|
+
@third_party_acct_id = result['account_id']
|
26
27
|
@third_party_contact_email = result['contact_email']
|
27
28
|
puts "\nThird Party"
|
28
|
-
table = Terminal::Table.new headings: [ 'Name', 'Key', 'Contact Email' ] do |t|
|
29
|
-
t << [ result['name'], result['key'], result['contact_email'] ]
|
29
|
+
table = Terminal::Table.new headings: [ 'Name', 'Key', 'Account ID', 'Contact Email' ] do |t|
|
30
|
+
t << [ result['name'], result['key'], result['account_id'].present? ? "#{result['account_name']} (#{result['account_id']})" : '', result['contact_email'] ]
|
30
31
|
end
|
31
32
|
puts table
|
32
33
|
puts
|
@@ -37,6 +38,7 @@ module Resources
|
|
37
38
|
third_party: {
|
38
39
|
name: prompter.ask("\nName for new third party: ") { |q| q.validate = /\A.{1,255}\z/; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Third Party Name" },
|
39
40
|
key: prompter.ask("\nUnique key for third party: ") { |q| q.validate = /\A[a-zA-Z0-9_-]{1,255}\z/; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Third Party key" },
|
41
|
+
account_id: prompter.ask("\nAccount ID: ") { |q| q.validate = lambda { | a | a.blank? || is_valid_object?('Account', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Account ID" },
|
40
42
|
contact_email: prompter.ask("\nContact email address for new third party: ") { |q| q.validate = EMAIL_REGEX; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid email address" }
|
41
43
|
}
|
42
44
|
}
|
@@ -51,6 +53,7 @@ module Resources
|
|
51
53
|
third_party: {
|
52
54
|
name: prompter.ask("\nNew name for third party: ") { |q| q.default = @third_party_name; q.validate = /\A.{1,255}\z/; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Third Party Name" },
|
53
55
|
key: prompter.ask("\nUnique key for third party: ") { |q| q.default = @third_party_key; q.validate = /\A[a-zA-Z0-9_-]{1,255}\z/; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Third Party key" },
|
56
|
+
account_id: prompter.ask("\nAccount ID: ") { |q| q.default = @acct_id; q.validate = lambda { | a | a.blank? || is_valid_object?('Account', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Account ID" },
|
54
57
|
contact_email: prompter.ask("\nNew contact email address for third party: ") { |q| q.default = @third_party_contact_email; q.validate = EMAIL_REGEX; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid email address" }
|
55
58
|
}
|
56
59
|
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Resources
|
2
|
+
|
3
|
+
class UserMapping < BaseResource
|
4
|
+
include ThirdPartyPrompter
|
5
|
+
include UserMappingPrompter
|
6
|
+
|
7
|
+
def list
|
8
|
+
tp_id = third_party_id
|
9
|
+
result = get("services/third_parties/#{tp_id}/user_mappings")
|
10
|
+
puts "\nUser Mappings for third party: #{tp_id}"
|
11
|
+
table = Terminal::Table.new headings: [ 'Third Party', 'User', 'User Code' ] do |t|
|
12
|
+
result.each do | user_mapping |
|
13
|
+
t << [ "#{user_mapping['third_party_name']} (#{user_mapping['third_party_id']})",
|
14
|
+
"#{user_mapping['user_name']} (#{user_mapping['user_id']})",
|
15
|
+
user_mapping['user_code'] ]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
prompter.say table.to_s
|
19
|
+
puts
|
20
|
+
end
|
21
|
+
|
22
|
+
def show
|
23
|
+
tp_id = third_party_id
|
24
|
+
um_id = user_mapping_id
|
25
|
+
user_mapping = get("services/third_parties/#{tp_id}/user_mappings/#{um_id}")
|
26
|
+
@um_third_party_id = user_mapping['third_party_id']
|
27
|
+
@um_user_id = user_mapping['user_id']
|
28
|
+
@um_user_code = user_mapping['user_code']
|
29
|
+
puts "\nUser Mapping for third party: #{tp_id}/#{um_id}"
|
30
|
+
table = Terminal::Table.new headings: [ 'Third Party', 'User', 'User Code' ] do |t|
|
31
|
+
t << [ "#{user_mapping['third_party_name']} (#{user_mapping['third_party_id']})",
|
32
|
+
"#{user_mapping['user_name']} (#{user_mapping['user_id']})",
|
33
|
+
user_mapping['user_code'] ]
|
34
|
+
end
|
35
|
+
puts table
|
36
|
+
puts
|
37
|
+
end
|
38
|
+
|
39
|
+
def create
|
40
|
+
tp_id = third_party_id
|
41
|
+
params = {
|
42
|
+
user_mapping: {
|
43
|
+
user_id: prompter.ask("\nabaqis User ID: ", Integer) { |q| q.validate = lambda { | a | is_valid_object?('User', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid user ID" },
|
44
|
+
user_code: prompter.ask("\nThird party User Code: ") { |q| q.validate = /\A.{1,255}\z/; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid third party user ID" }
|
45
|
+
}
|
46
|
+
}
|
47
|
+
result = post("services/third_parties/#{tp_id}/user_mappings", params)
|
48
|
+
puts "\nID of new user mapping: #{result['id']}"
|
49
|
+
puts
|
50
|
+
end
|
51
|
+
|
52
|
+
def update
|
53
|
+
tp_id = third_party_id
|
54
|
+
um_id = user_mapping_id
|
55
|
+
show
|
56
|
+
params = {
|
57
|
+
user_mapping: {
|
58
|
+
user_id: prompter.ask("\nabaqis User ID: ", Integer) { |q| q.default = @um_user_id; q.validate = lambda { | a | is_valid_object?('User', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid user ID" },
|
59
|
+
user_code: prompter.ask("\nThird party User Code: ") { |q| q.default = @um_user_code; q.validate = /\A.{1,255}\z/; q.responses[:not_valid] = "\nNot a valid third party user ID" }
|
60
|
+
}
|
61
|
+
}
|
62
|
+
result = put("services/third_parties/#{tp_id}/user_mappings/#{um_id}", params)
|
63
|
+
puts "\nID of updated user mapping: #{result['id']}"
|
64
|
+
puts
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy
|
68
|
+
tp_id = third_party_id
|
69
|
+
um_id = user_mapping_id
|
70
|
+
show
|
71
|
+
if prompter.agree("\nAre you sure you want to destroy this user mapping? (y/n) ", true)
|
72
|
+
puts
|
73
|
+
result = delete("services/third_parties/#{tp_id}/user_mappings/#{um_id}")
|
74
|
+
puts "\nID of deleted user mapping: #{result['id']}"
|
75
|
+
else
|
76
|
+
puts "\nCancelled deletion"
|
77
|
+
end
|
78
|
+
puts
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/pvdgm-svc-client.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: pvdgm-svc-client 0.
|
5
|
+
# stub: pvdgm-svc-client 0.3.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "pvdgm-svc-client"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.3.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Dave Sieh"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2017-01-23"
|
15
15
|
s.description = "This gem provides command line and other types of tools to support the Service Engine."
|
16
16
|
s.email = "dave.sieh@providigm.com"
|
17
17
|
s.executables = ["service_mgr", "service_mgr_completion", "valid_commands", "valid_resources"]
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"lib/pvdgm-svc-client/prompters/account_mapping_prompter.rb",
|
37
37
|
"lib/pvdgm-svc-client/prompters/configured_account_prompter.rb",
|
38
38
|
"lib/pvdgm-svc-client/prompters/configured_facility_prompter.rb",
|
39
|
+
"lib/pvdgm-svc-client/prompters/configured_user_prompter.rb",
|
39
40
|
"lib/pvdgm-svc-client/prompters/facility_mapping_prompter.rb",
|
40
41
|
"lib/pvdgm-svc-client/prompters/public_key_prompter.rb",
|
41
42
|
"lib/pvdgm-svc-client/prompters/service_definition_prompter.rb",
|
@@ -43,11 +44,13 @@ Gem::Specification.new do |s|
|
|
43
44
|
"lib/pvdgm-svc-client/prompters/sltc_provider_prompter.rb",
|
44
45
|
"lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb",
|
45
46
|
"lib/pvdgm-svc-client/prompters/third_party_prompter.rb",
|
47
|
+
"lib/pvdgm-svc-client/prompters/user_mapping_prompter.rb",
|
46
48
|
"lib/pvdgm-svc-client/resources/account_mapping.rb",
|
47
49
|
"lib/pvdgm-svc-client/resources/assessment_request.rb",
|
48
50
|
"lib/pvdgm-svc-client/resources/available_file.rb",
|
49
51
|
"lib/pvdgm-svc-client/resources/configured_account.rb",
|
50
52
|
"lib/pvdgm-svc-client/resources/configured_facility.rb",
|
53
|
+
"lib/pvdgm-svc-client/resources/configured_user.rb",
|
51
54
|
"lib/pvdgm-svc-client/resources/facility_mapping.rb",
|
52
55
|
"lib/pvdgm-svc-client/resources/mds_pull_account.rb",
|
53
56
|
"lib/pvdgm-svc-client/resources/provider.rb",
|
@@ -56,6 +59,7 @@ Gem::Specification.new do |s|
|
|
56
59
|
"lib/pvdgm-svc-client/resources/service_definition.rb",
|
57
60
|
"lib/pvdgm-svc-client/resources/sltc_registration.rb",
|
58
61
|
"lib/pvdgm-svc-client/resources/third_party.rb",
|
62
|
+
"lib/pvdgm-svc-client/resources/user_mapping.rb",
|
59
63
|
"lib/pvdgm-svc-client/service_mgr_options.rb",
|
60
64
|
"pvdgm-svc-client.gemspec",
|
61
65
|
"spec/base_resource_spec.rb",
|
@@ -64,40 +68,40 @@ Gem::Specification.new do |s|
|
|
64
68
|
]
|
65
69
|
s.homepage = "http://github.com/GitHubAdmin/pvdgm-svc-client"
|
66
70
|
s.licenses = ["MIT"]
|
67
|
-
s.rubygems_version = "2.
|
71
|
+
s.rubygems_version = "2.4.8"
|
68
72
|
s.summary = "Command-line client tools to support the Service Engine"
|
69
73
|
|
70
74
|
if s.respond_to? :specification_version then
|
71
75
|
s.specification_version = 4
|
72
76
|
|
73
77
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
74
|
-
s.add_runtime_dependency(%q<activesupport>, ["
|
75
|
-
s.add_runtime_dependency(%q<rest-client>, ["~> 1.
|
76
|
-
s.add_runtime_dependency(%q<terminal-table>, ["
|
77
|
-
s.add_runtime_dependency(%q<highline>, ["
|
78
|
-
s.add_development_dependency(%q<rspec>, ["
|
79
|
-
s.add_development_dependency(%q<rdoc>, ["
|
80
|
-
s.add_development_dependency(%q<bundler>, ["
|
81
|
-
s.add_development_dependency(%q<jeweler>, ["
|
78
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 4.2.7"])
|
79
|
+
s.add_runtime_dependency(%q<rest-client>, ["~> 1.8.0"])
|
80
|
+
s.add_runtime_dependency(%q<terminal-table>, [">= 0"])
|
81
|
+
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
82
|
+
s.add_development_dependency(%q<rspec>, [">= 3.5"])
|
83
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
84
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
85
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
82
86
|
else
|
83
|
-
s.add_dependency(%q<activesupport>, ["
|
84
|
-
s.add_dependency(%q<rest-client>, ["~> 1.
|
85
|
-
s.add_dependency(%q<terminal-table>, ["
|
86
|
-
s.add_dependency(%q<highline>, ["
|
87
|
-
s.add_dependency(%q<rspec>, ["
|
88
|
-
s.add_dependency(%q<rdoc>, ["
|
89
|
-
s.add_dependency(%q<bundler>, ["
|
90
|
-
s.add_dependency(%q<jeweler>, ["
|
87
|
+
s.add_dependency(%q<activesupport>, [">= 4.2.7"])
|
88
|
+
s.add_dependency(%q<rest-client>, ["~> 1.8.0"])
|
89
|
+
s.add_dependency(%q<terminal-table>, [">= 0"])
|
90
|
+
s.add_dependency(%q<highline>, [">= 0"])
|
91
|
+
s.add_dependency(%q<rspec>, [">= 3.5"])
|
92
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
93
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
94
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
91
95
|
end
|
92
96
|
else
|
93
|
-
s.add_dependency(%q<activesupport>, ["
|
94
|
-
s.add_dependency(%q<rest-client>, ["~> 1.
|
95
|
-
s.add_dependency(%q<terminal-table>, ["
|
96
|
-
s.add_dependency(%q<highline>, ["
|
97
|
-
s.add_dependency(%q<rspec>, ["
|
98
|
-
s.add_dependency(%q<rdoc>, ["
|
99
|
-
s.add_dependency(%q<bundler>, ["
|
100
|
-
s.add_dependency(%q<jeweler>, ["
|
97
|
+
s.add_dependency(%q<activesupport>, [">= 4.2.7"])
|
98
|
+
s.add_dependency(%q<rest-client>, ["~> 1.8.0"])
|
99
|
+
s.add_dependency(%q<terminal-table>, [">= 0"])
|
100
|
+
s.add_dependency(%q<highline>, [">= 0"])
|
101
|
+
s.add_dependency(%q<rspec>, [">= 3.5"])
|
102
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
103
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
104
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
101
105
|
end
|
102
106
|
end
|
103
107
|
|
metadata
CHANGED
@@ -1,127 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pvdgm-svc-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Sieh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.2.7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.2.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rest-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.8.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.8.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: terminal-table
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: highline
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.5'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rdoc
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: jeweler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '0'
|
125
125
|
description: This gem provides command line and other types of tools to support the
|
126
126
|
Service Engine.
|
127
127
|
email: dave.sieh@providigm.com
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/pvdgm-svc-client/prompters/account_mapping_prompter.rb
|
152
152
|
- lib/pvdgm-svc-client/prompters/configured_account_prompter.rb
|
153
153
|
- lib/pvdgm-svc-client/prompters/configured_facility_prompter.rb
|
154
|
+
- lib/pvdgm-svc-client/prompters/configured_user_prompter.rb
|
154
155
|
- lib/pvdgm-svc-client/prompters/facility_mapping_prompter.rb
|
155
156
|
- lib/pvdgm-svc-client/prompters/public_key_prompter.rb
|
156
157
|
- lib/pvdgm-svc-client/prompters/service_definition_prompter.rb
|
@@ -158,11 +159,13 @@ files:
|
|
158
159
|
- lib/pvdgm-svc-client/prompters/sltc_provider_prompter.rb
|
159
160
|
- lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb
|
160
161
|
- lib/pvdgm-svc-client/prompters/third_party_prompter.rb
|
162
|
+
- lib/pvdgm-svc-client/prompters/user_mapping_prompter.rb
|
161
163
|
- lib/pvdgm-svc-client/resources/account_mapping.rb
|
162
164
|
- lib/pvdgm-svc-client/resources/assessment_request.rb
|
163
165
|
- lib/pvdgm-svc-client/resources/available_file.rb
|
164
166
|
- lib/pvdgm-svc-client/resources/configured_account.rb
|
165
167
|
- lib/pvdgm-svc-client/resources/configured_facility.rb
|
168
|
+
- lib/pvdgm-svc-client/resources/configured_user.rb
|
166
169
|
- lib/pvdgm-svc-client/resources/facility_mapping.rb
|
167
170
|
- lib/pvdgm-svc-client/resources/mds_pull_account.rb
|
168
171
|
- lib/pvdgm-svc-client/resources/provider.rb
|
@@ -171,6 +174,7 @@ files:
|
|
171
174
|
- lib/pvdgm-svc-client/resources/service_definition.rb
|
172
175
|
- lib/pvdgm-svc-client/resources/sltc_registration.rb
|
173
176
|
- lib/pvdgm-svc-client/resources/third_party.rb
|
177
|
+
- lib/pvdgm-svc-client/resources/user_mapping.rb
|
174
178
|
- lib/pvdgm-svc-client/service_mgr_options.rb
|
175
179
|
- pvdgm-svc-client.gemspec
|
176
180
|
- spec/base_resource_spec.rb
|
@@ -196,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
200
|
version: '0'
|
197
201
|
requirements: []
|
198
202
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.4.8
|
200
204
|
signing_key:
|
201
205
|
specification_version: 4
|
202
206
|
summary: Command-line client tools to support the Service Engine
|