Class: Cradlepoint::Router
- Inherits:
-
CradlepointObject
- Object
- CradlepointObject
- Cradlepoint::Router
- Defined in:
- lib/cradlepoint/router.rb
Instance Attribute Summary collapse
-
#config_status ⇒ Object
Returns the value of attribute config_status.
-
#data ⇒ Object
Returns the value of attribute data.
-
#description ⇒ Object
Returns the value of attribute description.
-
#ecm_configuration_manager_data ⇒ Object
Returns the value of attribute ecm_configuration_manager_data.
-
#ecm_configuration_manager_uri ⇒ Object
Returns the value of attribute ecm_configuration_manager_uri.
-
#ecm_configuration_uri ⇒ Object
Returns the value of attribute ecm_configuration_uri.
-
#ecm_firmware_uri ⇒ Object
Returns the value of attribute ecm_firmware_uri.
-
#full_product_name ⇒ Object
Returns the value of attribute full_product_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#mac ⇒ Object
Returns the value of attribute mac.
-
#name ⇒ Object
Returns the value of attribute name.
-
#stream_usage_in ⇒ Object
Returns the value of attribute stream_usage_in.
-
#stream_usage_out ⇒ Object
Returns the value of attribute stream_usage_out.
-
#stream_usage_period ⇒ Object
Returns the value of attribute stream_usage_period.
Class Method Summary collapse
- .index ⇒ Object
- .rel_url ⇒ Object
- .rel_url_for_configuration_managers(id) ⇒ Object
- .rel_url_with_id(id) ⇒ Object
Instance Method Summary collapse
- #apply_new_config(config_settings = {}) ⇒ Object
- #assign_attributes_from_data ⇒ Object
- #configuration_manager_data ⇒ Object
- #configuration_uri ⇒ Object
- #firmware_data ⇒ Object
- #firmware_uri ⇒ Object
- #get ⇒ Object
- #get_configuration_editor_data ⇒ Object
-
#initialize(id = nil, options = {}) ⇒ Router
constructor
A new instance of Router.
- #lazy_load_configuration_manager_data ⇒ Object
- #lazy_load_router_data ⇒ Object
- #rel_url ⇒ Object
- #rel_url_for_configuration_managers ⇒ Object
- #rel_url_with_id ⇒ Object
Methods inherited from CradlepointObject
build_new_url, #build_new_url, #build_url, build_url, ecm_object_blob?, #ecm_object_blob?, #params, #successful_response?, successful_response?
Constructor Details
#initialize(id = nil, options = {}) ⇒ Router
Returns a new instance of Router.
9 10 11 12 |
# File 'lib/cradlepoint/router.rb', line 9 def initialize(id = nil, = {}) self.id = id .each { |k, v| send("#{ k }=", v) if v } end |
Instance Attribute Details
#config_status ⇒ Object
Returns the value of attribute config_status.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def config_status @config_status end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def data @data end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def description @description end |
#ecm_configuration_manager_data ⇒ Object
Returns the value of attribute ecm_configuration_manager_data.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def ecm_configuration_manager_data @ecm_configuration_manager_data end |
#ecm_configuration_manager_uri ⇒ Object
Returns the value of attribute ecm_configuration_manager_uri.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def ecm_configuration_manager_uri @ecm_configuration_manager_uri end |
#ecm_configuration_uri ⇒ Object
Returns the value of attribute ecm_configuration_uri.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def ecm_configuration_uri @ecm_configuration_uri end |
#ecm_firmware_uri ⇒ Object
Returns the value of attribute ecm_firmware_uri.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def ecm_firmware_uri @ecm_firmware_uri end |
#full_product_name ⇒ Object
Returns the value of attribute full_product_name.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def full_product_name @full_product_name end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def id @id end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def ip_address @ip_address end |
#mac ⇒ Object
Returns the value of attribute mac.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def mac @mac end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def name @name end |
#stream_usage_in ⇒ Object
Returns the value of attribute stream_usage_in.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def stream_usage_in @stream_usage_in end |
#stream_usage_out ⇒ Object
Returns the value of attribute stream_usage_out.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def stream_usage_out @stream_usage_out end |
#stream_usage_period ⇒ Object
Returns the value of attribute stream_usage_period.
4 5 6 |
# File 'lib/cradlepoint/router.rb', line 4 def stream_usage_period @stream_usage_period end |
Class Method Details
.index ⇒ Object
38 39 40 |
# File 'lib/cradlepoint/router.rb', line 38 def self.index build_array_of_routers_from_response(Cradlepoint.make_request(:get, build_url(rel_url))) end |
.rel_url ⇒ Object
14 15 16 |
# File 'lib/cradlepoint/router.rb', line 14 def self.rel_url '/routers' end |
.rel_url_for_configuration_managers(id) ⇒ Object
30 31 32 |
# File 'lib/cradlepoint/router.rb', line 30 def self.rel_url_for_configuration_managers(id) "#{ Cradlepoint::Router.rel_url_with_id(id) }/confguration_managers/" end |
.rel_url_with_id(id) ⇒ Object
22 23 24 |
# File 'lib/cradlepoint/router.rb', line 22 def self.rel_url_with_id(id) "#{ rel_url }/#{ id }/" end |
Instance Method Details
#apply_new_config(config_settings = {}) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/cradlepoint/router.rb', line 49 def apply_new_config(config_settings = {}) config = Cradlepoint::Config.new(self, config_settings) config.create_editor config.apply_config_to_editor config.remove_editor end |
#assign_attributes_from_data ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/cradlepoint/router.rb', line 97 def assign_attributes_from_data return unless self.data and self.data.any? self.mac = self.data[:mac] self.name = self.data[:name] self.ip_address = self.data[:ip_address] self.config_status = self.data[:config_status] self.description = self.data[:description] self.full_product_name = self.data[:full_product_name] self.stream_usage_in = self.data[:stream_usage_in] self.stream_usage_out = self.data[:stream_usage_out] self.stream_usage_period = self.data[:stream_usage_period] end |
#configuration_manager_data ⇒ Object
56 57 58 59 60 |
# File 'lib/cradlepoint/router.rb', line 56 def configuration_manager_data check_for_id_or_raise_error lazy_load_configuration_manager_data unless self.ecm_configuration_manager_data self.ecm_configuration_manager_data end |
#configuration_uri ⇒ Object
72 73 74 75 76 |
# File 'lib/cradlepoint/router.rb', line 72 def configuration_uri lazy_load_router_data unless self.ecm_configuration_manager_uri lazy_load_configuration_manager_data unless self.ecm_configuration_uri self.ecm_configuration_uri end |
#firmware_data ⇒ Object
62 63 64 65 |
# File 'lib/cradlepoint/router.rb', line 62 def firmware_data check_for_id_or_raise_error Cradlepoint.make_request(:get, build_url(firmware_uri.split('/api/v1').last)) if firmware_uri end |
#firmware_uri ⇒ Object
67 68 69 70 |
# File 'lib/cradlepoint/router.rb', line 67 def firmware_uri lazy_load_router_data unless self.ecm_firmware_uri self.ecm_firmware_uri end |
#get ⇒ Object
42 43 44 45 46 47 |
# File 'lib/cradlepoint/router.rb', line 42 def get check_for_id_or_raise_error self.data = Cradlepoint.make_request(:get, build_url(rel_url_with_id)) assign_attributes_from_data self.data end |
#get_configuration_editor_data ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/cradlepoint/router.rb', line 88 def get_configuration_editor_data { account: '/api/v1' + Cradlepoint.account.rel_url_with_id, baseline: configuration_uri, firmware: firmware_uri, router: '/api/v1' + rel_url_with_id } end |
#lazy_load_configuration_manager_data ⇒ Object
84 85 86 |
# File 'lib/cradlepoint/router.rb', line 84 def lazy_load_configuration_manager_data self.ecm_configuration_manager_data = Cradlepoint.make_request(:get, build_url(rel_url_for_configuration_managers)) end |
#lazy_load_router_data ⇒ Object
78 79 80 81 82 |
# File 'lib/cradlepoint/router.rb', line 78 def lazy_load_router_data get # Grab the data from the api. self.ecm_firmware_uri = self.data[:actual_firmware] self.ecm_configuration_manager_uri = self.data[:configuration_manager] end |
#rel_url ⇒ Object
18 19 20 |
# File 'lib/cradlepoint/router.rb', line 18 def rel_url Cradlepoint::Router.rel_url end |
#rel_url_for_configuration_managers ⇒ Object
34 35 36 |
# File 'lib/cradlepoint/router.rb', line 34 def rel_url_for_configuration_managers Cradlepoint::Router.rel_url_with_id(id) end |
#rel_url_with_id ⇒ Object
26 27 28 |
# File 'lib/cradlepoint/router.rb', line 26 def rel_url_with_id Cradlepoint::Router.rel_url_with_id(id) end |