pvdgm-svc-client 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +21 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/bin/service_mgr +8 -0
- data/bin/service_mgr_completion +86 -0
- data/bin/valid_commands +16 -0
- data/bin/valid_resources +11 -0
- data/lib/pvdgm-svc-client/base_resource.rb +118 -0
- data/lib/pvdgm-svc-client/prompters/account_mapping_prompter.rb +26 -0
- data/lib/pvdgm-svc-client/prompters/configured_account_prompter.rb +30 -0
- data/lib/pvdgm-svc-client/prompters/configured_facility_prompter.rb +30 -0
- data/lib/pvdgm-svc-client/prompters/facility_mapping_prompter.rb +26 -0
- data/lib/pvdgm-svc-client/prompters/public_key_prompter.rb +27 -0
- data/lib/pvdgm-svc-client/prompters/service_definition_prompter.rb +30 -0
- data/lib/pvdgm-svc-client/prompters/service_prompter.rb +26 -0
- data/lib/pvdgm-svc-client/prompters/sltc_provider_prompter.rb +24 -0
- data/lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb +26 -0
- data/lib/pvdgm-svc-client/prompters/third_party_prompter.rb +26 -0
- data/lib/pvdgm-svc-client/resources/account_mapping.rb +83 -0
- data/lib/pvdgm-svc-client/resources/assessment_request.rb +61 -0
- data/lib/pvdgm-svc-client/resources/available_file.rb +48 -0
- data/lib/pvdgm-svc-client/resources/configured_account.rb +118 -0
- data/lib/pvdgm-svc-client/resources/configured_facility.rb +118 -0
- data/lib/pvdgm-svc-client/resources/facility_mapping.rb +90 -0
- data/lib/pvdgm-svc-client/resources/mds_pull_account.rb +55 -0
- data/lib/pvdgm-svc-client/resources/provider.rb +28 -0
- data/lib/pvdgm-svc-client/resources/public_key.rb +119 -0
- data/lib/pvdgm-svc-client/resources/service.rb +67 -0
- data/lib/pvdgm-svc-client/resources/service_definition.rb +147 -0
- data/lib/pvdgm-svc-client/resources/sltc_registration.rb +51 -0
- data/lib/pvdgm-svc-client/resources/third_party.rb +61 -0
- data/lib/pvdgm-svc-client/service_mgr_options.rb +157 -0
- data/lib/pvdgm-svc-client.rb +16 -0
- data/spec/base_resource_spec.rb +208 -0
- data/spec/service_mgr_options_spec.rb +266 -0
- data/spec/spec_helper.rb +22 -0
- metadata +202 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe659993682a43aa61d59412455bf087b35431c0
|
4
|
+
data.tar.gz: 1e77ae45be9368ba0f85a598c9b5183d42e004f7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 39082c083e1128958bf40ab6739f7e5c6a1cb5051070f158e3b5b084d53342c8b5bef62c9ecc38411268f73bc162ce4336a5d8e16a2cbc0aa94248e8d669ad34
|
7
|
+
data.tar.gz: 00232acf2de7e5c305ee110d1878bcc1353d927a470650391c18c47e4671cb738cc72512b97e5ced311df09067c09da0991bea7b0349a3f679ebe92f4227fc0a
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "activesupport", "= 3.2.14"
|
6
|
+
gem "rest-client"
|
7
|
+
gem 'terminal-table'
|
8
|
+
gem 'highline'
|
9
|
+
|
10
|
+
# Add dependencies to develop your gem here.
|
11
|
+
# Include everything needed to run rake, tests, features, etc.
|
12
|
+
group :development do
|
13
|
+
gem "rspec"
|
14
|
+
gem "rdoc", "~> 3.12"
|
15
|
+
gem "bundler", "~> 1.0"
|
16
|
+
gem "jeweler", "~> 1.8.7"
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.14)
|
5
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
addressable (2.3.5)
|
8
|
+
builder (3.2.2)
|
9
|
+
diff-lcs (1.2.4)
|
10
|
+
faraday (0.8.8)
|
11
|
+
multipart-post (~> 1.2.0)
|
12
|
+
git (1.2.6)
|
13
|
+
github_api (0.10.1)
|
14
|
+
addressable
|
15
|
+
faraday (~> 0.8.1)
|
16
|
+
hashie (>= 1.2)
|
17
|
+
multi_json (~> 1.4)
|
18
|
+
nokogiri (~> 1.5.2)
|
19
|
+
oauth2
|
20
|
+
hashie (2.0.5)
|
21
|
+
highline (1.6.19)
|
22
|
+
httpauth (0.2.0)
|
23
|
+
i18n (0.6.5)
|
24
|
+
jeweler (1.8.7)
|
25
|
+
builder
|
26
|
+
bundler (~> 1.0)
|
27
|
+
git (>= 1.2.5)
|
28
|
+
github_api (= 0.10.1)
|
29
|
+
highline (>= 1.6.15)
|
30
|
+
nokogiri (= 1.5.10)
|
31
|
+
rake
|
32
|
+
rdoc
|
33
|
+
json (1.8.0)
|
34
|
+
jwt (0.1.8)
|
35
|
+
multi_json (>= 1.5)
|
36
|
+
mime-types (1.25)
|
37
|
+
multi_json (1.8.0)
|
38
|
+
multi_xml (0.5.5)
|
39
|
+
multipart-post (1.2.0)
|
40
|
+
nokogiri (1.5.10)
|
41
|
+
oauth2 (0.9.2)
|
42
|
+
faraday (~> 0.8)
|
43
|
+
httpauth (~> 0.2)
|
44
|
+
jwt (~> 0.1.4)
|
45
|
+
multi_json (~> 1.0)
|
46
|
+
multi_xml (~> 0.5)
|
47
|
+
rack (~> 1.2)
|
48
|
+
rack (1.5.2)
|
49
|
+
rake (10.1.0)
|
50
|
+
rdoc (3.12.2)
|
51
|
+
json (~> 1.4)
|
52
|
+
rest-client (1.6.7)
|
53
|
+
mime-types (>= 1.16)
|
54
|
+
rspec (2.14.1)
|
55
|
+
rspec-core (~> 2.14.0)
|
56
|
+
rspec-expectations (~> 2.14.0)
|
57
|
+
rspec-mocks (~> 2.14.0)
|
58
|
+
rspec-core (2.14.5)
|
59
|
+
rspec-expectations (2.14.3)
|
60
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
61
|
+
rspec-mocks (2.14.3)
|
62
|
+
terminal-table (1.4.5)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
activesupport (= 3.2.14)
|
69
|
+
bundler (~> 1.0)
|
70
|
+
highline
|
71
|
+
jeweler (~> 1.8.7)
|
72
|
+
rdoc (~> 3.12)
|
73
|
+
rest-client
|
74
|
+
rspec
|
75
|
+
terminal-table
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Dave
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
= pvdgm-svc-client
|
2
|
+
|
3
|
+
This gem provides a command-line client to provide management features for the abaqis services subsystem.
|
4
|
+
|
5
|
+
More documentation to come...
|
6
|
+
|
7
|
+
== Contributing to pvdgm-svc-client
|
8
|
+
|
9
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
10
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
11
|
+
* Fork the project.
|
12
|
+
* Start a feature/bugfix branch.
|
13
|
+
* Commit and push until you are happy with your contribution.
|
14
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
15
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
16
|
+
|
17
|
+
== Copyright
|
18
|
+
|
19
|
+
Copyright (c) 2013 Providigm. See LICENSE.txt for
|
20
|
+
further details.
|
21
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler'
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
require 'rake'
|
14
|
+
|
15
|
+
require 'jeweler'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
18
|
+
gem.name = "pvdgm-svc-client"
|
19
|
+
gem.homepage = "http://github.com/GitHubAdmin/pvdgm-svc-client"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{Command-line client tools to support the Service Engine}
|
22
|
+
gem.description = %Q{This gem provides command line and other types of tools to support the Service Engine.}
|
23
|
+
gem.email = "dave.sieh@providigm.com"
|
24
|
+
gem.authors = ["Dave Sieh"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "pvdgm-svc-client #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.6
|
data/bin/service_mgr
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# This script is to be sourced into your bash shell to provide command-line TAB completion
|
4
|
+
# of options, resources and commands for the service_mgr script.
|
5
|
+
#
|
6
|
+
# To source this script, you can:
|
7
|
+
#
|
8
|
+
# 1. source service_mgr_completion
|
9
|
+
# 2. . service_mgr_completion
|
10
|
+
#
|
11
|
+
# If you want this to be available at all times, you can add one of the source commands
|
12
|
+
# above into your .bashrc.
|
13
|
+
#
|
14
|
+
|
15
|
+
#
|
16
|
+
# See if the any of the words currently on the command line are one of the valid resources.
|
17
|
+
#
|
18
|
+
# The first argument is a list of words currently on the
|
19
|
+
# command line, the second+ arguments are the valid resources.
|
20
|
+
#
|
21
|
+
# If a match is found, the matching resource is echoed to stdout and the result code is set
|
22
|
+
# to 0.
|
23
|
+
#
|
24
|
+
svc_mgr_find_match () {
|
25
|
+
local resource
|
26
|
+
local word
|
27
|
+
for word in $1
|
28
|
+
do
|
29
|
+
for resource in ${@:2}
|
30
|
+
do
|
31
|
+
[[ "$word" == "${resource}" ]] && echo $word && return 0
|
32
|
+
done
|
33
|
+
done
|
34
|
+
return 1
|
35
|
+
}
|
36
|
+
|
37
|
+
#
|
38
|
+
# This is the function return to perform completion analysis (see the 'complete' statement at
|
39
|
+
# the end of this script.
|
40
|
+
#
|
41
|
+
_ServiceMgrComplete() {
|
42
|
+
local cur
|
43
|
+
|
44
|
+
COMPREPLY=() # Array storing the possible completions
|
45
|
+
cur=${COMP_WORDS[COMP_CWORD]} # Store the current word on the command line
|
46
|
+
|
47
|
+
case "$cur" in
|
48
|
+
-*)
|
49
|
+
# The current word on the command line starts with dash. Check against all
|
50
|
+
# the valid command line options.
|
51
|
+
COMPREPLY=( $( compgen -W '-h --help -s --server -n --no-ssl -l --list -t --token -p --third-party-id --d --service-definition-id -a --configured-account-id' -- $cur ) )
|
52
|
+
;;
|
53
|
+
|
54
|
+
*)
|
55
|
+
# The current word on the command line is anything but a '-'. We need
|
56
|
+
# to determine the appropriate completions based on what has already
|
57
|
+
# been entered
|
58
|
+
|
59
|
+
resources=$(valid_resources) # Get the list of valid resources
|
60
|
+
current_word_list=${COMP_WORDS[@]} # Create a list of the current words on the
|
61
|
+
# command line
|
62
|
+
|
63
|
+
# Determine if one of the words currently on the command line is one
|
64
|
+
# of the valid resources
|
65
|
+
matched_name=$(svc_mgr_find_match "$current_word_list" ${resources})
|
66
|
+
resource_on_command_line=$?
|
67
|
+
if [[ $resource_on_command_line == 0 ]]
|
68
|
+
then
|
69
|
+
# One of the words on the command line was one of our resources. Now
|
70
|
+
# get the list of valid commands for that resource and complete against them...
|
71
|
+
commands=$(valid_commands $matched_name)
|
72
|
+
COMPREPLY=( $( compgen -W '$commands' -- $cur ) )
|
73
|
+
else
|
74
|
+
# There was not a resource name on the command line. Complete the current
|
75
|
+
# word against the list of valid resources
|
76
|
+
COMPREPLY=( $( compgen -W '$resources' -- $cur ) )
|
77
|
+
fi
|
78
|
+
;;
|
79
|
+
esac
|
80
|
+
|
81
|
+
return 0
|
82
|
+
}
|
83
|
+
|
84
|
+
# Register the _ServiceMgrComplete function as a completion function for
|
85
|
+
# all executables named 'service_mgr'.
|
86
|
+
complete -F _ServiceMgrComplete -o filenames service_mgr
|
data/bin/valid_commands
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
require 'pvdgm-svc-client'
|
5
|
+
|
6
|
+
# Require all the resources
|
7
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'resources/*.rb')).each do | resource_path |
|
8
|
+
require File.join('resources', File.basename(resource_path))
|
9
|
+
end
|
10
|
+
|
11
|
+
RESOURCE = ARGV.first
|
12
|
+
raise "Must specify a resource to determine the commands for" if RESOURCE.nil?
|
13
|
+
|
14
|
+
puts eval("Resources::#{ActiveSupport::Inflector.camelize(RESOURCE)}").instance_methods(false).join(" ")
|
15
|
+
|
16
|
+
# puts Resources.constants.join(" ")
|
data/bin/valid_resources
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
require 'pvdgm-svc-client'
|
5
|
+
|
6
|
+
# Require all the resources
|
7
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'resources/*.rb')).each do | resource_path |
|
8
|
+
require File.join('resources', File.basename(resource_path))
|
9
|
+
end
|
10
|
+
|
11
|
+
puts Resources.constants.map { |r| ActiveSupport::Inflector.underscore(r.to_s) }.join(" ")
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'json'
|
4
|
+
require 'highline'
|
5
|
+
require 'terminal-table'
|
6
|
+
|
7
|
+
class BaseResource
|
8
|
+
|
9
|
+
attr_reader :options, :prompter
|
10
|
+
|
11
|
+
def initialize(opts)
|
12
|
+
@options = opts
|
13
|
+
@prompter = HighLine.new
|
14
|
+
@prompter.wrap_at = 120
|
15
|
+
@prompter.page_at = 22
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def invoke_rest(is_json=true)
|
22
|
+
begin
|
23
|
+
response = yield
|
24
|
+
begin
|
25
|
+
is_json ? JSON.parse(response) : response
|
26
|
+
rescue Exception => ex
|
27
|
+
puts "Error parsing response: #{ex.message[0..100]}"
|
28
|
+
if options[:trace]
|
29
|
+
puts "Full Error message: #{ex.message}"
|
30
|
+
puts "\t#{ex.backtrace.join("\n\t")}"
|
31
|
+
end
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
rescue RestClient::Exception => ex
|
35
|
+
puts "Response: #{ex.response.code} - #{ex.response.description}"
|
36
|
+
if [ 403, 404 ].include?(ex.response.code)
|
37
|
+
if is_json
|
38
|
+
begin
|
39
|
+
hash = JSON.parse(ex.response.http_body)
|
40
|
+
if hash.has_key?('error')
|
41
|
+
puts(hash['error'])
|
42
|
+
elsif hash.has_key?('validation_error')
|
43
|
+
puts "Validation errors:"
|
44
|
+
hash['validation_error'].each_pair do | key, value |
|
45
|
+
puts " #{key}"
|
46
|
+
puts " #{value.join("\n ")}"
|
47
|
+
end
|
48
|
+
else
|
49
|
+
puts(hash.inspect)
|
50
|
+
end
|
51
|
+
rescue Exception => json_ex
|
52
|
+
puts "Unable to parse body for error: #{ex.response.http_body[0..50]}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
exit 1
|
57
|
+
rescue SystemExit
|
58
|
+
raise
|
59
|
+
rescue Exception => ex
|
60
|
+
# General unknown exception
|
61
|
+
puts "Error invoking RestClient: #{ex.message}"
|
62
|
+
puts "\t#{ex.backtrace.join("\n\t")}" if options[:trace]
|
63
|
+
exit 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def get(uri, is_json=true)
|
68
|
+
invoke_rest(is_json) do
|
69
|
+
RestClient.get(build_url(uri),
|
70
|
+
authentication_headers)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def delete(uri, is_json=true)
|
75
|
+
invoke_rest(is_json) do
|
76
|
+
RestClient.delete(build_url(uri),
|
77
|
+
authentication_headers)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def post(uri, parameters, is_json=true)
|
82
|
+
invoke_rest(is_json) do
|
83
|
+
RestClient.post(build_url(uri),
|
84
|
+
parameters,
|
85
|
+
authentication_headers)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def put(uri, parameters, is_json=true)
|
90
|
+
invoke_rest(is_json) do
|
91
|
+
RestClient.put(build_url(uri),
|
92
|
+
parameters,
|
93
|
+
authentication_headers)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def is_valid_object?(object_type, object_id)
|
98
|
+
result = get("services/validation?object_type=#{object_type}&object_id=#{object_id}")
|
99
|
+
result['exists']
|
100
|
+
end
|
101
|
+
|
102
|
+
def is_valid_date?(date_string)
|
103
|
+
DateTime.parse date_string
|
104
|
+
true
|
105
|
+
rescue
|
106
|
+
false
|
107
|
+
end
|
108
|
+
|
109
|
+
def build_url(uri)
|
110
|
+
"#{options[:use_ssl] ? 'https' : 'http'}://#{options[:server]}/#{uri}"
|
111
|
+
end
|
112
|
+
|
113
|
+
def authentication_headers
|
114
|
+
{
|
115
|
+
'Authorization' => "Token token=\"#{options[:api_token]}\""
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module AccountMappingPrompter
|
2
|
+
|
3
|
+
def account_mapping_id(allow_none=false)
|
4
|
+
return options[:account_mapping_id] if options[:account_mapping_id]
|
5
|
+
return options[:account_mapping_id] = ENV['ACCOUNT_MAPPING_ID'] if ENV['ACCOUNT_MAPPING_ID']
|
6
|
+
return options[:account_mapping_id] = prompt_for_account_mapping_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_account_mapping_id(allow_none)
|
12
|
+
result = get("services/third_parties/#{third_party_id}/account_mappings")
|
13
|
+
|
14
|
+
(puts "No third-parties are defined. Cannot continue"; exit 1) if result.empty?
|
15
|
+
|
16
|
+
# Build a menu of the account mappings
|
17
|
+
puts
|
18
|
+
return prompter.choose do | menu |
|
19
|
+
menu.prompt = "Select the Account Mapping: "
|
20
|
+
menu.choice("No Selection") { -1 } if allow_none
|
21
|
+
result.each do | account_mapping |
|
22
|
+
menu.choice("#{account_mapping['account_name']} (#{account_mapping['account_id']}) - #{account_mapping['account_code']}") { account_mapping['id'] }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ConfiguredAccountPrompter
|
2
|
+
|
3
|
+
def configured_account_id(allow_none=false)
|
4
|
+
return options[:configured_account_id] if options[:configured_account_id]
|
5
|
+
return options[:configured_account_id] = ENV['CONFIGURED_ACCOUNT_ID'] if ENV['CONFIGURED_ACCOUNT_ID']
|
6
|
+
return options[:configured_account_id] = prompt_for_configured_account_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_configured_account_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_accounts")
|
14
|
+
elsif respond_to?(:service_id)
|
15
|
+
result = get("services/services/#{service_id}/service_definitions/#{service_definition_id}/configured_accounts")
|
16
|
+
end
|
17
|
+
|
18
|
+
(puts "No accounts 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 Account: "
|
24
|
+
menu.choice("No Selection") { -1 } if allow_none
|
25
|
+
result.each do | configured_account |
|
26
|
+
menu.choice("#{configured_account['account_name']} (#{configured_account['account_id']}) - #{configured_account['enabled']}") { configured_account['id'] }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ConfiguredFacilityPrompter
|
2
|
+
|
3
|
+
def configured_facility_id(allow_none=false)
|
4
|
+
return options[:configured_facility_id] if options[:configured_facility_id]
|
5
|
+
return options[:configured_facility_id] = ENV['CONFIGURED_FACILITY_ID'] if ENV['CONFIGURED_FACILITY_ID']
|
6
|
+
return options[:configured_facility_id] = prompt_for_configured_facility_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_configured_facility_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_facilities")
|
14
|
+
elsif respond_to?(:service_id)
|
15
|
+
result = get("services/services/#{service_id}/service_definitions/#{service_definition_id}/configured_facilities")
|
16
|
+
end
|
17
|
+
|
18
|
+
(puts "No facilities 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 Facility: "
|
24
|
+
menu.choice("No Selection") { -1 } if allow_none
|
25
|
+
result.each do | configured_facility |
|
26
|
+
menu.choice("#{configured_facility['facility_name']} (#{configured_facility['facility_id']}) - #{configured_facility['enabled']}") { configured_facility['id'] }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module FacilityMappingPrompter
|
2
|
+
|
3
|
+
def facility_mapping_id(allow_none=false)
|
4
|
+
return options[:facility_mapping_id] if options[:facility_mapping_id]
|
5
|
+
return options[:facility_mapping_id] = ENV['FACILITY_MAPPING_ID'] if ENV['FACILITY_MAPPING_ID']
|
6
|
+
return options[:facility_mapping_id] = prompt_for_facility_mapping_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_facility_mapping_id(allow_none)
|
12
|
+
result = get("services/third_parties/#{third_party_id}/facility_mappings")
|
13
|
+
|
14
|
+
(puts "No facility mappings have been defined. Cannot continue"; exit 1) if result.empty?
|
15
|
+
|
16
|
+
# Build a menu of the facility mappings
|
17
|
+
puts
|
18
|
+
return prompter.choose do | menu |
|
19
|
+
menu.prompt = "Select the Facility Mapping: "
|
20
|
+
menu.choice("No Selection") { -1 } if allow_none
|
21
|
+
result.each do | facility_mapping |
|
22
|
+
menu.choice("#{facility_mapping['facility_name']} (#{facility_mapping['facility_id']}) - #{facility_mapping['facility_code']}") { facility_mapping['id'] }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module PublicKeyPrompter
|
2
|
+
|
3
|
+
def public_key_id(allow_none=false)
|
4
|
+
return options[:public_key_id] if options[:public_key_id]
|
5
|
+
return options[:public_key_id] = ENV['PUBLIC_KEY_ID'] if ENV['PUBLIC_KEY_ID']
|
6
|
+
return options[:public_key_id] = prompt_for_public_key_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_public_key_id(allow_none)
|
12
|
+
result = get("services/public_keys")
|
13
|
+
|
14
|
+
(puts "No public keys have been created. Cannot continue"; exit 1) if result.empty?
|
15
|
+
|
16
|
+
# Build a menu of the public keys
|
17
|
+
puts
|
18
|
+
return prompter.choose do | menu |
|
19
|
+
menu.prompt = "Select the Public Key: "
|
20
|
+
menu.choice("No Selection") { -1 } if allow_none
|
21
|
+
result.each do | public_key |
|
22
|
+
menu.choice(public_key['name']) { public_key['id'] }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ServiceDefinitionPrompter
|
2
|
+
|
3
|
+
def service_definition_id(allow_none=false)
|
4
|
+
return options[:service_definition_id] if options[:service_definition_id]
|
5
|
+
return options[:service_definition_id] = ENV['SERVICE_DEFINITION_ID'] if ENV['SERVICE_DEFINITION_ID']
|
6
|
+
return options[:service_definition_id] = prompt_for_service_definition_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_service_definition_id(allow_none)
|
12
|
+
if respond_to?(:third_party_id)
|
13
|
+
result = get("services/third_parties/#{third_party_id}/service_definitions")
|
14
|
+
elsif respond_to?(:service_id)
|
15
|
+
result = get("services/services/#{service_id}/service_definitions")
|
16
|
+
end
|
17
|
+
|
18
|
+
(puts "No service definitions have been defined. 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 Service Definition: "
|
24
|
+
menu.choice("No Selection") { -1 } if allow_none
|
25
|
+
result.each do | service_definition |
|
26
|
+
menu.choice("#{service_definition['third_party_name']} / #{service_definition['service_name']} - #{service_definition['hostname']}") { service_definition['id'] }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ServicePrompter
|
2
|
+
|
3
|
+
def service_id(allow_none=false)
|
4
|
+
return options[:service_id] if options[:service_id]
|
5
|
+
return options[:service_id] = ENV['SERVICE_ID'] if ENV['SERVICE_ID']
|
6
|
+
return options[:service_id] = prompt_for_service_id(allow_none)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def prompt_for_service_id(allow_none)
|
12
|
+
result = get("services/services")
|
13
|
+
|
14
|
+
(puts "No services have been defined. Cannot continue"; exit 1) if result.empty?
|
15
|
+
|
16
|
+
# Build a menu of the services
|
17
|
+
puts
|
18
|
+
return prompter.choose do | menu |
|
19
|
+
menu.prompt = "Select the Service: "
|
20
|
+
menu.choice("No Selection") { -1 } if allow_none
|
21
|
+
result.each do | service |
|
22
|
+
menu.choice(service['name']) { service['id'] }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SltcProviderPrompter
|
2
|
+
|
3
|
+
def sltc_provider_id(allow_none=false)
|
4
|
+
return options[:slt_provider_id] = prompt_for_sltc_provider_id(allow_none)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def prompt_for_sltc_provider_id(allow_none)
|
10
|
+
result = get("services/sltc_providers?configured_account_id=#{configured_account_id}")
|
11
|
+
|
12
|
+
(puts "No providers are configured. Cannot continue"; exit 1) if result.empty?
|
13
|
+
|
14
|
+
# Build a menu of the providers
|
15
|
+
puts
|
16
|
+
return prompter.choose do | menu |
|
17
|
+
menu.prompt = "Select the Provider: "
|
18
|
+
menu.choice("No Selection") { -1 } if allow_none
|
19
|
+
result.each do | provider |
|
20
|
+
menu.choice(provider['name']) { provider['id'] }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|