feat: imports resource + analytics.get_aggregate_stats (parity B2)#6
Merged
Conversation
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>
Member
Author
|
Renamed the new Workstream-B2 aggregate-analytics model Names only — model fields and logic unchanged. Covers the Pydantic model + |
…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>
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
Workstream B2 parity for the AWSYS.CO Python SDK. Implements both the sync and async clients (dual-client SDK).
importsresource (client.imports, sync + async) wrapping/api/v1/imports:start(*, provider, access_token, target_namespace=None, scan_only=None)→POSTwith 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), raisesTimeoutErroron overrun. Sync usestime.sleep; async usesasyncio.sleep.analytics.get_aggregate_stats(short_path, *, period=None)(sync + async) →GET /api/v1/links/{short_path}/stats/aggregate. Existingget_statsleft untouched.ImportJob,ImportCounts,AggregateStats,DayClicks,HourClicks,DeviceBreakdown,UTMBreakdown,UpgradeForMore(camelCase aliases, matching existing_CamelModelbase). Tier-gated breakdowns modeled asOptional.importsattached toClientandAsyncClient; new models exported from package surface.pyproject.toml+awsysco/__version__, kept in sync).The backing API routes (
/api/v1/imports*,/api/v1/links/{id}/stats/aggregate) are currently staging-only — production deploy is pending APPROVE. Therefore:MagicMock/AsyncMock); no live HTTP calls are made.Test plan
imports(start snake_case body + parse, get_status/cancel/list,wait_for_completionpending→completed resolution +TimeoutError) andget_aggregate_stats(free-tierupgrade_for_more+ pro-tierdevice_breakdown), both sync and async177 passed, 26 skipped(skips are pre-existing credential-gated live tests)client.imports/await asyncclient.imports,analytics.get_aggregate_stats, model imports,__version__ == 1.3.0🤖 Generated with Claude Code