Skip to content

feat: imports resource + analytics.get_aggregate_stats (parity B2)#6

Merged
pbertsch merged 3 commits into
mainfrom
feat/imports-aggregate-resources
Jun 27, 2026
Merged

feat: imports resource + analytics.get_aggregate_stats (parity B2)#6
pbertsch merged 3 commits into
mainfrom
feat/imports-aggregate-resources

Conversation

@pbertsch

Copy link
Copy Markdown
Member

Summary

Workstream B2 parity for the AWSYS.CO Python SDK. Implements both the sync and async clients (dual-client SDK).

  • New imports resource (client.imports, sync + async) wrapping /api/v1/imports:
    • start(*, provider, access_token, target_namespace=None, scan_only=None)POST with snake_case body (None optionals omitted)
    • get_status(job_id)GET /api/v1/imports/{job_id}
    • cancel(job_id)DELETE /api/v1/imports/{job_id}
    • list(*, limit=None)GET /api/v1/imports (unwraps {"jobs": [...]})
    • wait_for_completion(job_id, *, poll_interval=2.0, timeout=120.0) → polls until terminal (completed/partial/failed/cancelled), raises TimeoutError on overrun. Sync uses time.sleep; async uses asyncio.sleep.
  • analytics.get_aggregate_stats(short_path, *, period=None) (sync + async) → GET /api/v1/links/{short_path}/stats/aggregate. Existing get_stats left untouched.
  • Pydantic v2 models: ImportJob, ImportCounts, AggregateStats, DayClicks, HourClicks, DeviceBreakdown, UTMBreakdown, UpgradeForMore (camelCase aliases, matching existing _CamelModel base). Tier-gated breakdowns modeled as Optional.
  • imports attached to Client and AsyncClient; new models exported from package surface.
  • README sections (Analytics aggregate + Imports + Models table).
  • Version bumped 1.2.0 → 1.3.0 (pyproject.toml + awsysco/__version__, kept in sync).

⚠️ Dependency on production

The backing API routes (/api/v1/imports*, /api/v1/links/{id}/stats/aggregate) are currently staging-only — production deploy is pending APPROVE. Therefore:

  • This PR is intentionally a DRAFT — do not merge/publish until the routes are live in prod.
  • All tests are mocked (MagicMock/AsyncMock); no live HTTP calls are made.

Test plan

  • Mocked unit tests pass — imports (start snake_case body + parse, get_status/cancel/list, wait_for_completion pending→completed resolution + TimeoutError) and get_aggregate_stats (free-tier upgrade_for_more + pro-tier device_breakdown), both sync and async
  • Full suite green: 177 passed, 26 skipped (skips are pre-existing credential-gated live tests)
  • Public surface verified: client.imports / await asyncclient.imports, analytics.get_aggregate_stats, model imports, __version__ == 1.3.0
  • Live integration tests — pending prod route deploy (APPROVE)

🤖 Generated with Claude Code

pbertsch and others added 2 commits June 27, 2026 12:45
Adds the Workstream B2 parity surface to the dual sync/async SDK:

- New `imports` resource (sync + async) wrapping /api/v1/imports:
  start (snake_case body), get_status, cancel, list, wait_for_completion
  (polls to a terminal state; sync time.sleep / async asyncio.sleep).
- Extends the analytics resource (sync + async) with get_aggregate_stats
  -> GET /api/v1/links/{short_path}/stats/aggregate.
- Pydantic v2 models: ImportJob, ImportCounts, AggregateStats, DayClicks,
  HourClicks, DeviceBreakdown, UTMBreakdown, UpgradeForMore.
- Attaches `imports` to Client and AsyncClient; exports new models.
- Fully mocked tests (sync + async) for imports + aggregate stats.
- README sections; version bump 1.2.0 -> 1.3.0 (pyproject + __version__).

NOTE: backing routes are staging-only (prod deploy pending APPROVE) —
this PR is a DRAFT and all tests are mocked (no live calls).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…K consistency)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pbertsch

Copy link
Copy Markdown
Member Author

Renamed the new Workstream-B2 aggregate-analytics model AggregateStatsAggregateAnalytics for cross-SDK naming consistency with the TS and Go SDKs (which name the equivalent type AggregateAnalytics).

Names only — model fields and logic unchanged. Covers the Pydantic model + __all__/re-export, both sync & async get_aggregate_stats return types and .model_validate calls, the analytics tests, and the README model table. pytest: 177 passed, 26 skipped (credential-gated live tests stay skipped).

@pbertsch pbertsch marked this pull request as ready for review June 27, 2026 19:05
…fixtures

gitleaks/gitleaks-action@v2 requires a paid GITLEAKS_LICENSE for GitHub orgs
and fails the Detect-secrets job. Use the MIT-licensed gitleaks CLI directly
and allowlist test/example/doc fixtures that hold placeholder tokens.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pbertsch pbertsch merged commit cbf85c4 into main Jun 27, 2026
3 checks passed
@pbertsch pbertsch deleted the feat/imports-aggregate-resources branch June 27, 2026 19:45
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.

1 participant