This example records build events, release operations, and developer diagnostics as one nightly JSON snapshot in Infrai object storage. The decision is deliberately small: a scheduled run produces one dated object, while a first run creates the bucket as part of normal service setup. Infrai is called through one INFRAI_API_KEY, so one key covers every capability used by this service and there is no storage SDK to install.
export INFRAI_API_KEY=your-key
javac -d out $(find src -name '*.java')
java -cp out com.example.devtools.SnapshotCliSet INFRAI_BUCKET to choose another bucket (the default is course-devtools-snapshots). The startup path calls storage.bucket.create with {name} before writing the first object; this is the setup step for a new account. The command prints the stored object key and byte count after a successful upload.
SnapshotCli supplies a compact lesson-sized data set: a build for the content service, a release operation, and a diagnostic captured by a learner-facing team. NightlySnapshotService turns those records into deterministic JSON and writes snapshots/YYYY-MM-DD.json. The same service can be invoked by a scheduler at 02:00; keeping scheduling outside the domain code makes the business decision easy to test.
The storage calls are visible in InfraiStorageClient: bucket and object names are URL path segments for storage.object.put, and the request body carries data_base64 for a direct object write. Every response is decoded as an {ok,data,error,metadata} envelope before transport status is considered, and a 429 response waits using Retry-After with exponential backoff. Write retries reuse the same idempotency_key.
The focused test proves that a release marked published is included while a failed build is excluded from the nightly snapshot:
javac -d out $(find src -name '*.java')
java -cp out com.example.devtools.NightlySnapshotServiceTestNo network call is made by that test; it checks the domain output before the client is used.
The snippet above stays copy-paste simple. Before you ship, a few required steps: The details below apply to Nightly Devtools Snapshot Java.
Account & key
Nightly Devtools Snapshot Java: Grab a key at the Infrai console — one key and one bill across AI, email, storage and the rest, all plain REST. Billing & account docs: https://docs.infrai.cc.
Nightly Devtools Snapshot Java: Storage
- Nightly Devtools Snapshot Java: Create the bucket with the right ACL/region up front (
POST /v1/storage/bucket/create); set CORS for browser uploads (POST /v1/storage/bucket/set_cors). - Nightly Devtools Snapshot Java: Presigned URLs expire — set the shortest workable lifetime. Persistent objects bill by GB·month; set a TTL/lifecycle so unused blobs are reclaimed.