Skip to content

feat: usage read module (get_space, get_space_usage, get_traffic) - #43

Merged
chmmou merged 1 commit into
mainfrom
feature/usage-read-module
May 4, 2026
Merged

feat: usage read module (get_space, get_space_usage, get_traffic)#43
chmmou merged 1 commit into
mainfrom
feature/usage-read-module

Conversation

@chmmou

@chmmou chmmou commented May 4, 2026

Copy link
Copy Markdown
Owner

Summary

New internal/usage package and kasapi-cli usage subcommand 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_traffic returns a Map keyed by 0 / 01..31; the decoder flattens it into a slice (summary first, then days). xsi:nil FTP fields map to zero. Byte counts decode into int64.

Tests run all three success fixtures end-to-end (decode + Client + Tabular) and lock in the parameter-shape contract (empty directory omits params; --month is zero-padded).

Closes #10

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
@chmmou
chmmou merged commit 042993f into main May 4, 2026
1 check passed
@chmmou
chmmou deleted the feature/usage-read-module branch May 4, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read modules: usage (space, traffic)

1 participant