api.cloud is about space, not about data. Creating a storage is api.storage.create(), reading and writing it is run(); this resource answers the two questions those two cannot: how much room is left, and how to get more.
The surface
| Call | Does | Costs |
|---|---|---|
| api.cloud.usage() | The whole picture: plan, per-service totals, per-storage ceilings, add-ons. | nothing |
| api.cloud.addons.buy({ service, gb }) | Adds gigabytes, billed monthly in credits. | credits |
const usage = await api.cloud.usage();
console.log(usage.pack); // "free" | "go" | "starter"
console.log(usage.object.usedBytes, "of", usage.object.quotaBytes);
for (const base of usage.nosql.storages) {
console.log(base.label, base.usedBytes, "of", base.quotaBytes, base.overQuota ? "FULL" : "");
}usage = api.cloud.usage()
print(usage["pack"]) # "free" | "go" | "starter"
print(usage["object"]["usedBytes"], "of", usage["object"]["quotaBytes"])
for base in usage["nosql"]["storages"]:
print(base["label"], base["usedBytes"], "of", base["quotaBytes"], "FULL" if base["overQuota"] else "")Three services, counted apart
A NoSQL Database, a SQL Database and an Object Storage each have their own count and their own ceiling. Nothing moves between them: filling one does not take room from another, and the free space of one is not usable by another.
| Plan | NoSQL Database | SQL Database | Object Storage |
|---|---|---|---|
| Free | 50 MB × 1 | 50 MB × 1 | 100 MB × 1 |
| Go | 500 MB × 2 | 500 MB × 2 | 1 GB × 1 |
| Starter | 1 GB × 2 | 1 GB × 2 | 2 GB × 1 |
| Enterprise | 5 GB × 2 | 5 GB × 2 | 10 GB × 1 |
Read as « the ceiling of one storage × how many of them the plan allows ». Details on Quotas and plans.
The ceiling is per storage, and that is the number that refuses a write
Two 500 MB databases are two guarantees of 500 MB, not one of a gigabyte. So a write into a full one is refused while the service total shows space — and the per-storage figure, in usage().<service>.storages[], is the one to show a user.
Hosting and mail take the object storage
What a host keeps online, and what a mailbox keeps, are counted in the account's Object Storage — the same bytes, the same ceiling. usage().object.hostingBytes says how much of it is hosting, which is what makes the total add up when nothing of yours seems to account for it.
What happens when it is full
| Operation | Past the ceiling |
|---|---|
| Writing | Refused — quota_exceeded (403). |
| Reading | Works. |
| Deleting | Works. This is how you get back under. |
That asymmetry is deliberate: a storage you cannot read and cannot empty would be a storage you cannot rescue.
Buying space
const { charged, usage } = await api.cloud.addons.buy({ service: "object", gb: 1 });
// charged: 200 — credits taken now
// usage: the fresh report, ceilings already raisedresult = api.cloud.addons.buy(service="object", gb=1)
result["charged"] # 200 — credits taken now
result["usage"] # the fresh report, ceilings already raisedTwo add-ons only: database, shared by NoSQL and SQL, and object. An add-on is a pool laid on top of the guaranteed ceilings — it fills in where a storage has run out, and it can never eat into another one's guarantee.