Dart Toit API

This package provides gRPC functions to access the Toit server through its APIs.

Example

import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:grpc/grpc.dart';
import 'package:toit_api/toit/api/auth.pbgrpc.dart';
/**
 * This application demonstrates logging in with a user-name password.
 */
Future<void> main(List<String> args) async {
  if (args.length != 2) {
    print("Usage: username_pw.dart <user-name> <password>");
    exit(1);
  }
  var username = args[0];
  var password = args[1];
  var channel = ClientChannel('api.toit.io');
  try {
    print("Logging in...");
    var authStub = AuthClient(channel);
    var resp = await authStub
        .login(LoginRequest(username: username, password: password));
    var tokenBytes = resp.accessToken;
    var token = utf8.decode(tokenBytes);
    // The received token must be used in the `options` of all other stubs.
    var options = CallOptions(metadata: {'Authorization': 'Bearer ${token}'});
    print("Logging out...");
    var authorizedClientStub = AuthClient(channel, options: options);
    await authorizedClientStub.logout(LogoutRequest());
  } finally {
    channel.shutdown();
  }
}

See more examples in the example folder.

Resources

The protobuf files for the Toit APIs can be found here. The documentation for the Toit API is here.

Known limitations

This package currently only exposes the generated protobuf APIs. No effort has been made to create a nicer layer around it.

Issues and feedback

Please file issues to send feedback or report a bug. Thank you!.

Libraries

any.pb
any.pbenum
any.pbjson
api.pb
api.pbenum
api.pbjson
app.pb
app.pb
app.pbenum
app.pbenum
app.pbgrpc
app.pbjson
app.pbjson
auth.pb
auth.pbenum
auth.pbgrpc
auth.pbjson
data.pb
data.pb
data.pbenum
data.pbenum
data.pbgrpc
data.pbjson
data.pbjson
descriptor.pb
descriptor.pbenum
descriptor.pbjson
device.pb
device.pb
device.pbenum
device.pbenum
device.pbgrpc
device.pbjson
device.pbjson
doctor.pb
doctor.pbenum
doctor.pbgrpc
doctor.pbjson
duration.pb
duration.pbenum
duration.pbjson
empty.pb
empty.pbenum
empty.pbjson
field_mask.pb
field_mask.pbenum
field_mask.pbjson
hardware.pb
hardware.pbenum
hardware.pbgrpc
hardware.pbjson
job.pb
job.pbenum
job.pbjson
message.pb
message.pbenum
message.pbjson
organization.pb
organization.pb
organization.pbenum
organization.pbenum
organization.pbgrpc
organization.pbjson
organization.pbjson
plugin.pb
plugin.pbenum
plugin.pbjson
program.pb
program.pb
program.pbenum
program.pbenum
program.pbgrpc
program.pbjson
program.pbjson
publish.pb
publish.pbenum
publish.pbgrpc
publish.pbjson
sdk.pb
sdk.pbenum
sdk.pbgrpc
sdk.pbjson
simulator.pb
simulator.pbenum
simulator.pbgrpc
simulator.pbjson
source_context.pb
source_context.pbenum
source_context.pbjson
struct.pb
struct.pbenum
struct.pbjson
subscribe.pb
subscribe.pbenum
subscribe.pbgrpc
subscribe.pbjson
timestamp.pb
timestamp.pbenum
timestamp.pbjson
topic.pb
topic.pbenum
topic.pbjson
type.pb
type.pbenum
type.pbjson
user.pb
user.pbenum
user.pbgrpc
user.pbjson
wrappers.pb
wrappers.pbenum
wrappers.pbjson