Tablebox DocsSite 日本語

Managing projects

Manager keeps the PaaS side: projects, keys, links, environment variables, removals, closings, usage and limits. You use it through Console or the management API. It is never on the path of what people exchange, which goes through Relay.

Console

Sign in to Console with GitHub; you see and manage the projects you own, in English or Japanese, on a desktop or a phone. Deleting a project, a key, a link or a variable, removing a participant and closing a range each ask for confirmation first.

Screen Shows Does
Projects Each project's name, state and bytes this month Creates a project, opens one
Project ID, the Relay URL, state, limits Renames, deletes, sets the monthly byte limit and the connection limit
Keys IDs and creation times Creates a key (its secret shown once), deletes one
Links ID, root, patterns, creation time Creates a link, copies its ID, deletes one
Variables Names and update times Sets or replaces a value, deletes a variable
Participants Removals: sub, path, time Removes a sub, optionally within a path
Ranges Closings: path, time Closes a path
Usage Per day of a chosen month: bytes in and out, connected minutes, peak connections; the month's totals against the limits

Paths and patterns are typed relative to the project root, as the API takes them.

The management API

The API is at /v1 on the Manager API address (Reference), with JSON bodies. A call authenticates with a key, Authorization: Basic base64({key id}:{secret}), and acts on that key's project; Console calls it with its session. Errors are HTTP statuses with {"code", "message"}: bad-request (400; message names the field at fault), unauthenticated (401), forbidden (403, a key listing or creating projects), not-found (404, also for a project the caller does not manage) and internal (500).

Call Body Result
GET /projects, POST /projects (Console only) {name} [Project], Project
GET, PATCH, DELETE /projects/{p} {name?, limits?} Project
GET /projects/{p}/keys, POST [{id, created}], {id, secret, created}
DELETE /projects/{p}/keys/{id}
GET /projects/{p}/links, POST {root, publish, subscribe} [Link], Link
DELETE /projects/{p}/links/{id}
GET /projects/{p}/variables [{name, updated}]
PUT /projects/{p}/variables/{name}, DELETE {value}
GET /projects/{p}/removals, POST {sub, path?} [{sub, path, at}], the removal
GET /projects/{p}/closings, POST {path} [{path, at}], the closing
GET /projects/{p}/usage?from={day}&to={day} [{day, bytesIn, bytesOut, seconds, peakConnections}]
TypeScript, Node · manage.ts
// The management API with a project key: a link, a variable, a limit, a removal, a closing and this month's usage.
const auth = `Basic ${btoa(`${process.env.TABLEBOX_KEY_ID}:${process.env.TABLEBOX_KEY_SECRET}`)}`;
const project = `${process.env.TABLEBOX_MANAGER_URL}/v1/projects/${process.env.TABLEBOX_PROJECT}`;

async function call(method: string, path: string, body?: unknown) {
  const reply = await fetch(project + path, {
    method, headers: { authorization: auth, 'content-type': 'application/json' }, body: JSON.stringify(body),
  });
  if (!reply.ok) throw new Error(`${method} ${path}: ${reply.status} ${await reply.text()}`);
  return reply.status === 204 ? undefined : reply.json();
}

const link = await call('POST', '/links', { root: 'rooms/42', publish: ['{id}/**'], subscribe: ['**'] });
console.log(`link ${link.id} for rooms/42`);
await call('PUT', '/variables/STORAGE_BUCKET', { value: 'my-bucket' });
await call('PATCH', '', { limits: { connections: 1_000 } });
await call('POST', '/removals', { sub: 'mallory', path: 'rooms/42' });
await call('POST', '/closings', { path: 'rooms/41' });
const today = new Date().toISOString().slice(0, 10);
console.log(await call('GET', `/usage?from=${today.slice(0, 8)}01&to=${today}`));

Keys, links and variables

Removals and closings

Limits and usage

You set a monthly byte limit (bytes in and out over the UTC calendar month) and a connection limit, each optional. Reaching the byte limit makes the project stopped until the month ends or the limit rises: every session, the programs' included, closes with limit, and new ones are refused. Reaching the connection limit makes it full while the count stays there: new sessions are refused with limit, and open ones continue. A limit can be passed by what Relays carry in one report interval (10 s) plus the time a change takes to reach them.

Usage is counted per project and UTC day: bytes into and out of Relays, connected seconds and peak connections, programs' sessions included, visible within a minute.

While Manager is down

Sessions in progress carry on. Relays admit, remove and limit with the last state they read, also after their own restart, and programs keep running with the last variables they read. Console and the API are unavailable; removals, closings and settings take effect once Manager is back, and the usage counted meanwhile is reported then.