EndlessWaffleCLI 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/enum +1 -1
- data/exe/ewcommand +125 -0
- data/exe/ewrole +130 -0
- data/exe/ewsecuritygroups +120 -0
- data/exe/ewssl +18 -2
- data/lib/EndlessWaffleCLI.rb +113 -0
- data/lib/EndlessWaffleCLI/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50395eba362047b268d82769ca10eb86abbbc30c
|
4
|
+
data.tar.gz: f0d5e95918e01a2519a766ffa38eb67146d1d390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cfc9e8e1edb918bcac89c746a221e90fa8aa4f034176cdb7d9b678f9852ac87d3a42203c3aa937eae8214cd49c441cd5a6b05ceb01c47c1ad1a6f51491f92a3
|
7
|
+
data.tar.gz: cbde355ead948b9267ce4fbb4f22fdc2c7d43ac2c115728fb236dbffa366376e4554d87b17c83b0ef632e167f79c24b4ffae16289fc5a66e3610353d989a4e4f
|
data/exe/enum
CHANGED
@@ -101,7 +101,7 @@ def showTable(result)
|
|
101
101
|
{:key=>:instanceId, :size=>13, :title=>"Instance Id"},
|
102
102
|
{:key=>:name, :size=>13, :title=>"Name"},
|
103
103
|
{:key=>:role, :size=>8, :title=>"Role"},
|
104
|
-
{:key=>:environment, :size=>
|
104
|
+
{:key=>:environment, :size=>14, :title=>"Env"},
|
105
105
|
{:key=>:instanceType, :size=>10, :title=>"Type"},
|
106
106
|
{:key=>:availabilityZone, :size=>12, :title=>"Zone"},
|
107
107
|
{:key=>:instanceState, :size=>12, :title=>"State"},
|
data/exe/ewcommand
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "EndlessWaffleCLI"
|
5
|
+
require 'json'
|
6
|
+
require 'getoptlong'
|
7
|
+
require 'console_table'
|
8
|
+
require 'colorize'
|
9
|
+
|
10
|
+
if ENV['EndlessWaffleURL'].nil?
|
11
|
+
puts "EndlessWaffleCLI requires the 'EndlessWaffleURL' environment variable to be set."
|
12
|
+
exit 1
|
13
|
+
else
|
14
|
+
EndlessWaffleCLI.setServer ENV['EndlessWaffleURL']
|
15
|
+
end
|
16
|
+
|
17
|
+
if ENV['EndlessWaffleToken'].nil?
|
18
|
+
puts "EndlessWaffleCLI requires the 'EndlessWaffleToken' environment variable to be set."
|
19
|
+
exit 1
|
20
|
+
else
|
21
|
+
EndlessWaffleCLI.setToken ENV['EndlessWaffleToken']
|
22
|
+
end
|
23
|
+
|
24
|
+
def showHelp
|
25
|
+
puts
|
26
|
+
puts "Endless Waffle Commands"
|
27
|
+
puts "Usage example: #{$0} -c MyNewCommand"
|
28
|
+
puts
|
29
|
+
puts "Options:"
|
30
|
+
puts "-c or --create".ljust(30) +"-> Create new command"
|
31
|
+
puts "-l or --list".ljust(30) +"-> List commands"
|
32
|
+
puts "-d or --delete".ljust(30) +"-> Delete command"
|
33
|
+
puts "-e or --edit ".ljust(30) +"-> Edit command"
|
34
|
+
puts "-s or --show ".ljust(30) +"-> Show command"
|
35
|
+
puts "-h or --help".ljust(30) +"-> Show this help message."
|
36
|
+
puts
|
37
|
+
end
|
38
|
+
|
39
|
+
def showCommand(name)
|
40
|
+
result = EndlessWaffleCLI.showCommand name
|
41
|
+
puts result["command"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def createCommand(name)
|
45
|
+
puts JSON.pretty_generate(EndlessWaffleCLI.createCommand name)
|
46
|
+
end
|
47
|
+
|
48
|
+
def deleteCommand(name)
|
49
|
+
print "Are you Sure you want to delete Command #{name} (y/n): ".colorize(:red)
|
50
|
+
response = STDIN.gets.chomp
|
51
|
+
if response == 'y'
|
52
|
+
puts EndlessWaffleCLI.deleteCommand(name)
|
53
|
+
else
|
54
|
+
puts "Stopping request."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def editCommand(name)
|
59
|
+
orignial = EndlessWaffleCLI.showCommand name
|
60
|
+
tmp_file="/tmp/ewCommand-edit-#{name}-#{$$}.sh"
|
61
|
+
File.open(tmp_file,"w") do |f|
|
62
|
+
f.write(orignial["command"])
|
63
|
+
end
|
64
|
+
if ENV['EDITOR'].nil?
|
65
|
+
puts "I can not continue, please set your EDITOR enviroment variable"
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
system "$EDITOR #{tmp_file}"
|
69
|
+
edited = File.read(tmp_file)
|
70
|
+
FileUtils.rm tmp_file
|
71
|
+
result = {:name => name, :command => edited}
|
72
|
+
puts EndlessWaffleCLI.updateCommand result
|
73
|
+
end
|
74
|
+
|
75
|
+
def listCommand(name)
|
76
|
+
query = {"query"=>{"name"=>name}}
|
77
|
+
result = EndlessWaffleCLI.listCommand query
|
78
|
+
table_config = [
|
79
|
+
{:key=>:name, :size=>23, :title=>"Name"},
|
80
|
+
{:key=>:created_at, :size=>30, :title=>"Created"},
|
81
|
+
{:key=>:updated_at, :size=>30, :title=>"Updated"}
|
82
|
+
]
|
83
|
+
ConsoleTable.define(table_config) do |table|
|
84
|
+
result.each do |r|
|
85
|
+
table << [
|
86
|
+
r["name"],
|
87
|
+
r["created_at"],
|
88
|
+
r["updated_at"]
|
89
|
+
]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
parser = GetoptLong.new
|
95
|
+
parser.set_options(["-c", "--create", GetoptLong::NO_ARGUMENT],
|
96
|
+
["-l", "--list", GetoptLong::NO_ARGUMENT],
|
97
|
+
["-d", "--delete", GetoptLong::NO_ARGUMENT],
|
98
|
+
["-e", "--edit", GetoptLong::NO_ARGUMENT],
|
99
|
+
["-s", "--show", GetoptLong::NO_ARGUMENT],
|
100
|
+
["-h", "--help", GetoptLong::NO_ARGUMENT]
|
101
|
+
)
|
102
|
+
|
103
|
+
begin
|
104
|
+
begin
|
105
|
+
opt,arg = parser.get_option
|
106
|
+
break if not opt
|
107
|
+
case opt
|
108
|
+
when "-h" || "--help"
|
109
|
+
showHelp; exit
|
110
|
+
when "-c" || "--create"
|
111
|
+
createCommand ARGV[0]; exit
|
112
|
+
when "-l" || "--list"
|
113
|
+
listCommand ARGV[0]; exit
|
114
|
+
when "-d" || "--delete"
|
115
|
+
deleteCommand ARGV[0]; exit
|
116
|
+
when "-e" || "--edit"
|
117
|
+
editCommand ARGV[0]; exit
|
118
|
+
when "-s" || "--show"
|
119
|
+
showCommand ARGV[0]; exit
|
120
|
+
end
|
121
|
+
rescue => err
|
122
|
+
puts "#{err.class()}: #{err.message}"
|
123
|
+
exit 1
|
124
|
+
end
|
125
|
+
end while 1
|
data/exe/ewrole
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "EndlessWaffleCLI"
|
5
|
+
require 'json'
|
6
|
+
require 'getoptlong'
|
7
|
+
require 'console_table'
|
8
|
+
require 'colorize'
|
9
|
+
|
10
|
+
if ENV['EndlessWaffleURL'].nil?
|
11
|
+
puts "EndlessWaffleCLI requires the 'EndlessWaffleURL' environment variable to be set."
|
12
|
+
exit 1
|
13
|
+
else
|
14
|
+
EndlessWaffleCLI.setServer ENV['EndlessWaffleURL']
|
15
|
+
end
|
16
|
+
|
17
|
+
if ENV['EndlessWaffleToken'].nil?
|
18
|
+
puts "EndlessWaffleCLI requires the 'EndlessWaffleToken' environment variable to be set."
|
19
|
+
exit 1
|
20
|
+
else
|
21
|
+
EndlessWaffleCLI.setToken ENV['EndlessWaffleToken']
|
22
|
+
end
|
23
|
+
|
24
|
+
def showHelp
|
25
|
+
puts
|
26
|
+
puts "Endless Waffle Roles"
|
27
|
+
puts "Usage example: #{$0} -c myNewRole"
|
28
|
+
puts
|
29
|
+
puts "Options:"
|
30
|
+
puts "-c or --create".ljust(30) +"-> Create new role"
|
31
|
+
puts "-l or --list".ljust(30) +"-> List Roles"
|
32
|
+
puts "-d or --delete".ljust(30) +"-> Delete Role"
|
33
|
+
puts "-e or --edit ".ljust(30) +"-> Edit role"
|
34
|
+
puts "-s or --show ".ljust(30) +"-> Show Role"
|
35
|
+
puts "-h or --help".ljust(30) +"-> Show this help message."
|
36
|
+
puts
|
37
|
+
end
|
38
|
+
|
39
|
+
def showRole(name)
|
40
|
+
puts JSON.pretty_generate(EndlessWaffleCLI.showRole name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def createRole(name)
|
44
|
+
puts JSON.pretty_generate(EndlessWaffleCLI.createRole name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def deleteRole(name)
|
48
|
+
print "Are you Sure you want to delete role #{name} (y/n): ".colorize(:red)
|
49
|
+
response = STDIN.gets.chomp
|
50
|
+
if response == 'y'
|
51
|
+
puts EndlessWaffleCLI.deleteRole(name)
|
52
|
+
else
|
53
|
+
puts "Stopping request."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def editRole(name)
|
58
|
+
orignial = JSON.pretty_generate(EndlessWaffleCLI.showRole name)
|
59
|
+
tmp_file="/tmp/ewrole-edit-#{name}-#{$$}.json"
|
60
|
+
File.open(tmp_file,"w") do |f|
|
61
|
+
f.write(orignial)
|
62
|
+
end
|
63
|
+
if ENV['EDITOR'].nil?
|
64
|
+
puts "I can not continue, please set your EDITOR enviroment variable"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
system "$EDITOR #{tmp_file}"
|
68
|
+
edited = File.read(tmp_file)
|
69
|
+
FileUtils.rm tmp_file
|
70
|
+
|
71
|
+
begin
|
72
|
+
edited = JSON.parse(edited)
|
73
|
+
rescue JSON::ParserError => e
|
74
|
+
puts "Sorry you give me invalid JSON, try again!".colorize(:red)
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
puts EndlessWaffleCLI.updateRole edited
|
78
|
+
end
|
79
|
+
|
80
|
+
def listRoles(name)
|
81
|
+
query = {"query"=>{"name"=>name}}
|
82
|
+
result = EndlessWaffleCLI.listRoles query
|
83
|
+
table_config = [
|
84
|
+
{:key=>:name, :size=>15, :title=>"Name"},
|
85
|
+
{:key=>:created_at, :size=>30, :title=>"Created"},
|
86
|
+
{:key=>:updated_at, :size=>30, :title=>"Updated"}
|
87
|
+
]
|
88
|
+
ConsoleTable.define(table_config) do |table|
|
89
|
+
result.each do |r|
|
90
|
+
table << [
|
91
|
+
r["name"],
|
92
|
+
r["created_at"],
|
93
|
+
r["updated_at"]
|
94
|
+
]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
parser = GetoptLong.new
|
100
|
+
parser.set_options(["-c", "--create", GetoptLong::NO_ARGUMENT],
|
101
|
+
["-l", "--list", GetoptLong::NO_ARGUMENT],
|
102
|
+
["-d", "--delete", GetoptLong::NO_ARGUMENT],
|
103
|
+
["-e", "--edit", GetoptLong::NO_ARGUMENT],
|
104
|
+
["-s", "--show", GetoptLong::NO_ARGUMENT],
|
105
|
+
["-h", "--help", GetoptLong::NO_ARGUMENT]
|
106
|
+
)
|
107
|
+
|
108
|
+
begin
|
109
|
+
begin
|
110
|
+
opt,arg = parser.get_option
|
111
|
+
break if not opt
|
112
|
+
case opt
|
113
|
+
when "-h" || "--help"
|
114
|
+
showHelp; exit
|
115
|
+
when "-c" || "--create"
|
116
|
+
createRole ARGV[0]; exit
|
117
|
+
when "-l" || "--list"
|
118
|
+
listRoles ARGV[0]; exit
|
119
|
+
when "-d" || "--delete"
|
120
|
+
deleteRole ARGV[0]; exit
|
121
|
+
when "-e" || "--edit"
|
122
|
+
editRole ARGV[0]; exit
|
123
|
+
when "-s" || "--show"
|
124
|
+
showRole ARGV[0]; exit
|
125
|
+
end
|
126
|
+
rescue => err
|
127
|
+
puts "#{err.class()}: #{err.message}"
|
128
|
+
exit 1
|
129
|
+
end
|
130
|
+
end while 1
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "EndlessWaffleCLI"
|
5
|
+
require 'json'
|
6
|
+
require 'getoptlong'
|
7
|
+
require 'console_table'
|
8
|
+
|
9
|
+
query = {}
|
10
|
+
updateCache = false
|
11
|
+
showJSON = false
|
12
|
+
|
13
|
+
if ENV['EndlessWaffleURL'].nil?
|
14
|
+
puts "EndlessWaffleCLI requires the 'EndlessWaffleURL' environment variable to be set."
|
15
|
+
exit 1
|
16
|
+
else
|
17
|
+
EndlessWaffleCLI.setServer ENV['EndlessWaffleURL']
|
18
|
+
end
|
19
|
+
|
20
|
+
if ENV['EndlessWaffleToken'].nil?
|
21
|
+
puts "EndlessWaffleCLI requires the 'EndlessWaffleToken' environment variable to be set."
|
22
|
+
exit 1
|
23
|
+
else
|
24
|
+
EndlessWaffleCLI.setToken ENV['EndlessWaffleToken']
|
25
|
+
end
|
26
|
+
|
27
|
+
def colorizeState(state)
|
28
|
+
if state > 0
|
29
|
+
state.to_s.colorize(:green)
|
30
|
+
else
|
31
|
+
state.to_s.colorize(:red)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def showHelp
|
36
|
+
puts
|
37
|
+
puts "Endless Waffle Security Groups"
|
38
|
+
puts "Usage example: #{$0} -a us-east-1c"
|
39
|
+
puts
|
40
|
+
puts "Options:"
|
41
|
+
puts "-v or --vpc_id".ljust(30) +"-> Specifiy vpc_id"
|
42
|
+
puts "-g or --group_id".ljust(30) +"-> Specify group id"
|
43
|
+
puts "-n or --name".ljust(30) +"-> Specify group id"
|
44
|
+
puts "-j or --json".ljust(30) +"-> Raw JSON output"
|
45
|
+
puts "-c or --cache ".ljust(30) +"-> Update local Cache database with current AWS data"
|
46
|
+
puts "-h or --help".ljust(30) +"-> Show this help message."
|
47
|
+
puts
|
48
|
+
end
|
49
|
+
|
50
|
+
parser = GetoptLong.new
|
51
|
+
parser.set_options(["-v", "--vpc_id", GetoptLong::NO_ARGUMENT],
|
52
|
+
["-g", "--group_id", GetoptLong::NO_ARGUMENT],
|
53
|
+
["-n", "--name", GetoptLong::NO_ARGUMENT],
|
54
|
+
["-j", "--json", GetoptLong::NO_ARGUMENT],
|
55
|
+
["-c", "--cache", GetoptLong::NO_ARGUMENT],
|
56
|
+
["-h", "--help", GetoptLong::NO_ARGUMENT]
|
57
|
+
)
|
58
|
+
|
59
|
+
begin
|
60
|
+
begin
|
61
|
+
opt,arg = parser.get_option
|
62
|
+
break if not opt
|
63
|
+
case opt
|
64
|
+
when "-h" || "--help"
|
65
|
+
showHelp
|
66
|
+
exit
|
67
|
+
when "-v" || "--vpc_id"
|
68
|
+
query.store(:vpc_id, ARGV[0])
|
69
|
+
when "-g" || "--group_id"
|
70
|
+
query.store(:group_id, ARGV[0])
|
71
|
+
when "-n" || "--name"
|
72
|
+
query.store(:name, ARGV[0])
|
73
|
+
when "-j" || "--json"
|
74
|
+
showJSON = true
|
75
|
+
when "-c" || "--cache"
|
76
|
+
updateCache = true
|
77
|
+
end
|
78
|
+
rescue => err
|
79
|
+
puts "#{err.class()}: #{err.message}"
|
80
|
+
exit 1
|
81
|
+
end
|
82
|
+
end while 1
|
83
|
+
|
84
|
+
def showTable(result)
|
85
|
+
table_config = [
|
86
|
+
{:key=>:name, :size=>20, :title=>"Name"},
|
87
|
+
{:key=>:description, :size=>35, :title=>"Desc"},
|
88
|
+
{:key=>:group_id, :size=>12, :title=>"Group ID"},
|
89
|
+
{:key=>:vpc_id, :size=>12, :title=>"VPC ID"},
|
90
|
+
{:key=>:owner_id, :size=>16, :title=>"Owner"}
|
91
|
+
]
|
92
|
+
ConsoleTable.define(table_config) do |table|
|
93
|
+
result.each do |r|
|
94
|
+
table << [
|
95
|
+
r["name"],
|
96
|
+
r["description"],
|
97
|
+
r["group_id"],
|
98
|
+
r["vpc_id"],
|
99
|
+
r["owner_id"]
|
100
|
+
]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def showJSON(result)
|
106
|
+
puts JSON.pretty_generate(result)
|
107
|
+
end
|
108
|
+
|
109
|
+
if updateCache == true
|
110
|
+
puts "Running Cache Update:"
|
111
|
+
puts EndlessWaffleCLI.updateSecurityGroups
|
112
|
+
end
|
113
|
+
|
114
|
+
result = EndlessWaffleCLI.querySecurityGroups query
|
115
|
+
|
116
|
+
if showJSON == false
|
117
|
+
showTable result
|
118
|
+
else
|
119
|
+
showJSON result
|
120
|
+
end
|
data/exe/ewssl
CHANGED
@@ -10,7 +10,7 @@ require 'console_table'
|
|
10
10
|
require 'openssl'
|
11
11
|
|
12
12
|
|
13
|
-
|
13
|
+
@upload_to_iam=false
|
14
14
|
@results_directory = "#{ENV["HOME"]}/.ewssl"
|
15
15
|
@config_file = "#{ENV["HOME"]}/.ewssl.json"
|
16
16
|
|
@@ -50,6 +50,7 @@ def display_help
|
|
50
50
|
puts "-c or --config".ljust(30) +"-> Specifiy Config to use"
|
51
51
|
puts "-f or --fqdn".ljust(30) +"-> Domain name you want a CRT for"
|
52
52
|
puts "-l or --list".ljust(30) + "-> List Valid Configs"
|
53
|
+
puts "-i or --iam".ljust(30) + "-> Upload Certificate to IAM"
|
53
54
|
puts
|
54
55
|
exit 1
|
55
56
|
end
|
@@ -63,7 +64,8 @@ def parse_cli
|
|
63
64
|
parser.set_options(["-h", "--help", GetoptLong::NO_ARGUMENT],
|
64
65
|
["-c", "--config", GetoptLong::NO_ARGUMENT],
|
65
66
|
["-f", "--fqdn", GetoptLong::NO_ARGUMENT],
|
66
|
-
["-l", "--list", GetoptLong::NO_ARGUMENT]
|
67
|
+
["-l", "--list", GetoptLong::NO_ARGUMENT],
|
68
|
+
["-i", "--iam", GetoptLong::NO_ARGUMENT]
|
67
69
|
)
|
68
70
|
|
69
71
|
begin
|
@@ -78,6 +80,8 @@ def parse_cli
|
|
78
80
|
@active_config = ARGV[0].strip().downcase()
|
79
81
|
when "-f" || "--fqdn"
|
80
82
|
@fqdn = ARGV[0].strip().downcase()
|
83
|
+
when "-i" || "--iam"
|
84
|
+
@upload_to_iam = true
|
81
85
|
when "-l" || "--list"
|
82
86
|
@list = true
|
83
87
|
end
|
@@ -186,6 +190,14 @@ def genDataBag
|
|
186
190
|
end
|
187
191
|
end
|
188
192
|
|
193
|
+
def upload_to_iam
|
194
|
+
command = "aws iam upload-server-certificate \
|
195
|
+
--server-certificate-name #{@fqdn.gsub('*','star')}-#{@timestamp} \
|
196
|
+
--certificate-body file://#{@my_cert_path} \
|
197
|
+
--private-key file://#{@my_key_path}\
|
198
|
+
--certificate-chain file://#{@my_chain_path}"
|
199
|
+
system(command)
|
200
|
+
end
|
189
201
|
|
190
202
|
parse_cli
|
191
203
|
if @list == true
|
@@ -207,4 +219,8 @@ else
|
|
207
219
|
storeSignedCert
|
208
220
|
storeCertificateChain
|
209
221
|
genDataBag
|
222
|
+
if @upload_to_iam == true
|
223
|
+
upload_to_iam
|
224
|
+
end
|
225
|
+
|
210
226
|
end
|
data/lib/EndlessWaffleCLI.rb
CHANGED
@@ -85,4 +85,117 @@ module EndlessWaffleCLI
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def self.updateSecurityGroups
|
89
|
+
begin
|
90
|
+
result = RestClient.get "#{@@server}/securitygroups/update", :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
91
|
+
JSON.parse(result.body)
|
92
|
+
rescue => e
|
93
|
+
raise e
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.querySecurityGroups(query={})
|
98
|
+
begin
|
99
|
+
result = RestClient.post "#{@@server}/securitygroups/show", { :query => query }.to_json, :content_type => :json, :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
100
|
+
JSON.parse(result.body)
|
101
|
+
rescue => e
|
102
|
+
raise e
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def self.listRoles(query={})
|
108
|
+
begin
|
109
|
+
result = RestClient.post "#{@@server}/role/list", { :query => query }.to_json, :content_type => :json, :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
110
|
+
JSON.parse(result.body)
|
111
|
+
rescue => e
|
112
|
+
raise e
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.showRole(name)
|
117
|
+
begin
|
118
|
+
result = RestClient.post "#{@@server}/role/show", { :name => name }.to_json, :content_type => :json, :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
119
|
+
JSON.parse(result.body)
|
120
|
+
rescue => e
|
121
|
+
raise e
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.createRole(name)
|
126
|
+
query = {"name" => name}
|
127
|
+
begin
|
128
|
+
result = RestClient.post "#{@@server}/role/create", query.to_json, :content_type => :json, :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
129
|
+
JSON.parse(result.body)
|
130
|
+
rescue => e
|
131
|
+
raise e
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.deleteRole(name)
|
136
|
+
query = {"name" => name}
|
137
|
+
begin
|
138
|
+
result = RestClient.post "#{@@server}/role/delete", query.to_json, :content_type => :json, :Authorization => "Token token=\"#{@@token}\""
|
139
|
+
JSON.parse(result.body)
|
140
|
+
rescue => e
|
141
|
+
raise e
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.updateRole(data)
|
146
|
+
begin
|
147
|
+
result = RestClient.post "#{@@server}/role/update", data.to_json, :content_type => :json, :Authorization => "Token token=\"#{@@token}\""
|
148
|
+
JSON.parse(result.body)
|
149
|
+
rescue => e
|
150
|
+
raise e
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.listCommand(query={})
|
155
|
+
begin
|
156
|
+
result = RestClient.post "#{@@server}/commands/list", { :query => query }.to_json, :content_type => :json, :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
157
|
+
JSON.parse(result.body)
|
158
|
+
rescue => e
|
159
|
+
raise e
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.showCommand(name)
|
164
|
+
begin
|
165
|
+
result = RestClient.post "#{@@server}/commands/show", { :name => name }.to_json, :content_type => :json, :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
166
|
+
JSON.parse(result.body)
|
167
|
+
rescue => e
|
168
|
+
raise e
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def self.createCommand(name)
|
173
|
+
query = {"name" => name}
|
174
|
+
begin
|
175
|
+
result = RestClient.post "#{@@server}/commands/create", query.to_json, :content_type => :json, :accept => :json, :Authorization => "Token token=\"#{@@token}\""
|
176
|
+
JSON.parse(result.body)
|
177
|
+
rescue => e
|
178
|
+
raise e
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.deleteCommand(name)
|
183
|
+
query = {"name" => name}
|
184
|
+
begin
|
185
|
+
result = RestClient.post "#{@@server}/commands/delete", query.to_json, :content_type => :json, :Authorization => "Token token=\"#{@@token}\""
|
186
|
+
JSON.parse(result.body)
|
187
|
+
rescue => e
|
188
|
+
raise e
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.updateCommand(data)
|
193
|
+
begin
|
194
|
+
result = RestClient.post "#{@@server}/commands/update", data.to_json, :content_type => :json, :Authorization => "Token token=\"#{@@token}\""
|
195
|
+
JSON.parse(result.body)
|
196
|
+
rescue => e
|
197
|
+
raise e
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
88
201
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: EndlessWaffleCLI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr. Ogg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -197,6 +197,9 @@ executables:
|
|
197
197
|
- enum
|
198
198
|
- enum-ssh
|
199
199
|
- ewami
|
200
|
+
- ewcommand
|
201
|
+
- ewrole
|
202
|
+
- ewsecuritygroups
|
200
203
|
- ewssh
|
201
204
|
- ewssl
|
202
205
|
- ewsubnets
|
@@ -224,6 +227,9 @@ files:
|
|
224
227
|
- exe/enum
|
225
228
|
- exe/enum-ssh
|
226
229
|
- exe/ewami
|
230
|
+
- exe/ewcommand
|
231
|
+
- exe/ewrole
|
232
|
+
- exe/ewsecuritygroups
|
227
233
|
- exe/ewssh
|
228
234
|
- exe/ewssl
|
229
235
|
- exe/ewsubnets
|