freebox_api 0.1.2 → 0.2.0
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.
- data/README.md +164 -79
- data/lib/freebox_api.rb +7 -0
- data/lib/freebox_api/configuration.rb +7 -0
- data/lib/freebox_api/configuration/connection.rb +70 -0
- data/lib/freebox_api/configuration/dhcp.rb +68 -0
- data/lib/freebox_api/configuration/freeplug.rb +36 -0
- data/lib/freebox_api/configuration/lan.rb +85 -0
- data/lib/freebox_api/freebox.rb +2 -2
- data/lib/freebox_api/version.rb +1 -1
- metadata +16 -5
- checksums.yaml +0 -15
data/README.md
CHANGED
@@ -69,7 +69,7 @@ mySession = FreeboxApi::Session.new(myApp, myFreebox)
|
|
69
69
|
or
|
70
70
|
|
71
71
|
```ruby
|
72
|
-
|
72
|
+
mySession = FreeboxApi::Session.new({
|
73
73
|
:app_id => 'fr.freebox.testapp',
|
74
74
|
:app_version => '0.0.7',
|
75
75
|
:app_token => 'dyNYgfK0Ya6FWGqq83sBHa7TwzWo+pg4fDFUJHShcjVYzTfaRrZzm93p7OTAfH/0',
|
@@ -79,50 +79,43 @@ mysession = FreeboxApi::Session.new({
|
|
79
79
|
Reference
|
80
80
|
---------
|
81
81
|
|
82
|
-
|
83
|
-
config = FreeboxApi::Config.new(mySession)
|
84
|
-
```
|
85
|
-
|
86
|
-
### Connection API
|
82
|
+
### Configuration
|
87
83
|
|
88
|
-
#### Connection
|
84
|
+
#### Connection
|
89
85
|
|
90
86
|
##### Get the current Connection status
|
91
|
-
[ ] GET /api/v1/connection/
|
92
87
|
|
93
|
-
|
88
|
+
```ruby
|
89
|
+
FreeboxApi::Configuration::Connection.getStatus(mySession)
|
90
|
+
```
|
94
91
|
|
95
92
|
##### Get the current Connection configuration
|
96
|
-
[X] GET /api/v1/connection/config/
|
97
93
|
|
98
94
|
```ruby
|
99
|
-
|
95
|
+
FreeboxApi::Configuration::Connection.getConfig(mySession)
|
100
96
|
```
|
101
97
|
|
102
98
|
##### Update the Connection configuration
|
103
|
-
[X] PUT /api/v1/connection/config/
|
104
99
|
|
105
100
|
```ruby
|
106
|
-
|
101
|
+
FreeboxApi::Configuration::Connection.updateConfig(mySession, {
|
107
102
|
:ping => true,
|
108
103
|
:wol => false,
|
109
104
|
})
|
110
105
|
```
|
111
106
|
|
112
|
-
|
107
|
+
##### IPv6
|
113
108
|
|
114
|
-
|
115
|
-
[X] GET /api/v1/connection/ipv6/config/
|
109
|
+
###### Get the current IPv6 Connection configuration
|
116
110
|
|
117
111
|
```ruby
|
118
|
-
|
112
|
+
FreeboxApi::Configuration::Connection::IPv6.getConfig(mySession)
|
119
113
|
```
|
120
114
|
|
121
|
-
|
122
|
-
[X] PUT /api/v1/connection/ipv6/config/
|
115
|
+
###### Update the IPv6 Connection configuration
|
123
116
|
|
124
117
|
```ruby
|
125
|
-
|
118
|
+
FreeboxApi::Configuration::Connection::IPv6.updateConfig(mySession, {
|
126
119
|
:delegations => [
|
127
120
|
{
|
128
121
|
:prefix => '2a01:e30:d252:a2a2::/64',
|
@@ -132,25 +125,38 @@ config.update('ipv6', {
|
|
132
125
|
})
|
133
126
|
```
|
134
127
|
|
135
|
-
|
128
|
+
##### Connection DynDNS status
|
129
|
+
|
130
|
+
###### Get the status of a DynDNS service
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
FreeboxApi::Configuration::Connection::DDNS.getStatus(mySession, 'dyndns')
|
134
|
+
```
|
135
|
+
|
136
|
+
or
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
ddns = FreeboxApi::Configuration::Connection::DDNS.new(mySession, 'dyndns')
|
140
|
+
ddns.status
|
141
|
+
```
|
136
142
|
|
137
|
-
|
138
|
-
[ ] GET /api/v1/connection/ddns/{provider}/status/
|
143
|
+
###### Get the config of a DynDNS service
|
139
144
|
|
140
|
-
|
145
|
+
```ruby
|
146
|
+
FreeboxApi::Configuration::Connection::DDNS.getConfig(mySession, 'dyndns')
|
147
|
+
```
|
141
148
|
|
142
|
-
|
143
|
-
[X] GET /api/v1/connection/ddns/{provider}/
|
149
|
+
or
|
144
150
|
|
145
151
|
```ruby
|
146
|
-
|
152
|
+
ddns = FreeboxApi::Configuration::Connection::DDNS.new(mySession, 'dyndns')
|
153
|
+
ddns.config
|
147
154
|
```
|
148
155
|
|
149
156
|
##### Set the config of a DynDNS service
|
150
|
-
[X] PUT /api/v1/connection/ddns/{provider}/
|
151
157
|
|
152
158
|
```ruby
|
153
|
-
|
159
|
+
FreeboxApi::Configuration::Connection::DDNS.updateConfig(mySession, 'dyndns', {
|
154
160
|
:enabled => false,
|
155
161
|
:user => 'test',
|
156
162
|
:password => 'ssss',
|
@@ -158,22 +164,30 @@ config.update('ddns/dyndns', {
|
|
158
164
|
})
|
159
165
|
```
|
160
166
|
|
161
|
-
|
167
|
+
or
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
ddns = FreeboxApi::Configuration::Connection::DDNS.new(mySession, 'dyndns')
|
171
|
+
ddns.config = {
|
172
|
+
:enabled => false,
|
173
|
+
:user => 'test',
|
174
|
+
:password => 'ssss',
|
175
|
+
:hostname => 'ttt',
|
176
|
+
}
|
177
|
+
```
|
162
178
|
|
163
|
-
#### Lan
|
179
|
+
#### Lan
|
164
180
|
|
165
181
|
##### Get the current Lan configuration
|
166
|
-
[X] GET /api/v1/lan/config/
|
167
182
|
|
168
183
|
```ruby
|
169
|
-
|
184
|
+
FreeboxApi::Configuration::Lan.getConfig(mySession)
|
170
185
|
```
|
171
186
|
|
172
187
|
##### Update the current Lan configuration
|
173
|
-
[X] PUT /api/v1/lan/config/
|
174
188
|
|
175
189
|
```ruby
|
176
|
-
|
190
|
+
FreeboxApi::Configuration::Lan.updateConfig({
|
177
191
|
:mode => 'router',
|
178
192
|
:ip => '192.168.69.254',
|
179
193
|
:name => 'Freebox de r0ro',
|
@@ -183,38 +197,52 @@ config.update('lan', {
|
|
183
197
|
})
|
184
198
|
```
|
185
199
|
|
186
|
-
|
187
|
-
|
188
|
-
#### Lan Browser API
|
200
|
+
##### Lan Browser
|
189
201
|
|
190
|
-
|
191
|
-
[X] GET /api/v1/lan/browser/interfaces/
|
202
|
+
###### Getting the list of browsable LAN interfaces
|
192
203
|
|
193
204
|
```ruby
|
194
|
-
|
195
|
-
interfaces.index
|
205
|
+
FreeboxApi::Configuration::Lan::Browser.interfaces(mySession)
|
196
206
|
```
|
197
207
|
|
198
208
|
##### Getting the list of hosts on a given interface
|
199
|
-
[X] GET /api/v1/lan/browser/{interface}/
|
200
209
|
|
201
210
|
```ruby
|
202
|
-
|
203
|
-
|
211
|
+
FreeboxApi::Configuration::Lan::Browser::Interface.getLanHosts(mySession, 'pub')
|
212
|
+
```
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
interface = FreeboxApi::Configuration::Lan::Browser::Interface.new(mySession, 'pub')
|
216
|
+
interface.lan_hosts
|
204
217
|
```
|
205
218
|
|
206
219
|
##### Getting an host information
|
207
|
-
[X] GET /api/v1/lan/browser/{interface}/{hostid}/
|
208
220
|
|
209
221
|
```ruby
|
210
|
-
|
222
|
+
FreeboxApi::Configuration::Lan::Browser::LanHost.show(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
|
223
|
+
```
|
224
|
+
|
225
|
+
or
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
lan_host = FreeboxApi::Configuration::Lan::Browser::LanHost.new(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
|
229
|
+
lan_host.show
|
211
230
|
```
|
212
231
|
|
213
232
|
##### Updating an host information
|
214
|
-
[X] PUT /api/v1/lan/browser/{interface}/{hostid}/
|
215
233
|
|
216
234
|
```ruby
|
217
|
-
|
235
|
+
FreeboxApi::Configuration::Lan::Browser::LanHost.update(mySession, 'pub', 'ether-00:24:d4:7e:00:4c', {
|
236
|
+
:id => 'ether-00:24:d4:7e:00:4c',
|
237
|
+
:primary_name => 'Freebox Tv',
|
238
|
+
})
|
239
|
+
```
|
240
|
+
|
241
|
+
or
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
lan_host = FreeboxApi::Configuration::Lan::Browser::LanHost.new(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
|
245
|
+
lan_host.update({
|
218
246
|
:id => 'ether-00:24:d4:7e:00:4c',
|
219
247
|
:primary_name => 'Freebox Tv',
|
220
248
|
})
|
@@ -223,96 +251,145 @@ lan_hosts.update({
|
|
223
251
|
#### Wake on LAN
|
224
252
|
|
225
253
|
##### Send Wake ok Lan packet to an host
|
226
|
-
[ ] POST /api/v1/lan/wol/{interface}/
|
227
254
|
|
228
|
-
|
255
|
+
```ruby
|
256
|
+
FreeboxApi::Configuration::Lan::Browser::Interface.wol(mySession, 'pub', {
|
257
|
+
:mac => '00:24:d4:7e:00:4c',
|
258
|
+
:password => '',
|
259
|
+
}
|
260
|
+
```
|
261
|
+
|
262
|
+
or
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
interface = FreeboxApi::Configuration::Lan::Browser::Interface.new(mySession, 'pub')
|
266
|
+
interface.wol({
|
267
|
+
:mac => '00:24:d4:7e:00:4c',
|
268
|
+
:password => '',
|
269
|
+
}
|
270
|
+
```
|
229
271
|
|
230
|
-
|
272
|
+
or
|
231
273
|
|
232
274
|
```ruby
|
233
|
-
|
234
|
-
|
275
|
+
lan_host = FreeboxApi::Configuration::Lan::Browser::LanHost.new(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
|
276
|
+
lan_host.wol({ :password => '' })
|
235
277
|
```
|
236
278
|
|
279
|
+
#### Freeplug
|
280
|
+
|
237
281
|
##### Get the current Freeplugs networks
|
238
|
-
[X] GET /api/v1/freeplug/
|
239
282
|
|
240
283
|
```ruby
|
241
|
-
|
284
|
+
FreeboxApi::Configuration::Freeplug.network(mySession)
|
242
285
|
```
|
243
286
|
|
244
287
|
##### Get a particular Freeplug information
|
245
|
-
[X] GET /api/v1/freeplug/{id}/
|
246
288
|
|
247
289
|
```ruby
|
248
|
-
|
290
|
+
FreeboxApi::Configuration::Freeplug.show(mySession, 'F4:CA:E5:1D:46:AE')
|
291
|
+
```
|
292
|
+
|
293
|
+
or
|
294
|
+
|
295
|
+
```ruby
|
296
|
+
freeplug = FreeboxApi::Configuration::Freeplug.new(mySession, 'F4:CA:E5:1D:46:AE')
|
297
|
+
freeplug.show
|
249
298
|
```
|
250
299
|
|
251
300
|
##### Reset a Freeplug
|
252
|
-
[X] POST /api/v1/freeplug/{id}/reset/
|
253
301
|
|
254
302
|
```ruby
|
255
|
-
|
303
|
+
FreeboxApi::Configuration::Freeplug.reset(mySession, 'F4:CA:E5:1D:46:AE')
|
256
304
|
```
|
257
305
|
|
258
|
-
|
306
|
+
or
|
307
|
+
|
308
|
+
```ruby
|
309
|
+
freeplug = FreeboxApi::Configuration::Freeplug.new(mySession, 'F4:CA:E5:1D:46:AE')
|
310
|
+
freeplug.reset
|
311
|
+
```
|
259
312
|
|
260
|
-
#### DHCP
|
313
|
+
#### DHCP
|
261
314
|
|
262
315
|
##### Get the current DHCP configuration
|
263
|
-
[X] GET /api/v1/dhcp/config/
|
264
316
|
|
265
317
|
```ruby
|
266
|
-
|
318
|
+
FreeboxApi::Configuration::Dhcp.getConfig(mySession)
|
267
319
|
```
|
268
320
|
|
269
321
|
##### Update the current DHCP configuration
|
270
|
-
[X] PUT /api/v1/dhcp/config/
|
271
322
|
|
272
323
|
```ruby
|
273
|
-
|
324
|
+
FreeboxApi::Configuration::Dhcp.updateConfig(mySession, {
|
274
325
|
:enabled => false,
|
275
326
|
})
|
276
327
|
```
|
277
328
|
|
278
|
-
#### DHCP Static Lease API
|
279
|
-
|
280
329
|
##### Get the list of DHCP static leases
|
281
|
-
[X] GET /api/v1/dhcp/static\_lease/
|
282
330
|
|
283
331
|
```ruby
|
284
|
-
|
285
|
-
static_leases.index
|
332
|
+
FreeboxApi::Configuration::Dhcp.static_leases(mySession)
|
286
333
|
```
|
287
334
|
|
288
335
|
##### Get a given DHCP static lease
|
289
|
-
[X] GET /api/v1/dhcp/static\_lease/{id}
|
290
336
|
|
291
337
|
```ruby
|
292
|
-
|
338
|
+
FreeboxApi::Configuration::Dhcp::StaticLease.show(mySession, '00:DE:AD:B0:0B:55')
|
339
|
+
```
|
340
|
+
|
341
|
+
or
|
342
|
+
|
343
|
+
```ruby
|
344
|
+
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:DE:AD:B0:0B:55')
|
345
|
+
static_lease.show
|
293
346
|
```
|
294
347
|
|
295
348
|
##### Update DHCP static lease
|
296
|
-
[X] PUT /api/v1/dhcp/static\_lease/{id}
|
297
349
|
|
298
350
|
```ruby
|
299
|
-
|
351
|
+
FreeboxApi::Configuration::Dhcp::StaticLease.update(mySession, {
|
352
|
+
:id => '00:DE:AD:B0:0B:55',
|
353
|
+
:comment => 'Mon PC',
|
354
|
+
})
|
355
|
+
```
|
356
|
+
|
357
|
+
or
|
358
|
+
|
359
|
+
```ruby
|
360
|
+
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:DE:AD:B0:0B:55')
|
361
|
+
static_lease.update({
|
300
362
|
:id => '00:DE:AD:B0:0B:55',
|
301
363
|
:comment => 'Mon PC',
|
302
364
|
})
|
303
365
|
```
|
304
366
|
|
305
367
|
##### Delete a DHCP static lease
|
306
|
-
[X] DELETE /api/v1/dhcp/static\_lease/{id}
|
307
368
|
|
308
369
|
```ruby
|
309
|
-
|
370
|
+
FreeboxApi::Configuration::Dhcp::StaticLease.delete(mySession, '00:DE:AD:B0:0B:55')
|
371
|
+
```
|
372
|
+
|
373
|
+
or
|
374
|
+
|
375
|
+
```ruby
|
376
|
+
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:DE:AD:B0:0B:55')
|
377
|
+
static_lease.delete
|
310
378
|
```
|
311
379
|
|
312
380
|
##### Add a DHCP static lease
|
313
|
-
[X] POST /api/v1/dhcp/static\_lease/
|
314
381
|
|
315
382
|
```ruby
|
383
|
+
FreeboxApi::Configuration::Dhcp::StaticLease.create(mySession, {
|
384
|
+
:ip => '192.168.1.222',
|
385
|
+
:mac => '00:00:00:11:11:11',
|
386
|
+
})
|
387
|
+
```
|
388
|
+
|
389
|
+
or
|
390
|
+
|
391
|
+
```ruby
|
392
|
+
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:00:00:11:11:11')
|
316
393
|
static_lease.create({
|
317
394
|
:ip => '192.168.1.222',
|
318
395
|
:mac => '00:00:00:11:11:11',
|
@@ -320,7 +397,15 @@ static_lease.create({
|
|
320
397
|
```
|
321
398
|
|
322
399
|
##### Get the list of DHCP dynamic leases
|
323
|
-
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
FreeboxApi::Configuration::Dhcp.dynamic_leases(mySession)
|
403
|
+
```
|
404
|
+
|
405
|
+
|
406
|
+
OLD API
|
407
|
+
=======
|
408
|
+
|
324
409
|
|
325
410
|
### Ftp
|
326
411
|
|
data/lib/freebox_api.rb
CHANGED
@@ -2,6 +2,13 @@ module FreeboxApi
|
|
2
2
|
end
|
3
3
|
|
4
4
|
require 'freebox_api/config'
|
5
|
+
|
6
|
+
require 'freebox_api/configuration'
|
7
|
+
require 'freebox_api/configuration/connection'
|
8
|
+
require 'freebox_api/configuration/dhcp'
|
9
|
+
require 'freebox_api/configuration/freeplug'
|
10
|
+
require 'freebox_api/configuration/lan'
|
11
|
+
|
5
12
|
require 'freebox_api/freebox'
|
6
13
|
require 'freebox_api/session'
|
7
14
|
require 'freebox_api/version'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module FreeboxApi
|
2
|
+
|
3
|
+
module Configuration
|
4
|
+
|
5
|
+
module Connection
|
6
|
+
|
7
|
+
def self.getStatus(session)
|
8
|
+
session.http_call('get', '/connection/')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.getConfig(session)
|
12
|
+
session.http_call('get', '/connection/config/')
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.updateConfig(session, value)
|
16
|
+
session.http_call('put', '/connection/config/', value)
|
17
|
+
end
|
18
|
+
|
19
|
+
module IPv6
|
20
|
+
|
21
|
+
def self.getConfig(session)
|
22
|
+
session.http_call('get', '/connection/ipv6/config/')
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.updateConfig(session, value)
|
26
|
+
session.http_call('put', '/connection/ipv6/config/', value)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class DDNS
|
32
|
+
|
33
|
+
def initialize(session, provider)
|
34
|
+
# TODO: validate that provider matches (ovh|dyndns|noip)
|
35
|
+
@session = session
|
36
|
+
@provider = provider
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.getStatus(session, provider)
|
40
|
+
session.http_call('get', "/connection/ddns/#{provider}/status/")
|
41
|
+
end
|
42
|
+
|
43
|
+
def status
|
44
|
+
self.class.getStatus(@session, @provider)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.getConfig(session, provider)
|
48
|
+
session.http_call('get', "/connection/ddns/#{provider}/")
|
49
|
+
end
|
50
|
+
|
51
|
+
def config
|
52
|
+
self.class.getConfig(@session, @provider)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.updateConfig(session, provider, value)
|
56
|
+
@session.http_call('put', "/connection/ddns/#{provider}/", value)
|
57
|
+
end
|
58
|
+
|
59
|
+
def config=(value)
|
60
|
+
self.class.updateConfig(@session, @provider, value)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module FreeboxApi
|
2
|
+
|
3
|
+
module Configuration
|
4
|
+
|
5
|
+
module Dhcp
|
6
|
+
|
7
|
+
def self.getConfig(session)
|
8
|
+
session.http_call('get', '/dhcp/config/')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.updateConfig(session, value)
|
12
|
+
session.http_call('put', '/dhcp/config/')
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.static_leases(session)
|
16
|
+
session.http_call('get', '/dhcp/static_lease/')
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.dynamic_leases(session)
|
20
|
+
session.http_call('get', '/dhcp/dynamic_lease/')
|
21
|
+
end
|
22
|
+
|
23
|
+
class StaticLease
|
24
|
+
|
25
|
+
def initialize(session, id)
|
26
|
+
@session = session
|
27
|
+
@id = id
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.show(session, id)
|
31
|
+
session.http_call('get', "/dhcp/static_lease/#{id}")
|
32
|
+
end
|
33
|
+
|
34
|
+
def show
|
35
|
+
self.class.show(@session, @id)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.update(session, id, value = {})
|
39
|
+
session.http_call('put', "/dhcp/static_lease/#{id}", value)
|
40
|
+
end
|
41
|
+
|
42
|
+
def update(value = {})
|
43
|
+
self.class.update(@session, @id, value)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.delete(session, id)
|
47
|
+
session.http_call('delete', "/dhcp/static_lease/#{id}")
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete
|
51
|
+
self.class.delete(@session, @id)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.create(session, value)
|
55
|
+
session.http_call('post', '/dhcp/static_lease/', value)
|
56
|
+
end
|
57
|
+
|
58
|
+
def create(value)
|
59
|
+
self.class.create(@session, value)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module FreeboxApi
|
2
|
+
|
3
|
+
module Configuration
|
4
|
+
|
5
|
+
class Freeplug
|
6
|
+
|
7
|
+
def initialize(session, id)
|
8
|
+
@session = session
|
9
|
+
@id = id
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.network(session)
|
13
|
+
session.http_call('get', '/freeplug/')
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.show(session, id)
|
17
|
+
session.http_call('get', "/freeplug/#{id}/")
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
self.class.show(@session, @id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.reset(session, id)
|
25
|
+
session.http_call('post', "/freeplug/#{id}/reset/")
|
26
|
+
end
|
27
|
+
|
28
|
+
def reset
|
29
|
+
self.class.reset(@session, @id)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module FreeboxApi
|
2
|
+
|
3
|
+
module Configuration
|
4
|
+
|
5
|
+
module Lan
|
6
|
+
|
7
|
+
def self.getConfig(session)
|
8
|
+
session.http_call('get', '/lan/config/')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.updateConfig(session, value)
|
12
|
+
session.http_call('put', '/lan/config/', value)
|
13
|
+
end
|
14
|
+
|
15
|
+
module Browser
|
16
|
+
|
17
|
+
def self.interfaces(session)
|
18
|
+
session.http_call('get', '/lan/browser/interfaces/')
|
19
|
+
end
|
20
|
+
|
21
|
+
class Interface
|
22
|
+
|
23
|
+
def initialize(session, name)
|
24
|
+
@session = session
|
25
|
+
@name = name
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.getLanHosts(session, name)
|
29
|
+
session.http_call('get', "/lan/browser/#{name}/")
|
30
|
+
end
|
31
|
+
|
32
|
+
def lan_hosts
|
33
|
+
self.class.getLanHosts(@session, @name)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.wol(session, name, params = {})
|
37
|
+
session.http_call('post', "/lan/wol/#{name}/", params)
|
38
|
+
end
|
39
|
+
|
40
|
+
def wol(params = {})
|
41
|
+
self.class.wol(@session, @name, params)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class LanHost
|
47
|
+
|
48
|
+
def initialize(session, interface, hostid)
|
49
|
+
@session = session
|
50
|
+
@interface = interface
|
51
|
+
@hostid = hostid
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.show(session, interface, hostid)
|
55
|
+
session.http_call('get', "/lan/browser/#{interface}/#{hostid}/")
|
56
|
+
end
|
57
|
+
|
58
|
+
def show
|
59
|
+
self.class.show(@session, @interface, @hostid)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.update(session, interface, hostid, value)
|
63
|
+
session.http_call('put', "/lan/browser/#{interface}/#{hostid}/", value)
|
64
|
+
end
|
65
|
+
|
66
|
+
def update(value)
|
67
|
+
self.class.update(@session, @interface, @hostid, value)
|
68
|
+
end
|
69
|
+
|
70
|
+
def wol(password = '')
|
71
|
+
Interface.wol(@session, interface, {
|
72
|
+
:mac => show['l2ident']['id'],
|
73
|
+
:password => password,
|
74
|
+
})
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
data/lib/freebox_api/freebox.rb
CHANGED
@@ -8,7 +8,7 @@ module FreeboxApi
|
|
8
8
|
|
9
9
|
attr_reader :logger
|
10
10
|
|
11
|
-
def initialize(hash = {})
|
11
|
+
def initialize(hash = {}, logger = nil)
|
12
12
|
self[:freebox_ip] = hash[:freebox_ip] ? hash[:freebox_ip] : 'mafreebox.free.fr'
|
13
13
|
self[:freebox_port] = hash[:freebox_port] ? hash[:freebox_port] : '80'
|
14
14
|
@client = RestClient::Resource.new("http://#{self[:freebox_ip]}:#{self[:freebox_port]}")
|
@@ -17,7 +17,7 @@ module FreeboxApi
|
|
17
17
|
self[:api_version] = discover['api_version']
|
18
18
|
self[:api_base_url] = discover['api_base_url']
|
19
19
|
self[:device_type] = discover['device_type']
|
20
|
-
self.logger =
|
20
|
+
self.logger = logger
|
21
21
|
end
|
22
22
|
|
23
23
|
def logger=(logger)
|
data/lib/freebox_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freebox_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Mickaël Canévet
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-10-05 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: json
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rest-client
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -51,6 +56,11 @@ files:
|
|
51
56
|
- lib/freebox_api.rb
|
52
57
|
- lib/freebox_api/application.rb
|
53
58
|
- lib/freebox_api/config.rb
|
59
|
+
- lib/freebox_api/configuration.rb
|
60
|
+
- lib/freebox_api/configuration/connection.rb
|
61
|
+
- lib/freebox_api/configuration/dhcp.rb
|
62
|
+
- lib/freebox_api/configuration/freeplug.rb
|
63
|
+
- lib/freebox_api/configuration/lan.rb
|
54
64
|
- lib/freebox_api/freebox.rb
|
55
65
|
- lib/freebox_api/resources/freeplug.rb
|
56
66
|
- lib/freebox_api/resources/freeplug_network.rb
|
@@ -64,25 +74,26 @@ files:
|
|
64
74
|
homepage: http://github.com/mcanevet/freebox_api
|
65
75
|
licenses:
|
66
76
|
- Apache 2.0
|
67
|
-
metadata: {}
|
68
77
|
post_install_message:
|
69
78
|
rdoc_options: []
|
70
79
|
require_paths:
|
71
80
|
- lib
|
72
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
73
83
|
requirements:
|
74
84
|
- - ! '>='
|
75
85
|
- !ruby/object:Gem::Version
|
76
86
|
version: '0'
|
77
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
78
89
|
requirements:
|
79
90
|
- - ! '>='
|
80
91
|
- !ruby/object:Gem::Version
|
81
92
|
version: '0'
|
82
93
|
requirements: []
|
83
94
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
95
|
+
rubygems_version: 1.8.23
|
85
96
|
signing_key:
|
86
|
-
specification_version:
|
97
|
+
specification_version: 3
|
87
98
|
summary: Ruby bindings for Freebox OS's rest API
|
88
99
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
OWU0Zjg4MjY4Yjk3ZTFkNGZkMjY1MmJmOTM2NzNhNTIwNTU1ZTI0Mg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MzM3ODk1MWMwZjg0NzZiYmUzMWRiY2JjNDZlYmEyMGZlZTc4NDk1YQ==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZWE3ZTk4ODZhYjMxNGEyOTMyOTM3ZjVlY2ZjZGZmMTAwMzUyMThlNTUzOGQz
|
10
|
-
M2QwYTdhMzQwZmNhZTUwNTcyZGJjNjlmZmMzNjg2OGVlZTExMTU3YzU1NWZj
|
11
|
-
OTFmOTY1NjU1OWU1NWZmOGI3ZGJhNDY1OTY5MTQxODY3M2ViZTg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MGI5ZGViOGViYmYxMTZhZTIxYjk3NmExODZhYjQ4NGYyNTZjNjMyYWZkZTY2
|
14
|
-
MTQyMWZkZjRlM2E3NTdmMjgyOGRjZThmY2Y0NjY1OTc0MTA5NTgyYjBhZDYz
|
15
|
-
YzE4MjIyMzJhODY1ZGQ1NzlmZDBlMzc4ODA3ZTM2NTRjY2EwNDE=
|