feat: usage read module (get_space, get_space_usage, get_traffic) - #43
Merged
Conversation
Implement the three KAS read endpoints for webspace and traffic counters under a new internal/usage package and a "kasapi-cli usage" subcommand tree: - usage space (get_space) lists per-account webspace totals with a computed usage ratio. - usage space-detail [--directory PATH] (get_space_usage) reports per-directory file counts and byte sums. - usage traffic [--year Y --month M] (get_traffic) returns the monthly summary plus per-day rows. Decoding notes: - get_traffic returns a Map keyed by "0" (monthly summary) and "01".."31" (daily rows). The decoder flattens it into a slice in KAS-given order (summary first), so a single TrafficList renders cleanly as JSON/YAML/table. - xsi:nil FTP traffic / hits map to zero. The summary row's Comment field carries any KAS-provided context. - Byte counts and timestamps decode into int64 so 9-digit values survive on 32-bit platforms. Tests cover all three success fixtures end-to-end (decode + Client + Tabular) plus the parameter-shape contracts on the Client (empty directory omits params; --year/--month zero-pads month). Closes #10
This was referenced May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
internal/usagepackage andkasapi-cli usagesubcommand tree wiring the three KAS read endpoints around webspace and traffic counters:usage space(get_space) — per-account webspace totals + usage ratio.usage space-detail [--directory PATH](get_space_usage) — per-directory file counts and byte sums.usage traffic [--year Y --month M](get_traffic) — monthly summary plus per-day rows.get_trafficreturns a Map keyed by0/01..31; the decoder flattens it into a slice (summary first, then days).xsi:nilFTP fields map to zero. Byte counts decode intoint64.Tests run all three success fixtures end-to-end (decode + Client + Tabular) and lock in the parameter-shape contract (empty directory omits params;
--monthis zero-padded).Closes #10