FreeboxOS¶
FreeboxOS API client
The FreeboxOS Client class inherits the Rest.Client()
.
- class FreeboxOS.Client(opts)¶
- Arguments
opts (
variant()
) – initial options, as an object.
Accepted options are:
http_transaction_factory
A function yielding a transaction. Defaults to
Http.Transaction.factory()
.suffix
String to append to all fully-formed URLs. Defaults to “/”.
Other methods are documented in Rest.Client()
.
Example of usage: listing Freebox Server internal Disk (warning: auth is not included here, see FreeboxOSAuth.Client()
for that).
import QtQuick 2.5
import fbx.application 1.0
import fbx.async 1.0
import fbx.web 1.0
Application {
property var client
ListModel { id: model }
ListView {
anchors.fill: parent
focus: true
model: model
delegate: Text {
color: "white"
text: model.name
}
highlight: Rectangle { radius: 2; color: "dodgerblue" }
}
function client_list(path) {
console.debug("list", path);
return client.fs.ls(path).read().then(function (files) {
model.clear();
for (var i = 0; i < files.length; i++)
model.append(files[i]);
});
}
Component.onCompleted: {
var authz;
...
// authz must be done, then :
client = new FreeboxOS.Client({
suffix: "",
http_transaction_factory: authz.http_transaction_factory
});
client.add("fs");
client.fs.add("ls");
return client_list("/");
}
As FreeboxOS API is a RESTful API, see Rest.Client()
and the FreeboxOS API Documentation.