Repository navigation
feat(reporting): serve reporting subscriptions from one SubscriptionOptions block #1739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
adaba82
feat(reporting): serve reporting subscriptions from one SubscriptionO…
bokelley 7fc664a
fix(decisioning): type the managed principal task parameters
bokelley a4c9b6b
fix(reporting): run write triggers off the request path and bound pla…
bokelley 8495b17
fix(reporting): parse wire instants with 1-6 fractional digits on Pyt…
bokelley d257b16
ci: pin pypa/gh-action-pypi-publish to v1.14.3 for GHSA-5xjx-3w67-w9x9
bokelley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """The principal a reporting subscription belongs to (AdCP 3.3, experimental). | ||
|
|
||
| Kept dependency-free so the reporting runtime, the materializer and the server | ||
| can all name it without importing each other. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import Any | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class PrincipalRef: | ||
| """The identity a reporting subscription belongs to: ``(tenant_id, principal_id)``. | ||
|
|
||
| ``principal_id`` is the seller-resolved, stable identity of the | ||
| authenticated caller (the same value the reporting caller resolver yields | ||
| as ``consumer_id``), never anything read from request content. | ||
| ``tenant_id`` names the tenant on a multi-tenant server and is ``None`` on | ||
| a single-tenant one. One reporting engine serves one tenant: state is keyed | ||
| by ``principal_id``, and the tenant is recorded with it. | ||
|
|
||
| The TypeScript SDK spells it ``PrincipalRef { tenantId, principalId }``. | ||
| """ | ||
|
|
||
| tenant_id: str | None | ||
| principal_id: str | ||
|
|
||
| def __post_init__(self) -> None: | ||
| if not isinstance(self.principal_id, str) or not self.principal_id: | ||
| raise ValueError("PrincipalRef.principal_id must be a non-empty string") | ||
| if self.tenant_id is not None and ( | ||
| not isinstance(self.tenant_id, str) or not self.tenant_id | ||
| ): | ||
| raise ValueError("PrincipalRef.tenant_id must be a non-empty string or None") | ||
|
|
||
| @property | ||
| def subject(self) -> str: | ||
| """The key reporting state and ledger ownership use (``principal_id``).""" | ||
| return self.principal_id | ||
|
|
||
| @classmethod | ||
| def coerce(cls, value: Any, *, tenant_id: str | None = None) -> PrincipalRef: | ||
| """Accept a ``PrincipalRef``, a ``PrincipalIdentity`` or a principal id string.""" | ||
| if isinstance(value, PrincipalRef): | ||
| return value | ||
| if isinstance(value, str): | ||
| return cls(tenant_id, value) | ||
| subject = getattr(value, "subject", None) | ||
| if isinstance(subject, str): | ||
| return cls(getattr(value, "tenant_id", tenant_id), subject) | ||
| raise TypeError("expected a PrincipalRef, a PrincipalIdentity or a principal id") | ||
|
|
||
|
|
||
| __all__ = ["PrincipalRef"] |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.