Class: Cradlepoint::Config
- Inherits:
-
CradlepointObject
- Object
- CradlepointObject
- Cradlepoint::Config
- Defined in:
- lib/cradlepoint/config.rb
Overview
In order to apply a configuration to the ECM you can simply call Cradlepoint::Config.update(router), where the router is currently an ActiveRecord object, this will soon merely require a ruby dictionary instead.
When update is called, a few steps must be undergone:
1. We must facilitate a POST to create a configuration_editor with the ECM API.
2. We must then perform a PUT of the configuration data to the configuration_editor.
3. Then we simply DELETE the configuration_editor, the ECM API does the rest.
Instance Attribute Summary collapse
-
#config_editor_id ⇒ Object
Returns the value of attribute config_editor_id.
-
#config_settings ⇒ Object
Returns the value of attribute config_settings.
-
#data ⇒ Object
Returns the value of attribute data.
-
#id ⇒ Object
Returns the value of attribute id.
-
#router ⇒ Object
Returns the value of attribute router.
Class Method Summary collapse
Instance Method Summary collapse
- #apply_config_to_editor ⇒ Object
- #create_editor ⇒ Object
-
#initialize(router, config_settings = nil) ⇒ Config
constructor
A new instance of Config.
- #rel_url ⇒ Object
- #rel_url_from_router ⇒ Object
- #rel_url_with_id ⇒ Object
- #remove_editor ⇒ Object
Methods inherited from CradlepointObject
build_new_url, #build_new_url, #build_url, build_url, #params
Constructor Details
#initialize(router, config_settings = nil) ⇒ Config
Returns a new instance of Config.
15 16 17 18 |
# File 'lib/cradlepoint/config.rb', line 15 def initialize(router, config_settings = nil) self.router = router self.config_settings = config_settings end |
Instance Attribute Details
#config_editor_id ⇒ Object
Returns the value of attribute config_editor_id.
13 14 15 |
# File 'lib/cradlepoint/config.rb', line 13 def config_editor_id @config_editor_id end |
#config_settings ⇒ Object
Returns the value of attribute config_settings.
13 14 15 |
# File 'lib/cradlepoint/config.rb', line 13 def config_settings @config_settings end |
#data ⇒ Object
Returns the value of attribute data.
13 14 15 |
# File 'lib/cradlepoint/config.rb', line 13 def data @data end |
#id ⇒ Object
Returns the value of attribute id.
13 14 15 |
# File 'lib/cradlepoint/config.rb', line 13 def id @id end |
#router ⇒ Object
Returns the value of attribute router.
13 14 15 |
# File 'lib/cradlepoint/config.rb', line 13 def router @router end |
Class Method Details
.rel_url ⇒ Object
20 21 22 |
# File 'lib/cradlepoint/config.rb', line 20 def self.rel_url '/configuration_editors/' end |
.rel_url_from_router(router) ⇒ Object
36 37 38 |
# File 'lib/cradlepoint/config.rb', line 36 def self.rel_url_from_router(router) "#{ Cradlepoint::Router.rel_url }/#{ router.id }/configuration_manager/" end |
.rel_url_with_id(id) ⇒ Object
28 29 30 |
# File 'lib/cradlepoint/config.rb', line 28 def self.rel_url_with_id(id) "#{ rel_url }#{ id }/" end |
Instance Method Details
#apply_config_to_editor ⇒ Object
53 54 55 56 57 58 |
# File 'lib/cradlepoint/config.rb', line 53 def apply_config_to_editor self.data = Cradlepoint.handle_response RestClient.put(build_url(rel_url_with_id), get_config_data_with_wrapper(config_settings).to_json, content_type: :json, accept: :json) end |
#create_editor ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/cradlepoint/config.rb', line 44 def create_editor self.data = Cradlepoint.handle_response RestClient.post(build_url(rel_url), router.get_configuration_editor_data.to_json, content_type: :json, accept: :json) self.id = self.data[:id] self.data end |
#rel_url ⇒ Object
24 25 26 |
# File 'lib/cradlepoint/config.rb', line 24 def rel_url Cradlepoint::Config.rel_url end |
#rel_url_from_router ⇒ Object
40 41 42 |
# File 'lib/cradlepoint/config.rb', line 40 def rel_url_from_router Cradlepoint::Config.rel_url_from_router(router) end |
#rel_url_with_id ⇒ Object
32 33 34 |
# File 'lib/cradlepoint/config.rb', line 32 def rel_url_with_id Cradlepoint::Config.rel_url_with_id(id) end |
#remove_editor ⇒ Object
60 61 62 63 64 |
# File 'lib/cradlepoint/config.rb', line 60 def remove_editor self.data = Cradlepoint.handle_response RestClient.delete(build_url(rel_url_with_id), content_type: :json, accept: :json) end |