B2 Bucket
Manage one Backblaze B2 bucket via the B2 Native API v4 — sync, create, update, idempotent delete, and get/set event notification rules — with first-class lifecycle rules so restic-pruned hidden file versions are actually deleted.
Gates making a bucket public: create and update now refuse bucketType=allPublic unless allowPublicBucket=true acknowledges it, as a method input or a global argument. Corrects the lifecycle check's error message, which claimed no rules were declared when they had been supplied via --input — swamp does not give pre-flight checks the method's inputs, so the check cannot see them. Documents that Event Notifications needs account-level enablement. Write paths verified end to end against live B2.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| applicationKeyId | string | B2 application key ID (master or scoped). Wire with ${{ vault.get(b2, B2_APPLICATION_KEY_ID) }}. |
| applicationKey | string | B2 application key — supply via vault.get(), never inline. |
| authHost? | string | Override the B2 authorize host (testing only). Defaults to https://api.backblazeb2.com. |
| bucketName | string | Name of the bucket this model manages. B2 bucket names are globally unique and 6-63 characters. |
| bucketId? | string | B2 bucket ID. Optional: when omitted it is resolved from bucketName via b2_list_buckets, which costs one class-C transaction per run. Set it to avoid that call. |
| bucketType? | enum | Desired bucket type. `create` defaults to allPrivate when this is unset — a restic repository must never be allPublic. Deliberately NOT a schema-level default: a default here would make `update` send bucketType on every run, silently flipping an allPublic bucket private for an operator who only meant to set lifecycle rules. |
| lifecycleRules? | array | Desired lifecycle rules. For a restic bucket use [{ fileNamePrefix: "", daysFromUploadingToHiding: null, daysFromHidingToDeleting: 1 }]. |
| corsRules? | array | Desired CORS rules. Omit to leave the bucket's CORS configuration untouched. |
| bucketInfo? | record | Desired user-defined bucket metadata (also carries Cache-Control policies). |
| fileLockEnabled? | boolean | Enable Object Lock on the bucket. Requires the writeBucketRetentions capability. Object Lock cannot be disabled once enabled. |
| allowPublicBucket | boolean | Acknowledge that this bucket may be allPublic. Without it, create and |
| allowUnprunedHiddenVersions | boolean | Set true to acknowledge that this bucket intentionally retains hidden file versions forever, which disables the lifecycle-hidden-version-retention pre-flight check. |
Resources
Live-verification fixes. unprunedPrefixes now reports [""] rather than [] for a bucket with NO lifecycle rules: the old value read as 'nothing is accumulating hidden versions' when in fact every file is, hiding exactly the buckets a consumer queries for. Adds defaultRetentionPeriod so a snapshot can distinguish a 1-day Object Lock window from a 10-year one, aliases a bucket named 'latest' to bucket-latest, and stops bucketInfo/options hard-failing sync on an unexpected value type.
First release. Manages one Backblaze B2 bucket via the Native API v4: sync, create, update, idempotent delete, and event notification rules. Models lifecycle rules precisely and surfaces prunesHiddenVersions, because restic-pruned pack files are billed forever without a daysFromHidingToDeleting rule. Notification-rule signing secrets and custom header values are stripped before any snapshot is written.
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License declared1/1earned
- Verified public repository2/2earned