freebox_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,8 +5,11 @@ WARNING: Work In Progress.
5
5
 
6
6
  Overview
7
7
  --------
8
+
8
9
  This gem contains Freebox OS API bindings for the Ruby language.
9
- I started working on that to use it with https://github.com/mcanevet/puppet-freebox
10
+ I started working on that to use it with https://github.com/mcanevet/puppet-freebox.
11
+
12
+ The official documentation is located here: http://dev.freebox.fr/sdk/os/
10
13
 
11
14
  Building the Freebox object
12
15
  ---------------------------
@@ -52,13 +55,7 @@ auth_request = myFreebox.authorize(token_request)
52
55
  app_token = auth_request['app_token']
53
56
  ```
54
57
 
55
- #### Track authorization progress
56
-
57
- ```ruby
58
- puts myFreebox.track_auth(auth_request['track_id'])
59
- ```
60
-
61
- ### Obtaining a session\_token
58
+ ### Creating the session object
62
59
 
63
60
  ```ruby
64
61
  myApp = {
@@ -82,20 +79,16 @@ mysession = FreeboxApi::Session.new({
82
79
  Reference
83
80
  ---------
84
81
 
85
- ### Connection API
86
-
87
82
  ```ruby
88
- connection = FreeboxApi::Services::Connection.new(mySession)
83
+ config = FreeboxApi::Config.new(mySession)
89
84
  ```
90
85
 
86
+ ### Connection API
87
+
91
88
  #### Connection status
92
89
 
93
90
  ##### Get the current Connection status
94
- [X] GET /api/v1/connection/
95
-
96
- ```ruby
97
- connection.status
98
- ```
91
+ [ ] GET /api/v1/connection/
99
92
 
100
93
  #### Connection configuration
101
94
 
@@ -103,26 +96,41 @@ connection.status
103
96
  [X] GET /api/v1/connection/config/
104
97
 
105
98
  ```ruby
106
- connection.config
99
+ config.show('connection')
107
100
  ```
108
101
 
109
102
  ##### Update the Connection configuration
110
103
  [X] PUT /api/v1/connection/config/
111
104
 
112
105
  ```ruby
113
- connection.config = {
106
+ config.update('connection', {
114
107
  :ping => true,
115
108
  :wol => false,
116
- }
109
+ })
117
110
  ```
118
111
 
119
112
  #### Connection IPv6 configuration
120
113
 
121
114
  ##### Get the current IPv6 Connection configuration
122
- [ ] GET /api/v1/connection/ipv6/config/
115
+ [X] GET /api/v1/connection/ipv6/config/
116
+
117
+ ```ruby
118
+ config.show('ipv6')
119
+ ```
123
120
 
124
121
  ##### Update the IPv6 Connection configuration
125
- [ ] PUT /api/v1/connection/ipv6/config/
122
+ [X] PUT /api/v1/connection/ipv6/config/
123
+
124
+ ```ruby
125
+ config.update('ipv6', {
126
+ :delegations => [
127
+ {
128
+ :prefix => '2a01:e30:d252:a2a2::/64',
129
+ :next_hop => 'fe80::be30:5bff:feb5:fcc7',
130
+ }
131
+ ]
132
+ })
133
+ ```
126
134
 
127
135
  #### Connection DynDNS status
128
136
 
@@ -132,20 +140,48 @@ connection.config = {
132
140
  #### Connection DynDNS configuration
133
141
 
134
142
  ##### Get the config of a DynDNS service
135
- [ ] GET /api/v1/connection/ddns/{provider}/
143
+ [X] GET /api/v1/connection/ddns/{provider}/
144
+
145
+ ```ruby
146
+ config.show('ddns/dyndns')
147
+ ```
136
148
 
137
149
  ##### Set the config of a DynDNS service
138
- [ ] PUT /api/v1/connection/ddns/{provider}/
150
+ [X] PUT /api/v1/connection/ddns/{provider}/
151
+
152
+ ```ruby
153
+ config.update('ddns/dyndns', {
154
+ :enabled => false,
155
+ :user => 'test',
156
+ :password => 'ssss',
157
+ :hostname => 'ttt',
158
+ })
159
+ ```
139
160
 
140
161
  ### Lan
141
162
 
142
163
  #### Lan Config API
143
164
 
144
165
  ##### Get the current Lan configuration
145
- [ ] GET /api/v1/lan/config/
166
+ [X] GET /api/v1/lan/config/
167
+
168
+ ```ruby
169
+ config.show('lan')
170
+ ```
146
171
 
147
172
  ##### Update the current Lan configuration
148
- [ ] PUT /api/v1/lan/config/
173
+ [X] PUT /api/v1/lan/config/
174
+
175
+ ```ruby
176
+ config.update('lan', {
177
+ :mode => 'router',
178
+ :ip => '192.168.69.254',
179
+ :name => 'Freebox de r0ro',
180
+ :name_dns => 'freebox-de-r0ro',
181
+ :name_mdns => 'Freebox-de-r0ro',
182
+ :name_netbios => 'Freebox_de_r0ro',
183
+ })
184
+ ```
149
185
 
150
186
  ### Lan Browser
151
187
 
@@ -193,37 +229,50 @@ lan_hosts.update({
193
229
 
194
230
  #### Freeplug API
195
231
 
232
+ ```ruby
233
+ freeplug_networks = FreeboxApi::Resources::FreeplugNetwork.new(session)
234
+ freeplugs = FreeboxApi::Resources::Freeplug.new(session)
235
+ ```
236
+
196
237
  ##### Get the current Freeplugs networks
197
- [ ] GET /api/v1/freeplug/
238
+ [X] GET /api/v1/freeplug/
239
+
240
+ ```ruby
241
+ freeplug_networks.index
242
+ ```
198
243
 
199
244
  ##### Get a particular Freeplug information
200
- [ ] GET /api/v1/freeplug/{id}/
245
+ [X] GET /api/v1/freeplug/{id}/
246
+
247
+ ```ruby
248
+ freeplugs.show('F4:CA:E5:1D:46:AE')
249
+ ```
201
250
 
202
251
  ##### Reset a Freeplug
203
- [ ] POST /api/v1/freeplug/{id}/reset/
252
+ [X] POST /api/v1/freeplug/{id}/reset/
253
+
254
+ ```ruby
255
+ freeplugs.reset('F4:CA:E5:1D:46:AE')
256
+ ```
204
257
 
205
258
  ### DHCP
206
259
 
207
260
  #### DHCP Configuration API
208
261
 
209
- ```ruby
210
- dhcp = FreeboxApi::Services::DHCP.new(mySession)
211
- ```
212
-
213
262
  ##### Get the current DHCP configuration
214
263
  [X] GET /api/v1/dhcp/config/
215
264
 
216
265
  ```ruby
217
- dhcp.config
266
+ config.show('dhcp')
218
267
  ```
219
268
 
220
269
  ##### Update the current DHCP configuration
221
270
  [X] PUT /api/v1/dhcp/config/
222
271
 
223
272
  ```ruby
224
- dhcp.config = {
273
+ config.update('dhcp', {
225
274
  :enabled => false,
226
- }
275
+ })
227
276
  ```
228
277
 
229
278
  #### DHCP Static Lease API
@@ -278,20 +327,41 @@ static_lease.create({
278
327
  #### Ftp config API
279
328
 
280
329
  ##### Get the current Ftp configuration
281
- [ ] GET /api/v1/ftp/config/
330
+ [X] GET /api/v1/ftp/config/
331
+
332
+ ```ruby
333
+ config.show('ftp')
334
+ ```
282
335
 
283
336
  ##### Update the FTP configuration
284
- [ ] PUT /api/v1/ftp/config/
337
+ [X] PUT /api/v1/ftp/config/
338
+
339
+ ```ruby
340
+ config.update('ftp', {
341
+ :enabled => true
342
+ })
343
+ ```
285
344
 
286
345
  ### NAT
287
346
 
288
347
  #### Dmz Config API
289
348
 
290
349
  ##### Get the current Dmz configuration
291
- [ ] GET /api/v1/fw/dmz/
350
+ [X] GET /api/v1/fw/dmz/
351
+
352
+ ```ruby
353
+ config.show('dmz')
354
+ ```
292
355
 
293
356
  ##### Update the current Dmz configuration
294
- [ ] PUT /api/v1/fw/dmz/
357
+ [X] PUT /api/v1/fw/dmz/
358
+
359
+ ```ruby
360
+ config.update('dmz', {
361
+ :enabled => true,
362
+ :ip => '192.168.1.42',
363
+ })
364
+ ```
295
365
 
296
366
  ### Port Forwarding
297
367
 
@@ -349,10 +419,20 @@ port_forwardings.destroy(3)
349
419
  #### UPnP IGD config API
350
420
 
351
421
  ##### Get the current UPnP IGD configuration
352
- [ ] GET /api/v1/upnpigd/config/
422
+ [X] GET /api/v1/upnpigd/config/
423
+
424
+ ```ruby
425
+ config.show('upnpigd')
426
+ ```
353
427
 
354
428
  ##### Update the UPnP IGD configuration
355
- [ ] PUT /api/v1/upnpigd/config/
429
+ [X] PUT /api/v1/upnpigd/config/
430
+
431
+ ```ruby
432
+ config.update('upnpigd', {
433
+ :enabled => true,
434
+ })
435
+ ```
356
436
 
357
437
  #### UPnP IGD Redirection API
358
438
 
@@ -376,38 +456,78 @@ upnp_redir.destroy('0.0.0.0-53644-udp')
376
456
  #### LCD config API
377
457
 
378
458
  ##### Get the current LCD configuration
379
- [ ] GET /api/v1/lcd/config/
459
+ [X] GET /api/v1/lcd/config/
460
+
461
+ ```ruby
462
+ config.show('lcd')
463
+ ```
380
464
 
381
465
  ##### Update the lcd configuration
382
- [ ] PUT /api/v1/lcd/config/
466
+ [X] PUT /api/v1/lcd/config/
467
+
468
+ ```ruby
469
+ config.update('lcd', {
470
+ :brightness => 50,
471
+ })
472
+ ```
383
473
 
384
474
  ### Network Share
385
475
 
386
476
  #### Samba config API
387
477
 
388
478
  ##### Get the current Samba configuration
389
- [ ] GET /api/v1/netshare/samba/
479
+ [X] GET /api/v1/netshare/samba/
480
+
481
+ ```ruby
482
+ config.show('samba')
483
+ ```
390
484
 
391
485
  ##### Update the Samba configuration
392
- [ ] PUT /api/v1/netshare/samba/
486
+ [X] PUT /api/v1/netshare/samba/
487
+
488
+ ```ruby
489
+ config.update('samba', {
490
+ :print_share_enabled => false,
491
+ })
492
+ ```
393
493
 
394
494
  #### Afp config API
395
495
 
396
496
  ##### Get the current Afp configuration
397
- [ ] GET /api/v1/netshare/afp/
497
+ [X] GET /api/v1/netshare/afp/
498
+
499
+ ```ruby
500
+ config.show('afp')
501
+ ```
398
502
 
399
503
  ##### Update the Afp configuration
400
- [ ] PUT /api/v1/netshare/afp/
504
+ [X] PUT /api/v1/netshare/afp/
505
+
506
+ ```ruby
507
+ config.update('afp', {
508
+ :guest_allow => false,
509
+ })
510
+ ```
401
511
 
402
512
  ### UPnP AV
403
513
 
404
514
  #### UPnP AV config API
405
515
 
406
516
  ##### Get the current UPnP AV configuration
407
- [ ] GET /api/v1/upnpav/config/
517
+ [X] GET /api/v1/upnpav/config/
518
+
519
+ ```ruby
520
+ config.show('upnpav')
521
+ ```
408
522
 
409
523
  ##### Update the UPnP AV configuration
410
- [ ] PUT /api/v1/upnpav/config/
524
+ [X] PUT /api/v1/upnpav/config/
525
+
526
+ ```ruby
527
+ config.update('upnpav', {
528
+ :enabled => false,
529
+ })
530
+ ```
411
531
 
412
532
  ### Switch
413
533
 
@@ -435,10 +555,22 @@ upnp_redir.destroy('0.0.0.0-53644-udp')
435
555
  #### Wi-Fi config API
436
556
 
437
557
  ##### Get the current Wi-Fi configuration
438
- [ ] GET /api/v1/wifi/config/
558
+ [X] GET /api/v1/wifi/config/
559
+
560
+ ```ruby
561
+ config.show('wifi')
562
+ ```
439
563
 
440
564
  ##### Update the Wi-Fi configuration
441
- [ ] PUT /api/v1/wifi/config/
565
+ [X] PUT /api/v1/wifi/config/
566
+
567
+ ```ruby
568
+ config.update('wifi', {
569
+ :ap_params => {
570
+ :ht_mode => 'disabled',
571
+ }
572
+ })
573
+ ```
442
574
 
443
575
  ##### Reset the Wi-Fi configuration
444
576
  [ ] POST /api/v1/wifi/config/reset/
data/freebox_api.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.name = 'freebox_api'
13
13
  gem.require_paths = ["lib"]
14
14
  gem.version = FreeboxApi::VERSION
15
+ gem.license = 'Apache 2.0'
15
16
 
16
17
  gem.add_dependency 'json'
17
18
  gem.add_dependency 'rest-client', '>= 1.6.1'
data/lib/freebox_api.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  module FreeboxApi
2
2
  end
3
3
 
4
+ require 'freebox_api/config'
4
5
  require 'freebox_api/freebox'
5
6
  require 'freebox_api/session'
6
7
  require 'freebox_api/version'
7
8
  resource_files = Dir[File.expand_path("#{File.dirname(__FILE__)}/freebox_api/resources/*.rb", __FILE__)]
8
9
  resource_files.each { |f| require f }
9
- service_files = Dir[File.expand_path("#{File.dirname(__FILE__)}/freebox_api/services/*.rb", __FILE__)]
10
- service_files.each { |f| require f }
@@ -0,0 +1,33 @@
1
+ module FreeboxApi
2
+
3
+ class Config
4
+
5
+ def initialize(session)
6
+ end
7
+
8
+ def url(service)
9
+ case service
10
+ when 'ipv6'
11
+ '/connection/ipv6/config/'
12
+ when /^ddns\//
13
+ "/connection/#{service}/"
14
+ when 'dmz'
15
+ '/fw/dmz/'
16
+ when 'samba', 'afp'
17
+ '/netshare/samba/'
18
+ else
19
+ "/#{service}/config/"
20
+ end
21
+ end
22
+
23
+ def show(service)
24
+ @session.http_call('get', url)
25
+ end
26
+
27
+ def update(service, params = {})
28
+ @session.http_call('put', url, params)
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,29 @@
1
+ module FreeboxApi
2
+
3
+ module Resources
4
+
5
+ class Freeplug
6
+
7
+ def initialize(session)
8
+ @session = session
9
+ end
10
+
11
+ def index
12
+ FreeplugNetwork.new(session).collect { |freeplug_network|
13
+ freeplug_network['members']
14
+ }.flatten
15
+ end
16
+
17
+ def show(id)
18
+ @session.http_call('get', "/freeplug/#{id}/")
19
+ end
20
+
21
+ def reset(id)
22
+ @session.http_call('post', "/freeplug/#{id}/reset/")
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,20 @@
1
+ module FreeboxApi
2
+
3
+ module Resources
4
+
5
+ class FreeplugNetwork
6
+
7
+ def initialize(session)
8
+ @session = session
9
+ end
10
+
11
+ def index
12
+ @session.http_call('get', '/freeplug/')
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
@@ -1,3 +1,3 @@
1
1
  module FreeboxApi
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,86 +1,110 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: freebox_api
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
5
11
  platform: ruby
6
- authors:
7
- - Mickaël Canévet
12
+ authors:
13
+ - "Micka\xC3\xABl Can\xC3\xA9vet"
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2013-09-29 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-09-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
14
21
  name: json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
22
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ! '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rest-client
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: 1.6.1
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
34
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rest-client
35
36
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 13
43
+ segments:
44
+ - 1
45
+ - 6
46
+ - 1
40
47
  version: 1.6.1
48
+ type: :runtime
49
+ version_requirements: *id002
41
50
  description: Helps you to use Freebox OS's API calls from your app
42
51
  email: mickael.canevet@gmail.com
43
52
  executables: []
53
+
44
54
  extensions: []
55
+
45
56
  extra_rdoc_files: []
46
- files:
57
+
58
+ files:
47
59
  - .gitignore
48
60
  - LICENSE
49
61
  - README.md
50
62
  - freebox_api.gemspec
51
63
  - lib/freebox_api.rb
52
64
  - lib/freebox_api/application.rb
65
+ - lib/freebox_api/config.rb
53
66
  - lib/freebox_api/freebox.rb
67
+ - lib/freebox_api/resources/freeplug.rb
68
+ - lib/freebox_api/resources/freeplug_network.rb
54
69
  - lib/freebox_api/resources/interface.rb
55
70
  - lib/freebox_api/resources/lan_host.rb
56
71
  - lib/freebox_api/resources/port_forwarding.rb
57
72
  - lib/freebox_api/resources/static_lease.rb
58
73
  - lib/freebox_api/resources/upnp_redir.rb
59
- - lib/freebox_api/services/connection.rb
60
- - lib/freebox_api/services/dhcp.rb
61
74
  - lib/freebox_api/session.rb
62
75
  - lib/freebox_api/version.rb
63
76
  homepage: http://github.com/mcanevet/freebox_api
64
- licenses: []
65
- metadata: {}
77
+ licenses:
78
+ - Apache 2.0
66
79
  post_install_message:
67
80
  rdoc_options: []
68
- require_paths:
81
+
82
+ require_paths:
69
83
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ! '>='
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- required_rubygems_version: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
80
102
  requirements: []
103
+
81
104
  rubyforge_project:
82
- rubygems_version: 2.1.5
105
+ rubygems_version: 1.8.24
83
106
  signing_key:
84
- specification_version: 4
107
+ specification_version: 3
85
108
  summary: Ruby bindings for Freebox OS's rest API
86
109
  test_files: []
110
+
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTBiM2ZhNGVjYzZkMTEwZGVkOTc3NWMxNzQ0MmVkYWEzMmVhNmZmMQ==
5
- data.tar.gz: !binary |-
6
- M2EyZDUzMGQ2MTVjOTlkZGRiNzczZWRjMTFiMmJjNTRmODJkNjUzOA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- YjUwZTUyN2FmM2I4ZTJjNjI4M2IxOGU0YmFjNzNmZmY0NzIyM2U2YzA5NGJi
10
- OWVmNTIzYmIwYTJhNGQ1ZjU0NmZhZTRiMTc1YjMyZWIwNjYwYzgwZDhlNzFl
11
- MzkwMDA4NzcwZmZiZDQ2OGM2NTQ5MjFhMTBiZmE2MGVjZWU2Njc=
12
- data.tar.gz: !binary |-
13
- MWU1Mzk1ODc1MzA4ODMwZWYwOWViYjlmODViZWIxNGIyZTdhNzUyNDEwMDBj
14
- ZDk5NDgzZDA5OGVmZmU4Y2NhZjE3NmU0ZGZkNTI5MTk1ZGYyMTQyYmMyYTgz
15
- YmQ5NjMyMTk0ZGE5MjhmM2ZjY2FiMDQxZjM4NTJiYzVhOTY1MTA=
@@ -1,27 +0,0 @@
1
- module FreeboxApi
2
-
3
- module Services
4
-
5
- class Connection
6
-
7
- def initialize(session)
8
- @session = session
9
- end
10
-
11
- def status
12
- @session.http_call('get', '/connection/')
13
- end
14
-
15
- def config
16
- @session.http_call('get', '/connection/config/')
17
- end
18
-
19
- def config=(value)
20
- @session.http_call('put', '/connection/config/', value)
21
- end
22
-
23
- end
24
-
25
- end
26
-
27
- end
@@ -1,23 +0,0 @@
1
- module FreeboxApi
2
-
3
- module Services
4
-
5
- class DHCP
6
-
7
- def initialize(session)
8
- @session = session
9
- end
10
-
11
- def config
12
- @session.http_call('get', '/dhcp/config/')
13
- end
14
-
15
- def config=(value)
16
- @session.http_call('put', '/dhcp/config/', value)
17
- end
18
-
19
- end
20
-
21
- end
22
-
23
- end