Class: EnfApi::Captive

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/enfapi.rb

Overview

Captive

Instance Method Summary collapse

Instance Method Details

#create_device(new_dev_hash) ⇒ Object

Post the new device NO_TEST



138
139
140
141
# File 'lib/enfapi.rb', line 138

def create_device(new_dev_hash)
  json = EnfApi.to_json(new_dev_hash)
  EnfApi::API.instance.post "/api/captive/v1/device", json
end

#create_firmware_update(update_hash) ⇒ Object

POSTs a new firmware-udpate object NO_TEST



269
270
271
272
# File 'lib/enfapi.rb', line 269

def create_firmware_update(update_hash)
  json = EnfApi.to_json(update_hash)
  EnfApi::API.instance.post "/api/captive/v1/firmware/update", json
end

#create_profile(new_profile_hash) ⇒ Object

Post the new profile NO_TEST



172
173
174
175
# File 'lib/enfapi.rb', line 172

def create_profile(new_profile_hash)
  json = EnfApi.to_json(new_profile_hash)
  EnfApi::API.instance.post "/api/captive/v1/profile", json
end

#create_schedule(sched_hash) ⇒ Object

creates a new schedule object via POST NO_TEST



224
225
226
227
# File 'lib/enfapi.rb', line 224

def create_schedule(sched_hash)
  json = EnfApi.to_json(sched_hash)
  EnfApi::API.instance.post "/api/captive/v1/schedule", json
end

#create_wifi_configuration(new_wifi_config) ⇒ Object

NO_TEST



116
117
118
119
# File 'lib/enfapi.rb', line 116

def create_wifi_configuration(new_wifi_config)
  json = EnfApi::to_json(new_wifi_config)
  EnfApi::API.instance.post "/api/captive/v1/wifi", json
end

#delete_schedule(id) ⇒ Object

DELETEs the specified schedule NO_TEST



251
252
253
# File 'lib/enfapi.rb', line 251

def delete_schedule(id)
  EnfApi::API.instance.delete "/api/captive/v1/schedule/#{id}"
end

#get_device(dev_id) ⇒ Object

Get a specific device detail NO_TEST



153
154
155
# File 'lib/enfapi.rb', line 153

def get_device(dev_id)
  EnfApi::API.instance.get "/api/captive/v1/device/#{dev_id}"
end

#get_device_status(dev_id) ⇒ Object

Get the status of a device NO_TEST



166
167
168
# File 'lib/enfapi.rb', line 166

def get_device_status(dev_id)
  EnfApi::API.instance.get "/api/captive/v1/device/#{dev_id}/status"
end

#get_firmware_info(version) ⇒ Object

gets the details for a specific firmware version NO_TEST



217
218
219
220
# File 'lib/enfapi.rb', line 217

def get_firmware_info(version)
  url = "/api/captive/v1/firmware/release/#{version}"
  EnfApi::API.instance.get url
end

#get_firmware_update(update_id) ⇒ Object

GET details of a specified firmware update task NO_TEST



263
264
265
# File 'lib/enfapi.rb', line 263

def get_firmware_update(update_id)
  EnfApi::API.instance.get "/api/captive/v1/firmware/update/#{update_id}"
end

#get_profile(profile_id) ⇒ Object

Get detail on a specific profile NO_TEST



188
189
190
# File 'lib/enfapi.rb', line 188

def get_profile(profile_id)
  EnfApi::API.instance.get "/api/captive/v1/profile/#{profile_id}"
end

#get_schedule(id) ⇒ Object

GETs the details of a specific schedule NO_TEST



237
238
239
# File 'lib/enfapi.rb', line 237

def get_schedule(id)
  EnfApi::API.instance.get "/api/captive/v1/schedule/#{id}"
end

#get_wifi_configuration(wifi_id, version = nil) ⇒ Object

Get the wifi configuration using the wifi id NO_TEST



123
124
125
126
127
# File 'lib/enfapi.rb', line 123

