Class: SoracomCli::EventHandler
- Inherits:
-
Thor
- Object
- Thor
- SoracomCli::EventHandler
- Defined in:
- lib/soracom/cli.rb
Overview
EventHandler related commands
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/soracom/cli.rb', line 217 def create if .req=~/^[a-z]+:\/\/(.+)/ begin content = open(.req.sub(/^file:\/\//,'')).read ['req'] = content rescue Errno::ENOENT rescue SocketError abort "ERROR: Cannot access #{.req}." end end client = Soracom::Client.new(profile:.profile) puts JSON.pretty_generate(client.create_event_handler(.req)) end |
#delete ⇒ Object
233 234 235 236 |
# File 'lib/soracom/cli.rb', line 233 def delete client = Soracom::Client.new(profile:.profile) puts JSON.pretty_generate(client.delete_event_handler(.handler_id)) end |
#list ⇒ Object
209 210 211 212 213 |
# File 'lib/soracom/cli.rb', line 209 def list client = Soracom::Client.new(profile:.profile) .delete('profile') puts JSON.pretty_generate(client.list_event_handlers(Hash[.map { |k, v| [k.to_sym, v] }])) end |
#update ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/soracom/cli.rb', line 241 def update if .req=~/^[a-z]+:\/\/(.+)/ begin content = open(.req.sub(/^file:\/\//,'')).read ['req'] = content rescue Errno::ENOENT rescue SocketError abort "ERROR: Cannot access #{.req}." end end client = Soracom::Client.new(profile:.profile) puts JSON.pretty_generate(client.update_event_handler(.handler_id, .req)) end |