def get_wifi_configuration(wifi_id, version = nil)
  url = "/api/captive/v1/wifi/#{wifi_id}"
  url = "#{url}?version=#{version}" if version
  EnfApi::API.instance.get url
end

#list_devices(network) ⇒ Object

Get the list of devices NO_TEST



145
146
147
148
149
# File 'lib/enfapi.rb', line 145

def list_devices(network)
  url = "/api/captive/v1/device"
  url = "#{url}?#{network}" if network
  EnfApi::API.instance.get url
end

#list_firmware_imagesObject

Get the list of devices NO_TEST



201
202
203
204
# File 'lib/enfapi.rb', line 201

def list_firmware_images()
  url = "/api/captive/v1/firmware/release"
  EnfApi::API.instance.get url
end

#list_firmware_updatesObject

GET the list of existing update objects NO_TEST



257
258
259
# File 'lib/enfapi.rb', line 257

def list_firmware_updates()
  EnfApi::API.instance.get "/api/captive/v1/firmware/update"
end

#list_profiles(name = nil) ⇒ Object

Get the list of profiles name is a substring of the profile names to be returned NO_TEST



180
181
182
183
184
# File 'lib/enfapi.rb', line 180

def list_profiles(name = nil)
  url = "/api/captive/v1/profile"
  url = "#{url}?#{name}" if name
  EnfApi::API.instance.get url
end

#list_schedulesObject

GETs a list of all existing schedules NO_TEST



231
232
233
# File 'lib/enfapi.rb', line 231

def list_schedules
  EnfApi::API.instance.get "/api/captive/v1/schedule"
end

#list_wifi_configurationsObject

NO_TEST



111
112
113
# File 'lib/enfapi.rb', line 111

def list_wifi_configurations
  EnfApi::API.instance.get "/api/captive/v1/wifi"
end

#modify_firmware_update(update_id, update_hash) ⇒ Object

uses PUT to modify an existing firmware update task NO_TEST



276
277
278
279
280
# File 'lib/enfapi.rb', line 276

def modify_firmware_update(update_id, update_hash)
  url = "/api/captive/v1/firmware/update/#{update_id}"
  json = EnfApi.to_json(update_hash)
  EnfApi::API.instance.put url, json
end

#update_device(id, dev_updates) ⇒ Object

Update a device NO_TEST



159
160
161
162
# File 'lib/enfapi.rb', line 159

def update_device(id, dev_updates)
  json = EnfApi.to_json(dev_updates)
  EnfApi::API.instance.put "/api/captive/v1/device/#{id}", json
end

#update_profile(id, profile_updates) ⇒ Object

Send update PUT request for profile NO_TEST



194
195
196
197
# File 'lib/enfapi.rb', line 194

def update_profile(id, profile_updates)
  json = EnfApi.to_json(profile_updates)
  EnfApi::API.instance.put "/api/captive/v1/profile/#{id}", json
end

#update_schedule(id, sched_hash) ⇒ Object

update the details of a specific schedule NO_TEST



243
244
245
246
247
# File 'lib/enfapi.rb', line 243

def update_schedule(id, sched_hash)
  json = EnfApi.to_json(sched_hash)
  url = "/api/captive/v1/schedule/#{id}"
  EnfApi::API.instance.put url, json
end

#update_wifi_configuration(wifi_id, updated_wifi_config) ⇒ Object

Update an existing wifi configuration NO_TEST



131
132
133
134
# File 'lib/enfapi.rb', line 131

def update_wifi_configuration(wifi_id, updated_wifi_config)
  json = EnfApi::to_json(updated_wifi_config)
  EnfApi::API.instance.put "/api/captive/v1/wifi/#{wifi_id}", json
end

#upload_firmware_image(version, image_name) ⇒ Object

Upload the firmware image Current version sends an empty body - captive server doesn’t support sending the binary image yet. NO_TEST



210
211
212
213
# File 'lib/enfapi.rb', line 210

def upload_firmware_image(version, image_name)
  url = "/api/captive/v1/firmware/release/#{version}/#{image_name}"
  EnfApi::API.instance.put url
end