diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a62e2..22f9953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 0.10.0 (2026-11-16) + +Follows API 1.20.11, as 0.9.1 did. The saved spec has 163 operations and the models are regenerated from it. +No client method, argument or return type changed. Every model a method takes or returns is kept. + +### Removed + +70 models are gone from `faxforagents.models`, which now has 174. No method of `Client` or `AsyncClient` takes or returns them, directly or in a field. +The public document of API 1.20.11 does not define them. They came from the server's own document in 0.2.2 and 0.2.3. +Under 0.x a minor release can break imports, and this one does. Code that imports one of them has to drop the import. Nothing replaces them. + +- The admin console under `/v1/admin`, 43 models: `AbuseReview`, `AbuseReviewCreate`, `AbuseReviewPage`, `AbuseReviewPatch`, `Adjustment`, `AdjustmentApply`, `AdjustmentCreate`, `AdjustmentPage`, `AdminAction`, `AdminBrief`, `AdminDaily`, `AdminDailyPoint`, `AdminJob`, `AdminJobPage`, `AdminOrganization`, `AdminOrganizationDetail`, `AdminOrganizationPage`, `AdminRevenue`, `AdminStats`, `AdminWhoami`, `AnalyticsJourneys`, `AnalyticsOrganization`, `AnalyticsSource`, `AnalyticsSources`, `AnalyticsUsage`, `AnalyticsWebsite`, `AuditEvent`, `AuditEventPage`, `Client`, `ClientList`, `OutboxDiscarded`, `OutboxPage`, `OutboxRow`, `ProviderHealth`, `ProviderList`, `ReconcileResult`, `ReconciliationReport`, `ReleaseResult`, `ReviewAccessAction`, `ReviewAccessCreate`, `ReviewAccessIssued`, `RouteList`, `RouteState`. +- The dashboard sign-in under `/v1/auth`, 17 models: `Accepted`, `MagicLinkRequest`, `Passkey`, `PasskeyList`, `PasskeyLoginVerify`, `PasskeyRegisterVerify`, `Providers`, `Reauth`, `ReviewSignIn`, `Revoked`, `Sent`, `SessionInfo`, `SessionList`, `SessionOut`, `SwitchOrganization`, `UserOut`, `faxforagents__auth__schemas__Me`. +- The OAuth consent calls under `/v1/oauth/authorizations`, 5 models: `OAuthConsent`, `OAuthConsentClient`, `OAuthConsentDecision`, `OAuthConsentOrganization`, `OAuthRedirect`. +- The Stripe and Telnyx receivers under `/webhooks`, 2 models: `TelnyxAck`, `WebhookAck`. +- The server's module-qualified names for `InboxItem`, `InboxItemSummary` and `Me`, 3 models: `faxforagents__api__routes__inbox__InboxItem`, `faxforagents__api__schemas__InboxItem`, `faxforagents__api__schemas__Me`. The plain names stay. + +`faxforagents.models.Client` described an OAuth client in the admin console. `faxforagents.Client`, the client of this package, is not affected. + +`scripts/gen_models.py` now writes a model only for a schema that an operation reaches. The public document is curated by the same rule. +A refresh of the spec that brings one of these schemas back still leaves it out of `models.py`. +`tests/test_removed_models.py` fails when one of the 70 is back, or when the saved spec holds a schema that no operation reaches. + ## 0.9.1 (2026-11-16) Follows API 1.20.11. The saved spec has 163 operations and the models are regenerated from it. @@ -181,7 +204,7 @@ The package metadata links to the pricing page and the dashboard. The README nam ## 0.3.2 (2026-11-10) -`identity.create_api_key` takes `connected_app` on both clients. A key made with `connected_app=True` is bound by the auto-send setting like an OAuth connection. +`identity.create_api_key` takes `connected_app` on both clients. An API key made with `connected_app=True` is bound by the auto-send setting like an OAuth connection. The field is sent only when given, so existing calls send the same body. Needs API 1.12.0. The saved spec follows the public document at API 1.13.2. No operation or schema changed. @@ -205,7 +228,7 @@ Existing model names, fields and optionality are kept. ## 0.2.4 (2026-11-09) -`quotes.create` takes `quality`: standard, fine (the default), superfine or ultra. `Quote` and `FaxJob` carry it. The CLI has `--quality`. Needs API 1.11.0; older servers refuse the field. +`quotes.create` takes `quality`: standard, fine (the default), superfine or ultra. `Quote` and `FaxJob` carry it. The CLI has `--quality`. Needs API 1.11.0. Older servers refuse the field. ## 0.2.3 (2026-11-02) diff --git a/README.md b/README.md index 632d9b9..ad872d9 100644 --- a/README.md +++ b/README.md @@ -78,9 +78,9 @@ The same in async form, with `AsyncClient` and `await` on every call. that follow `next_cursor`. - `documents.create(text=...)`, `markdown=...` or `html=...` renders on the server. HTML prints with scripts off and no network, inline CSS and `data:` images only, at most 2 MiB. -- `documents.upload(path)` runs the whole upload path for a PDF or an image (PNG, JPG, TIFF): the - upload session, the signed PUT with the content type read from the filename, the sha256 check, the - document. An image becomes gray letter pages. +- `documents.upload(path)` runs the whole upload path for a PDF or an image (PNG, JPG, TIFF). It covers + the upload session, the signed PUT with the content type read from the filename, the sha256 check and + the document. An image becomes gray letter pages. - `documents.create_upload(filename=..., size_bytes=...)` needs no `content_type`. The API reads the type from the filename and refuses a filename of another format at once with `unsupported_format`. - `billing.statement()` reads the wallet one line per event, with the balance after each line. @@ -186,9 +186,9 @@ if req.status == "approved": An agent's own API key can never approve. `ffa.policies.evaluate(quote_id=...)` is a dry run that says whether a policy would allow the send. -A key made for a connected app used over stdio, such as the Gemini CLI extension, is created with +An API key for a connected app used over stdio, such as the Gemini CLI extension, is created with `connected_app=True`. The organization's auto-send setting (`ffa.policies.get_auto_send`) then binds it like -an OAuth connection. An agent's key cannot carry the flag. +an OAuth connection. An agent's API key cannot carry the flag. ```python key = ffa.identity.create_api_key("gemini", scopes=["fax:send"], connected_app=True) @@ -315,13 +315,16 @@ ruff check src tests && mypy src sh scripts/truthcheck.sh ``` -`spec/openapi.yaml` follows the public document at API version 1.20.11 and keeps the schemas of the earlier live documents. -The two validation error schemas are the exception. 0.5.0 removed them because the server never sent that shape. +`spec/openapi.yaml` follows the public document at API version 1.20.11. It has the same 163 operations and no schema that document lacks. +It also declares fields a route returns beyond the public schemas, in `InboxItemSummary` and `ExtractionPage`. +0.5.0 removed the two validation error schemas, because the server never sent that shape. 0.6.0 removed two cost fields of an extraction, because the server stopped sending them. 0.8.0 replaced five fields it had declared itself with the public ones, such as `Quote.policy_evaluation`. 0.9.0 leaves `Delivery.webhook_deleted` optional, where the public document requires it. -It also retains earlier public model names and route-documented response additions. -To refresh it, merge the live schemas while preserving existing declarations, then run `uv run python scripts/gen_models.py`. +0.10.0 removed the 70 schemas of earlier server documents that no operation reaches, such as those of the admin console. +`scripts/gen_models.py` writes a model only for a schema an operation reaches, through its paths, a shared response or a field. +If a refresh brings in a schema that no operation reaches, it gets no model and `tests/test_removed_models.py` fails. +To refresh it, merge the public document while preserving existing declarations, then run `uv run python scripts/gen_models.py`. Keep new response fields optional so older payloads and existing callers remain valid. The schema drift test compares every saved schema property with the generated declarations without network access. diff --git a/pyproject.toml b/pyproject.toml index 0d9841f..b761a02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "faxforagents" -version = "0.9.1" +version = "0.10.0" description = "Python client for Fax for Agents: a fax API, a hosted MCP server and SDKs built so AI agents can send and receive faxes." readme = "README.md" requires-python = ">=3.10" diff --git a/scripts/gen_models.py b/scripts/gen_models.py index 5b6c871..832aa16 100644 --- a/scripts/gen_models.py +++ b/scripts/gen_models.py @@ -2,11 +2,17 @@ """Generate ``src/faxforagents/models.py`` (pydantic v2) from ``spec/openapi.yaml``. The spec is the public document of https://github.com/faxforagents/openapi, copied into ``spec/`` so -the build is hermetic. Every ``components.schemas`` entry becomes a ``BaseModel``. Response models -allow extra fields (the API adds fields without a major version). Request models forbid them, as the -server does (``additionalProperties: false``). A field named ``from``, or one that is an attribute of -pydantic's BaseModel such as ``schema``, is ``from_`` or ``schema_`` with the alias ``from`` or -``schema``. Nullable fields are ``X | None``. Enums are ``Literal``. +the build is hermetic. Every ``components.schemas`` entry that an operation reaches becomes a +``BaseModel``. An operation reaches a schema through its parameters, request body and responses, a +shared response in ``components.responses``, or a field of another schema it reaches. A schema that no +operation reaches gets no model, even when a refresh of the spec brings one in from the server's own +document. The public document holds the same set, because its curate.py keeps only what the public +operations reach. 0.10.0 removed 70 such models, among them those of the admin console. + +Response models allow extra fields (the API adds fields without a major version). Request models forbid +them, as the server does (``additionalProperties: false``). A field named ``from``, or one that is an +attribute of pydantic's BaseModel such as ``schema``, is ``from_`` or ``schema_`` with the alias ``from`` +or ``schema``. Nullable fields are ``X | None``. Enums are ``Literal``. Usage:: @@ -140,6 +146,36 @@ def walk(node: Any) -> None: return out +def reached_schemas(spec: dict[str, Any]) -> set[str]: + """The names of the schemas an operation reaches. Only these become models. + + The walk starts at ``paths`` (and ``webhooks``, if the document has any) and follows every + ``$ref`` into ``components``: a shared response leads to its schema, a schema to the schemas of its + fields. A schema nothing points at is not reached, whatever it points at itself. + """ + components = spec.get("components") or {} + seen: set[tuple[str, str]] = set() + + def walk(node: Any) -> None: + if isinstance(node, dict): + ref = node.get("$ref") + if isinstance(ref, str) and ref.startswith("#/components/"): + kind, _, name = ref[len("#/components/") :].partition("/") + if (kind, name) not in seen: + seen.add((kind, name)) + walk((components.get(kind) or {}).get(name)) + for v in node.values(): + walk(v) + elif isinstance(node, list): + for v in node: + walk(v) + + walk(spec.get("paths") or {}) + walk(spec.get("webhooks") or {}) + defined = set(components.get("schemas") or {}) + return {name for kind, name in seen if kind == "schemas" and name in defined} + + def order(schemas: dict[str, Any]) -> list[str]: done: list[str] = [] seen: set[str] = set() @@ -204,7 +240,8 @@ def render_model(name: str, schema: dict[str, Any]) -> str: def render(spec: dict[str, Any]) -> str: - schemas = spec["components"]["schemas"] + reached = reached_schemas(spec) + schemas = {name: schema for name, schema in spec["components"]["schemas"].items() if name in reached} names = order(schemas) body = "\n\n".join(render_model(n, schemas[n]) for n in names) all_names = ", ".join(f'"{n}"' for n in names) @@ -223,6 +260,10 @@ def main() -> int: args = ap.parse_args() spec = yaml.safe_load(SPEC.read_text("utf-8")) text = render(spec) + reached = reached_schemas(spec) + left_out = sorted(set(spec["components"]["schemas"]) - reached) + if left_out: + print(f"no model for the schemas no operation reaches: {', '.join(left_out)}") if args.check: if not OUT.exists() or OUT.read_text("utf-8") != text: print("src/faxforagents/models.py is stale: run scripts/gen_models.py", file=sys.stderr) @@ -230,7 +271,7 @@ def main() -> int: print("models.py is current") return 0 OUT.write_text(text, "utf-8") - print(f"wrote {OUT.relative_to(ROOT)}: {len(spec['components']['schemas'])} models") + print(f"wrote {OUT.relative_to(ROOT)}: {len(reached)} models") return 0 diff --git a/spec/openapi.yaml b/spec/openapi.yaml index db55e33..cb88753 100644 --- a/spec/openapi.yaml +++ b/spec/openapi.yaml @@ -1,5 +1,6 @@ # Fax for Agents API, refreshed from the public document of https://github.com/faxforagents/openapi at API 1.20.11. -# All earlier schemas are kept. Existing SDK routes, model names and serializer additions are retained. +# An operation reaches every schema here. 0.10.0 dropped 70 earlier schemas that no operation reached. +# Existing SDK routes, model names and serializer additions are retained. openapi: 3.1.0 info: title: Fax for Agents API @@ -16792,2148 +16793,3 @@ components: - 'null' description: The approval that authorized this send. It authorizes the order of the same quote too. - AbuseReview: - properties: - id: - type: string - title: Id - org_id: - type: string - title: Org Id - key_id: - anyOf: - - type: string - - type: 'null' - title: Key Id - status: - type: string - enum: - - open - - resolved - title: Status - action: - type: string - enum: - - none - - suspended - title: Action - opened_by: - type: string - title: Opened By - additionalProperties: true - type: object - required: - - id - - org_id - - status - - action - - opened_by - title: AbuseReview - AbuseReviewCreate: - properties: - org_id: - type: string - maxLength: 64 - minLength: 3 - title: Org Id - key_id: - anyOf: - - type: string - maxLength: 64 - - type: 'null' - title: Key Id - reason: - type: string - maxLength: 500 - minLength: 3 - title: Reason - description: 'Why: recorded on the audit row' - suspend: - type: boolean - title: Suspend - description: Suspend sends for the organization or key at once - default: false - additionalProperties: false - type: object - required: - - org_id - - reason - title: AbuseReviewCreate - AbuseReviewPage: - properties: - items: - items: - $ref: '#/components/schemas/AbuseReview' - type: array - title: Items - next_cursor: - anyOf: - - type: string - - type: 'null' - title: Next Cursor - additionalProperties: true - type: object - required: - - items - title: AbuseReviewPage - AbuseReviewPatch: - properties: - action: - type: string - enum: - - suspend - - unsuspend - - resolve - title: Action - reason: - type: string - maxLength: 500 - minLength: 3 - title: Reason - description: 'Why: recorded on the audit row' - additionalProperties: false - type: object - required: - - action - - reason - title: AbuseReviewPatch - Accepted: - properties: - organization: - $ref: '#/components/schemas/OrganizationSummary' - additionalProperties: true - type: object - required: - - organization - title: Accepted - Adjustment: - properties: - id: - type: string - title: Id - org_id: - type: string - title: Org Id - environment: - type: string - title: Environment - direction: - type: string - title: Direction - amount_micro: - type: integer - title: Amount Micro - status: - type: string - title: Status - proposed_by: - type: string - title: Proposed By - applied_by: - anyOf: - - type: string - - type: 'null' - title: Applied By - txn_id: - anyOf: - - type: string - - type: 'null' - title: Txn Id - additionalProperties: true - type: object - required: - - id - - org_id - - environment - - direction - - amount_micro - - status - - proposed_by - title: Adjustment - AdjustmentApply: - properties: - reason: - type: string - maxLength: 500 - minLength: 3 - title: Reason - description: 'Why: recorded on the audit row' - confirm: - type: boolean - title: Confirm - description: Required when the proposer applies their own adjustment - default: false - additionalProperties: false - type: object - required: - - reason - title: AdjustmentApply - AdjustmentCreate: - properties: - org_id: - type: string - maxLength: 64 - minLength: 3 - title: Org Id - environment: - type: string - enum: - - live - - test - title: Environment - default: live - direction: - type: string - enum: - - credit - - debit - title: Direction - amount_micro: - type: integer - maximum: 10000000000.0 - exclusiveMinimum: 0.0 - title: Amount Micro - description: Integer micro-USD; at most 10,000.00 - reason: - type: string - maxLength: 500 - minLength: 3 - title: Reason - description: 'Why: recorded on the audit row' - additionalProperties: false - type: object - required: - - org_id - - direction - - amount_micro - - reason - title: AdjustmentCreate - AdjustmentPage: - properties: - items: - items: - $ref: '#/components/schemas/Adjustment' - type: array - title: Items - next_cursor: - anyOf: - - type: string - - type: 'null' - title: Next Cursor - additionalProperties: true - type: object - required: - - items - title: AdjustmentPage - AdminAction: - properties: - reason: - type: string - maxLength: 500 - minLength: 3 - title: Reason - description: 'Why: recorded on the audit row' - additionalProperties: false - type: object - required: - - reason - title: AdminAction - AdminBrief: - properties: - utc_day: - anyOf: - - type: string - - type: 'null' - title: Utc Day - text: - anyOf: - - type: string - - type: 'null' - title: Text - posted_at: - anyOf: - - type: string - - type: 'null' - title: Posted At - channel: - anyOf: - - type: string - - type: 'null' - title: Channel - status: - anyOf: - - type: string - enum: - - posted - - failed - - gave_up - - type: 'null' - title: Status - attempts: - type: integer - title: Attempts - default: 0 - local_day: - anyOf: - - type: string - - type: 'null' - title: Local Day - attempted_at: - anyOf: - - type: string - - type: 'null' - title: Attempted At - attempt_utc_day: - anyOf: - - type: string - - type: 'null' - title: Attempt Utc Day - retry_after_s: - type: integer - title: Retry After S - default: 600 - waiting_day: - anyOf: - - type: string - - type: 'null' - title: Waiting Day - additionalProperties: true - type: object - title: AdminBrief - AdminDaily: - properties: - metric: - type: string - title: Metric - description: - type: string - title: Description - days: - type: integer - title: Days - items: - items: - $ref: '#/components/schemas/AdminDailyPoint' - type: array - title: Items - additionalProperties: true - type: object - required: - - metric - - description - - days - - items - title: AdminDaily - AdminDailyPoint: - properties: - day: - type: string - title: Day - environment: - type: string - title: Environment - dims: - additionalProperties: true - type: object - title: Dims - value_num: - anyOf: - - type: integer - - type: 'null' - title: Value Num - value_json: - title: Value Json - computed_at: - type: string - title: Computed At - additionalProperties: true - type: object - required: - - day - - environment - - dims - - computed_at - title: AdminDailyPoint - AdminJob: - properties: - id: - type: string - title: Id - org_id: - type: string - title: Org Id - state: - type: string - title: State - route: - type: string - title: Route - environment: - type: string - enum: - - live - - test - title: Environment - age_s: - type: integer - title: Age S - additionalProperties: true - type: object - required: - - id - - org_id - - state - - route - - environment - - age_s - title: AdminJob - AdminJobPage: - properties: - items: - items: - $ref: '#/components/schemas/AdminJob' - type: array - title: Items - next_cursor: - anyOf: - - type: string - - type: 'null' - title: Next Cursor - additionalProperties: true - type: object - required: - - items - title: AdminJobPage - AdminOrganization: - properties: - id: - type: string - title: Id - name: - type: string - title: Name - suspended_at: - anyOf: - - type: string - - type: 'null' - title: Suspended At - internal: - type: boolean - title: Internal - default: false - balances_micro: - additionalProperties: true - type: object - title: Balances Micro - counts: - additionalProperties: - type: integer - type: object - title: Counts - additionalProperties: true - type: object - required: - - id - - name - - balances_micro - - counts - title: AdminOrganization - AdminOrganizationDetail: - properties: - organization: - additionalProperties: true - type: object - title: Organization - members: - items: - additionalProperties: true - type: object - type: array - title: Members - keys: - items: - additionalProperties: true - type: object - type: array - title: Keys - recent_jobs: - items: - additionalProperties: true - type: object - type: array - title: Recent Jobs - ledger: - additionalProperties: true - type: object - title: Ledger - open_reviews: - items: - additionalProperties: true - type: object - type: array - title: Open Reviews - additionalProperties: true - type: object - required: - - organization - - members - - keys - - recent_jobs - - ledger - - open_reviews - title: AdminOrganizationDetail - AdminOrganizationPage: - properties: - items: - items: - $ref: '#/components/schemas/AdminOrganization' - type: array - title: Items - next_cursor: - anyOf: - - type: string - - type: 'null' - title: Next Cursor - additionalProperties: true - type: object - required: - - items - title: AdminOrganizationPage - AdminRevenue: - properties: - computed_at: - type: string - title: Computed At - days: - type: integer - title: Days - captured: - additionalProperties: true - type: object - title: Captured - funded: - additionalProperties: true - type: object - title: Funded - refunded: - additionalProperties: true - type: object - title: Refunded - recurring: - additionalProperties: true - type: object - title: Recurring - balances_micro: - additionalProperties: - additionalProperties: - type: integer - type: object - type: object - title: Balances Micro - by_day: - items: - additionalProperties: true - type: object - type: array - title: By Day - data_age: - additionalProperties: true - type: object - title: Data Age - sources: - items: - additionalProperties: true - type: object - type: array - title: Sources - additionalProperties: true - type: object - required: - - computed_at - - days - - captured - - funded - - refunded - - recurring - - balances_micro - - by_day - - data_age - - sources - title: AdminRevenue - AdminStats: - properties: - computed_at: - type: string - title: Computed At - jobs_by_state: - additionalProperties: - type: integer - type: object - title: Jobs By State - by_environment: - additionalProperties: true - type: object - title: By Environment - live_sends: - additionalProperties: true - type: object - title: Live Sends - needs_you: - additionalProperties: true - type: object - title: Needs You - window: - additionalProperties: true - type: object - title: Window - totals: - additionalProperties: true - type: object - title: Totals - money_live_micro: - additionalProperties: - type: integer - type: object - title: Money Live Micro - additionalProperties: true - type: object - required: - - computed_at - - jobs_by_state - - by_environment - - live_sends - - needs_you - - window - - totals - - money_live_micro - title: AdminStats - AdminWhoami: - properties: - kind: - type: string - enum: - - user - - service - - dev - title: Kind - identity: - type: string - title: Identity - actor: - type: string - title: Actor - read_only: - type: boolean - title: Read Only - additionalProperties: true - type: object - required: - - kind - - identity - - actor - - read_only - title: AdminWhoami - AnalyticsJourneys: - properties: - computed_at: - type: string - title: Computed At - days: - type: integer - title: Days - window: - additionalProperties: - type: string - type: object - title: Window - cohort: - type: integer - title: Cohort - funnel: - items: - additionalProperties: true - type: object - type: array - title: Funnel - leakiest: - anyOf: - - additionalProperties: true - type: object - - type: 'null' - title: Leakiest - doors: - items: - additionalProperties: true - type: object - type: array - title: Doors - topups: - additionalProperties: true - type: object - title: Topups - site: - additionalProperties: true - type: object - title: Site - organizations: - items: - additionalProperties: true - type: object - type: array - title: Organizations - listed: - type: integer - title: Listed - additionalProperties: true - type: object - required: - - computed_at - - days - - window - - cohort - - funnel - - doors - - topups - - site - - organizations - - listed - title: AnalyticsJourneys - AnalyticsOrganization: - properties: - computed_at: - type: string - title: Computed At - days: - type: integer - title: Days - window: - additionalProperties: - type: string - type: object - title: Window - organization: - additionalProperties: true - type: object - title: Organization - steps: - items: - additionalProperties: true - type: object - type: array - title: Steps - members: - items: - additionalProperties: true - type: object - type: array - title: Members - doors: - items: - additionalProperties: true - type: object - type: array - title: Doors - keys: - additionalProperties: true - type: object - title: Keys - jobs: - additionalProperties: true - type: object - title: Jobs - topups: - items: - additionalProperties: true - type: object - type: array - title: Topups - inbound: - additionalProperties: true - type: object - title: Inbound - numbers: - additionalProperties: true - type: object - title: Numbers - actions: - items: - additionalProperties: true - type: object - type: array - title: Actions - recent: - items: - additionalProperties: true - type: object - type: array - title: Recent - usage: - items: - additionalProperties: true - type: object - type: array - title: Usage - tools: - items: - additionalProperties: true - type: object - type: array - title: Tools - additionalProperties: true - type: object - required: - - computed_at - - days - - window - - organization - - steps - - members - - doors - - keys - - jobs - - topups - - inbound - - numbers - - actions - - recent - - usage - - tools - title: AnalyticsOrganization - AnalyticsSource: - properties: - source: - type: string - title: Source - label: - type: string - title: Label - status: - type: string - title: Status - missing: - items: - type: string - type: array - title: Missing - step: - type: integer - title: Step - error: - anyOf: - - type: string - - type: 'null' - title: Error - last_pulled_at: - anyOf: - - type: string - - type: 'null' - title: Last Pulled At - latest_day: - anyOf: - - type: string - - type: 'null' - title: Latest Day - additionalProperties: true - type: object - required: - - source - - label - - status - - missing - - step - title: AnalyticsSource - AnalyticsSources: - properties: - items: - items: - $ref: '#/components/schemas/AnalyticsSource' - type: array - title: Items - pull: - additionalProperties: true - type: object - title: Pull - additionalProperties: true - type: object - required: - - items - - pull - title: AnalyticsSources - AnalyticsUsage: - properties: - computed_at: - type: string - title: Computed At - days: - type: integer - title: Days - window: - additionalProperties: - type: string - type: object - title: Window - org_id: - anyOf: - - type: string - - type: 'null' - title: Org Id - totals: - additionalProperties: true - type: object - title: Totals - by_day: - items: - additionalProperties: true - type: object - type: array - title: By Day - by_surface: - items: - additionalProperties: true - type: object - type: array - title: By Surface - by_family: - items: - additionalProperties: true - type: object - type: array - title: By Family - top_organizations: - items: - additionalProperties: true - type: object - type: array - title: Top Organizations - top_keys: - items: - additionalProperties: true - type: object - type: array - title: Top Keys - tools: - additionalProperties: true - type: object - title: Tools - data_age: - additionalProperties: true - type: object - title: Data Age - additionalProperties: true - type: object - required: - - computed_at - - days - - window - - totals - - by_day - - by_surface - - by_family - - top_organizations - - top_keys - - tools - - data_age - title: AnalyticsUsage - AnalyticsWebsite: - properties: - computed_at: - type: string - title: Computed At - days: - type: integer - title: Days - window: - additionalProperties: - type: string - type: object - title: Window - sources: - items: - $ref: '#/components/schemas/AnalyticsSource' - type: array - title: Sources - search: - additionalProperties: true - type: object - title: Search - traffic: - additionalProperties: true - type: object - title: Traffic - site: - additionalProperties: true - type: object - title: Site - ux: - additionalProperties: true - type: object - title: Ux - bing: - additionalProperties: true - type: object - title: Bing - authority: - additionalProperties: true - type: object - title: Authority - data_age: - additionalProperties: true - type: object - title: Data Age - additionalProperties: true - type: object - required: - - computed_at - - days - - window - - sources - - search - - traffic - - site - - ux - - bing - - authority - - data_age - title: AnalyticsWebsite - AuditEvent: - properties: - id: - type: string - title: Id - org_id: - anyOf: - - type: string - - type: 'null' - title: Org Id - actor: - type: string - title: Actor - action: - type: string - title: Action - resource_type: - type: string - title: Resource Type - resource_id: - anyOf: - - type: string - - type: 'null' - title: Resource Id - created_at: - type: string - title: Created At - additionalProperties: true - type: object - required: - - id - - actor - - action - - resource_type - - created_at - title: AuditEvent - AuditEventPage: - properties: - items: - items: - $ref: '#/components/schemas/AuditEvent' - type: array - title: Items - next_cursor: - anyOf: - - type: string - - type: 'null' - title: Next Cursor - additionalProperties: true - type: object - required: - - items - title: AuditEventPage - Client: - properties: - id: - type: string - title: Id - client_id: - type: string - title: Client Id - kind: - type: string - enum: - - static - - dynamic - - cimd - title: Kind - client_name: - anyOf: - - type: string - - type: 'null' - title: Client Name - client_host: - type: string - title: Client Host - created_at: - type: string - title: Created At - last_used_at: - anyOf: - - type: string - - type: 'null' - title: Last Used At - disabled_at: - anyOf: - - type: string - - type: 'null' - title: Disabled At - disabled_reason: - anyOf: - - type: string - - type: 'null' - title: Disabled Reason - additionalProperties: true - type: object - required: - - id - - client_id - - kind - - client_name - - client_host - - created_at - - last_used_at - - disabled_at - - disabled_reason - title: Client - ClientList: - properties: - items: - items: - $ref: '#/components/schemas/Client' - type: array - title: Items - next_cursor: - anyOf: - - type: string - - type: 'null' - title: Next Cursor - total: - type: integer - minimum: 0.0 - title: Total - additionalProperties: true - type: object - required: - - items - - total - title: ClientList - MagicLinkRequest: - properties: - email: - type: string - format: email - title: Email - next: - anyOf: - - type: string - maxLength: 400 - - type: 'null' - title: Next - description: An in-app path to open after sign-in. - additionalProperties: false - type: object - required: - - email - title: MagicLinkRequest - OAuthConsent: - properties: - id: - type: string - title: Id - client: - $ref: '#/components/schemas/OAuthConsentClient' - redirect_host: - type: string - title: Redirect Host - scopes_requested: - items: - type: string - type: array - title: Scopes Requested - organizations: - items: - $ref: '#/components/schemas/OAuthConsentOrganization' - type: array - title: Organizations - default_environment: - type: string - enum: - - live - - test - title: Default Environment - expires_at: - type: string - title: Expires At - additionalProperties: true - type: object - required: - - id - - client - - redirect_host - - scopes_requested - - organizations - - default_environment - - expires_at - title: OAuthConsent - OAuthConsentClient: - properties: - name: - anyOf: - - type: string - - type: 'null' - title: Name - description: The client's own name, shown as text beside the host. - host: - type: string - title: Host - description: 'The host the person is sending a credential to: the trust anchor.' - loopback: - type: boolean - title: Loopback - description: The redirect goes to the person's own computer (an app they started). - first_seen: - type: boolean - title: First Seen - description: This client was registered during this request. - additionalProperties: true - type: object - required: - - name - - host - - loopback - - first_seen - title: OAuthConsentClient - OAuthConsentDecision: - properties: - org_id: - type: string - maxLength: 64 - minLength: 1 - title: Org Id - environment: - type: string - enum: - - live - - test - title: Environment - default: test - additionalProperties: false - type: object - required: - - org_id - title: OAuthConsentDecision - OAuthConsentOrganization: - properties: - id: - type: string - title: Id - name: - type: string - title: Name - role: - type: string - title: Role - scopes: - items: - type: string - type: array - title: Scopes - description: What the grant would carry for this organization and role. - additionalProperties: true - type: object - required: - - id - - name - - role - - scopes - title: OAuthConsentOrganization - OAuthRedirect: - properties: - redirect_to: - type: string - title: Redirect To - description: 'Where the browser goes next: the client''s registered redirect URI.' - additionalProperties: true - type: object - required: - - redirect_to - title: OAuthRedirect - OutboxDiscarded: - properties: - id: - type: string - title: Id - discarded: - type: boolean - title: Discarded - additionalProperties: true - type: object - required: - - id - - discarded - title: OutboxDiscarded - OutboxPage: - properties: - items: - items: - $ref: '#/components/schemas/OutboxRow' - type: array - title: Items - next_cursor: - anyOf: - - type: string - - type: 'null' - title: Next Cursor - additionalProperties: true - type: object - required: - - items - title: OutboxPage - OutboxRow: - properties: - id: - type: string - title: Id - kind: - type: string - title: Kind - status: - type: string - enum: - - queued - - running - - done - - failed - - dead - title: Status - title: - anyOf: - - type: string - - type: 'null' - title: Title - error: - anyOf: - - type: string - - type: 'null' - title: Error - attempts: - type: integer - title: Attempts - max_attempts: - type: integer - title: Max Attempts - org_id: - anyOf: - - type: string - - type: 'null' - title: Org Id - created_at: - type: string - title: Created At - finished_at: - anyOf: - - type: string - - type: 'null' - title: Finished At - age_s: - type: integer - title: Age S - additionalProperties: true - type: object - required: - - id - - kind - - status - - attempts - - max_attempts - - created_at - - age_s - title: OutboxRow - Passkey: - properties: - id: - type: string - title: Id - label: - anyOf: - - type: string - - type: 'null' - title: Label - aaguid: - anyOf: - - type: string - - type: 'null' - title: Aaguid - transports: - anyOf: - - items: - type: string - type: array - - type: 'null' - title: Transports - backup_eligible: - type: boolean - title: Backup Eligible - created_at: - type: string - title: Created At - last_used_at: - anyOf: - - type: string - - type: 'null' - title: Last Used At - additionalProperties: true - type: object - required: - - id - - label - - aaguid - - transports - - backup_eligible - - created_at - - last_used_at - title: Passkey - PasskeyList: - properties: - items: - items: - $ref: '#/components/schemas/Passkey' - type: array - title: Items - additionalProperties: true - type: object - required: - - items - title: PasskeyList - PasskeyLoginVerify: - properties: - credential: - additionalProperties: true - type: object - title: Credential - additionalProperties: false - type: object - required: - - credential - title: PasskeyLoginVerify - PasskeyRegisterVerify: - properties: - credential: - additionalProperties: true - type: object - title: Credential - label: - anyOf: - - type: string - maxLength: 80 - - type: 'null' - title: Label - additionalProperties: false - type: object - required: - - credential - title: PasskeyRegisterVerify - ProviderHealth: - properties: - name: - type: string - title: Name - configured: - type: boolean - title: Configured - serves: - items: - type: string - type: array - title: Serves - default: [] - circuit: - type: string - title: Circuit - routes_paused: - items: - type: string - type: array - title: Routes Paused - breakers: - items: - additionalProperties: true - type: object - type: array - title: Breakers - default: [] - last_success_at: - anyOf: - - type: string - - type: 'null' - title: Last Success At - last_failure_at: - anyOf: - - type: string - - type: 'null' - title: Last Failure At - concurrency_in_use: - type: integer - title: Concurrency In Use - additionalProperties: true - type: object - required: - - name - - configured - - circuit - - routes_paused - - concurrency_in_use - title: ProviderHealth - ProviderList: - properties: - items: - items: - $ref: '#/components/schemas/ProviderHealth' - type: array - title: Items - additionalProperties: true - type: object - required: - - items - title: ProviderList - Providers: - properties: - magic_link: - type: boolean - title: Magic Link - default: true - passkeys: - type: boolean - title: Passkeys - default: true - github: - type: boolean - title: Github - google: - type: boolean - title: Google - additionalProperties: true - type: object - required: - - github - - google - title: Providers - Reauth: - properties: - method: - type: string - enum: - - passkey - - magic_link - title: Method - credential: - anyOf: - - additionalProperties: true - type: object - - type: 'null' - title: Credential - additionalProperties: false - type: object - required: - - method - title: Reauth - ReconcileResult: - properties: - outcome: - type: string - enum: - - no_provider_ref - - skipped - - poll_failed - - finalized - - retry_scheduled - - unknown - - pending - title: Outcome - job: - $ref: '#/components/schemas/AdminJob' - additionalProperties: true - type: object - required: - - outcome - - job - title: ReconcileResult - ReconciliationReport: - properties: - report: - anyOf: - - additionalProperties: true - type: object - - type: 'null' - title: Report - last_day: - anyOf: - - type: string - - type: 'null' - title: Last Day - additionalProperties: true - type: object - required: - - report - - last_day - title: ReconciliationReport - ReleaseResult: - properties: - settlement: - additionalProperties: true - type: object - title: Settlement - job: - $ref: '#/components/schemas/AdminJob' - additionalProperties: true - type: object - required: - - settlement - - job - title: ReleaseResult - ReviewAccessAction: - properties: - reason: - type: string - maxLength: 500 - minLength: 3 - title: Reason - description: 'Why: recorded on the audit row' - additionalProperties: false - type: object - required: - - reason - title: ReviewAccessAction - ReviewAccessCreate: - properties: - reason: - type: string - maxLength: 500 - minLength: 3 - title: Reason - description: 'Why: recorded on the audit row' - email: - type: string - format: email - title: Email - label: - type: string - maxLength: 120 - minLength: 1 - title: Label - default: Directory review - ttl_days: - type: integer - maximum: 90.0 - minimum: 1.0 - title: Ttl Days - default: 30 - additionalProperties: false - type: object - required: - - reason - - email - title: ReviewAccessCreate - ReviewAccessIssued: - properties: - id: - type: string - title: Id - email: - type: string - title: Email - label: - type: string - title: Label - code: - type: string - title: Code - expires_at: - type: string - title: Expires At - additionalProperties: true - type: object - required: - - id - - email - - label - - code - - expires_at - title: ReviewAccessIssued - ReviewSignIn: - properties: - email: - type: string - format: email - title: Email - code: - type: string - maxLength: 256 - minLength: 1 - format: password - title: Code - writeOnly: true - additionalProperties: false - type: object - required: - - email - - code - title: ReviewSignIn - Revoked: - properties: - revoked: - type: integer - title: Revoked - additionalProperties: true - type: object - required: - - revoked - title: Revoked - RouteList: - properties: - items: - items: - $ref: '#/components/schemas/RouteState' - type: array - title: Items - additionalProperties: true - type: object - required: - - items - title: RouteList - RouteState: - properties: - route: - type: string - title: Route - status: - type: string - enum: - - paused - - open - - breaker_open - title: Status - reason: - anyOf: - - type: string - - type: 'null' - title: Reason - actor: - type: string - title: Actor - updated_at: - type: string - title: Updated At - paused_at: - anyOf: - - type: string - - type: 'null' - title: Paused At - open_until: - anyOf: - - type: string - - type: 'null' - title: Open Until - additionalProperties: true - type: object - required: - - route - - status - - actor - - updated_at - title: RouteState - Sent: - properties: - sent: - type: boolean - title: Sent - message: - type: string - title: Message - additionalProperties: true - type: object - required: - - sent - - message - title: Sent - SessionInfo: - properties: - id: - type: string - title: Id - auth_method: - type: string - title: Auth Method - authenticated_at: - type: string - title: Authenticated At - fresh_until: - type: string - title: Fresh Until - fresh: - type: boolean - title: Fresh - expires_at: - type: string - title: Expires At - additionalProperties: true - type: object - required: - - id - - auth_method - - authenticated_at - - fresh_until - - fresh - - expires_at - title: SessionInfo - SessionList: - properties: - items: - items: - $ref: '#/components/schemas/SessionOut' - type: array - title: Items - additionalProperties: true - type: object - required: - - items - title: SessionList - SessionOut: - properties: - id: - type: string - title: Id - current: - type: boolean - title: Current - auth_method: - type: string - title: Auth Method - ip: - anyOf: - - type: string - - type: 'null' - title: Ip - user_agent: - anyOf: - - type: string - - type: 'null' - title: User Agent - created_at: - type: string - title: Created At - authenticated_at: - type: string - title: Authenticated At - last_seen_at: - type: string - title: Last Seen At - expires_at: - type: string - title: Expires At - additionalProperties: true - type: object - required: - - id - - current - - auth_method - - ip - - user_agent - - created_at - - authenticated_at - - last_seen_at - - expires_at - title: SessionOut - SwitchOrganization: - properties: - org_id: - type: string - title: Org Id - additionalProperties: false - type: object - required: - - org_id - title: SwitchOrganization - TelnyxAck: - properties: - received: - type: boolean - title: Received - outcome: - type: string - title: Outcome - event_id: - anyOf: - - type: string - - type: 'null' - title: Event Id - additionalProperties: true - type: object - required: - - received - - outcome - title: TelnyxAck - UserOut: - properties: - id: - type: string - title: Id - email: - type: string - title: Email - name: - anyOf: - - type: string - - type: 'null' - title: Name - email_verified: - type: boolean - title: Email Verified - created_at: - type: string - title: Created At - last_login_at: - anyOf: - - type: string - - type: 'null' - title: Last Login At - additionalProperties: true - type: object - required: - - id - - email - - name - - email_verified - - created_at - - last_login_at - title: UserOut - WebhookAck: - properties: - received: - type: boolean - title: Received - default: true - outcome: - type: string - title: Outcome - additionalProperties: true - type: object - required: - - outcome - title: WebhookAck - faxforagents__api__routes__inbox__InboxItem: - properties: - id: - type: string - title: Id - from: - anyOf: - - type: string - - type: 'null' - title: From - to: - type: string - title: To - pages: - type: integer - title: Pages - status: - type: string - title: Status - document_id: - anyOf: - - type: string - - type: 'null' - title: Document Id - received_at: - type: string - title: Received At - amount_micro: - type: integer - title: Amount Micro - default: 0 - note: - anyOf: - - type: string - - type: 'null' - title: Note - environment: - type: string - enum: - - live - - test - title: Environment - default: live - number_id: - anyOf: - - type: string - - type: 'null' - title: Number Id - project_id: - anyOf: - - type: string - - type: 'null' - title: Project Id - partial_content: - type: boolean - title: Partial Content - default: false - media_status: - type: string - title: Media Status - default: stored - duration_secs: - anyOf: - - type: integer - - type: 'null' - title: Duration Secs - provider: - type: string - title: Provider - default: '' - read_at: - anyOf: - - type: string - - type: 'null' - title: Read At - expires_at: - anyOf: - - type: string - - type: 'null' - title: Expires At - additionalProperties: true - type: object - required: - - id - - to - - pages - - status - - document_id - - received_at - title: InboxItem - faxforagents__api__schemas__InboxItem: - properties: - id: - type: string - title: Id - from: - anyOf: - - type: string - - type: 'null' - title: From - to: - type: string - title: To - pages: - type: integer - title: Pages - status: - type: string - title: Status - document_id: - anyOf: - - type: string - - type: 'null' - title: Document Id - received_at: - type: string - title: Received At - amount_micro: - type: integer - title: Amount Micro - default: 0 - note: - anyOf: - - type: string - - type: 'null' - title: Note - additionalProperties: true - type: object - required: - - id - - to - - pages - - status - - document_id - - received_at - title: InboxItem - faxforagents__api__schemas__Me: - properties: - org_id: - type: string - title: Org Id - project_id: - type: string - title: Project Id - key_id: - type: string - title: Key Id - key_prefix: - type: string - title: Key Prefix - environment: - type: string - enum: - - live - - test - title: Environment - scopes: - items: - type: string - type: array - title: Scopes - actor: - type: string - title: Actor - additionalProperties: true - type: object - required: - - org_id - - project_id - - key_id - - key_prefix - - environment - - scopes - - actor - title: Me - faxforagents__auth__schemas__Me: - properties: - user: - $ref: '#/components/schemas/UserOut' - organization: - anyOf: - - $ref: '#/components/schemas/OrganizationSummary' - - type: 'null' - organizations: - items: - $ref: '#/components/schemas/OrganizationSummary' - type: array - title: Organizations - session: - $ref: '#/components/schemas/SessionInfo' - csrf_token: - type: string - title: Csrf Token - passkeys: - type: integer - title: Passkeys - providers: - $ref: '#/components/schemas/Providers' - additionalProperties: true - type: object - required: - - user - - organization - - organizations - - session - - csrf_token - - passkeys - - providers - title: Me diff --git a/src/faxforagents/__init__.py b/src/faxforagents/__init__.py index 4c506c4..b83fedd 100644 --- a/src/faxforagents/__init__.py +++ b/src/faxforagents/__init__.py @@ -18,7 +18,7 @@ from __future__ import annotations -__version__ = "0.9.1" +__version__ = "0.10.0" from faxforagents._http import ORDER_TOKEN_HEADER from faxforagents.async_client import AsyncClient diff --git a/src/faxforagents/models.py b/src/faxforagents/models.py index 390be51..e851579 100644 --- a/src/faxforagents/models.py +++ b/src/faxforagents/models.py @@ -20,175 +20,6 @@ class _Request(BaseModel): model_config = ConfigDict(extra="forbid", populate_by_name=True) -class AbuseReview(_Response): - id: str - org_id: str - key_id: str | None = None - status: Literal["open", "resolved"] - action: Literal["none", "suspended"] - opened_by: str - - -class AbuseReviewCreate(_Request): - org_id: str - key_id: str | None = None - reason: str = Field(..., description="Why: recorded on the audit row") - suspend: bool = Field(False, description="Suspend sends for the organization or key at once") - - -class AbuseReviewPage(_Response): - items: list[AbuseReview] - next_cursor: str | None = None - - -class AbuseReviewPatch(_Request): - action: Literal["suspend", "unsuspend", "resolve"] - reason: str = Field(..., description="Why: recorded on the audit row") - - -class OrganizationSummary(_Response): - id: str - name: str - role: Literal["owner", "admin", "member", "viewer"] - suspended_at: str | None = Field(None, description="Set while a review has paused sending for the whole organization. A send answers `account_suspended` until it is cleared. Reads keep working.") - - -class Accepted(_Response): - organization: OrganizationSummary - - -class Adjustment(_Response): - id: str - org_id: str - environment: str - direction: str - amount_micro: int - status: str - proposed_by: str - applied_by: str | None = None - txn_id: str | None = None - - -class AdjustmentApply(_Request): - reason: str = Field(..., description="Why: recorded on the audit row") - confirm: bool = Field(False, description="Required when the proposer applies their own adjustment") - - -class AdjustmentCreate(_Request): - org_id: str - environment: Literal["live", "test"] = "live" - direction: Literal["credit", "debit"] - amount_micro: int = Field(..., description="Integer micro-USD; at most 10,000.00") - reason: str = Field(..., description="Why: recorded on the audit row") - - -class AdjustmentPage(_Response): - items: list[Adjustment] - next_cursor: str | None = None - - -class AdminAction(_Request): - reason: str = Field(..., description="Why: recorded on the audit row") - - -class AdminBrief(_Response): - utc_day: str | None = None - text: str | None = None - posted_at: str | None = None - channel: str | None = None - status: Literal["posted", "failed", "gave_up"] | None = None - attempts: int = 0 - local_day: str | None = None - attempted_at: str | None = None - attempt_utc_day: str | None = None - retry_after_s: int = 600 - waiting_day: str | None = None - - -class AdminDailyPoint(_Response): - day: str - environment: str - dims: dict[str, Any] - value_num: int | None = None - value_json: Any | None = None - computed_at: str - - -class AdminDaily(_Response): - metric: str - description: str - days: int - items: list[AdminDailyPoint] - - -class AdminJob(_Response): - id: str - org_id: str - state: str - route: str - environment: Literal["live", "test"] - age_s: int - - -class AdminJobPage(_Response): - items: list[AdminJob] - next_cursor: str | None = None - - -class AdminOrganization(_Response): - id: str - name: str - suspended_at: str | None = None - internal: bool = False - balances_micro: dict[str, Any] - counts: dict[str, int] - - -class AdminOrganizationDetail(_Response): - organization: dict[str, Any] - members: list[dict[str, Any]] - keys: list[dict[str, Any]] - recent_jobs: list[dict[str, Any]] - ledger: dict[str, Any] - open_reviews: list[dict[str, Any]] - - -class AdminOrganizationPage(_Response): - items: list[AdminOrganization] - next_cursor: str | None = None - - -class AdminRevenue(_Response): - computed_at: str - days: int - captured: dict[str, Any] - funded: dict[str, Any] - refunded: dict[str, Any] - recurring: dict[str, Any] - balances_micro: dict[str, dict[str, int]] - by_day: list[dict[str, Any]] - data_age: dict[str, Any] - sources: list[dict[str, Any]] - - -class AdminStats(_Response): - computed_at: str - jobs_by_state: dict[str, int] - by_environment: dict[str, Any] - live_sends: dict[str, Any] - needs_you: dict[str, Any] - window: dict[str, Any] - totals: dict[str, Any] - money_live_micro: dict[str, int] - - -class AdminWhoami(_Response): - kind: Literal["user", "service", "dev"] - identity: str - actor: str - read_only: bool - - class ApiKey(_Response): id: str label: str @@ -284,84 +115,6 @@ class AlreadyAllowed(_Response): prefixes: list[str] = Field(..., description="The listed prefixes this number's route carries.") -class AnalyticsJourneys(_Response): - computed_at: str - days: int - window: dict[str, str] - cohort: int - funnel: list[dict[str, Any]] - leakiest: dict[str, Any] | None = None - doors: list[dict[str, Any]] - topups: dict[str, Any] - site: dict[str, Any] - organizations: list[dict[str, Any]] - listed: int - - -class AnalyticsOrganization(_Response): - computed_at: str - days: int - window: dict[str, str] - organization: dict[str, Any] - steps: list[dict[str, Any]] - members: list[dict[str, Any]] - doors: list[dict[str, Any]] - keys: dict[str, Any] - jobs: dict[str, Any] - topups: list[dict[str, Any]] - inbound: dict[str, Any] - numbers: dict[str, Any] - actions: list[dict[str, Any]] - recent: list[dict[str, Any]] - usage: list[dict[str, Any]] - tools: list[dict[str, Any]] - - -class AnalyticsSource(_Response): - source: str - label: str - status: str - missing: list[str] - step: int - error: str | None = None - last_pulled_at: str | None = None - latest_day: str | None = None - - -class AnalyticsSources(_Response): - items: list[AnalyticsSource] - pull: dict[str, Any] - - -class AnalyticsUsage(_Response): - computed_at: str - days: int - window: dict[str, str] - org_id: str | None = None - totals: dict[str, Any] - by_day: list[dict[str, Any]] - by_surface: list[dict[str, Any]] - by_family: list[dict[str, Any]] - top_organizations: list[dict[str, Any]] - top_keys: list[dict[str, Any]] - tools: dict[str, Any] - data_age: dict[str, Any] - - -class AnalyticsWebsite(_Response): - computed_at: str - days: int - window: dict[str, str] - sources: list[AnalyticsSource] - search: dict[str, Any] - traffic: dict[str, Any] - site: dict[str, Any] - ux: dict[str, Any] - bing: dict[str, Any] - authority: dict[str, Any] - data_age: dict[str, Any] - - class ApiKeyCreate(_Request): label: str environment: Literal["live", "test"] = "test" @@ -455,21 +208,6 @@ class AttemptPage(_Response): items: list[Attempt] -class AuditEvent(_Response): - id: str - org_id: str | None = None - actor: str - action: str - resource_type: str - resource_id: str | None = None - created_at: str - - -class AuditEventPage(_Response): - items: list[AuditEvent] - next_cursor: str | None = None - - class AutoSendSetting(_Response): """The organization's auto-send setting for one environment: Settings, Connected apps, "Let connected apps send without asking". Stored as the managed policy ``policy_id`` (docs/APPROVALS.md).""" @@ -611,24 +349,6 @@ class ClassificationCreate(_Request): strong_model_if_below: float = 0.75 -class Client(_Response): - id: str - client_id: str - kind: Literal["static", "dynamic", "cimd"] - client_name: str | None - client_host: str - created_at: str - last_used_at: str | None - disabled_at: str | None - disabled_reason: str | None - - -class ClientList(_Response): - items: list[Client] - next_cursor: str | None = None - total: int - - class Correction(_Response): id: str extraction_id: str @@ -1201,11 +921,6 @@ class LedgerPage(_Response): next_cursor: str | None = None -class MagicLinkRequest(_Request): - email: str - next: str | None = Field(None, description="An in-app path to open after sign-in.") - - class Me(_Response): org_id: str project_id: str @@ -1298,39 +1013,6 @@ class NumberUpdate(_Request): email_pdf: bool | None = Field(None, description="Attach the PDF of each received fax to the notice mail. The mail goes to the verified address of an owner of the organization and to no other address. A PDF over 15 MiB is not attached. It needs the scope number:buy. An agent, an OAuth connection and a connected app are refused.") -class OAuthConsentClient(_Response): - name: str | None = Field(..., description="The client's own name, shown as text beside the host.") - host: str = Field(..., description="The host the person is sending a credential to: the trust anchor.") - loopback: bool = Field(..., description="The redirect goes to the person's own computer (an app they started).") - first_seen: bool = Field(..., description="This client was registered during this request.") - - -class OAuthConsentOrganization(_Response): - id: str - name: str - role: str - scopes: list[str] = Field(..., description="What the grant would carry for this organization and role.") - - -class OAuthConsent(_Response): - id: str - client: OAuthConsentClient - redirect_host: str - scopes_requested: list[str] - organizations: list[OAuthConsentOrganization] - default_environment: Literal["live", "test"] - expires_at: str - - -class OAuthConsentDecision(_Request): - org_id: str - environment: Literal["live", "test"] = "test" - - -class OAuthRedirect(_Response): - redirect_to: str = Field(..., description="Where the browser goes next: the client's registered redirect URI.") - - class OneTimeAttempts(_Response): """The tries of an order's fax while it is still going out. A busy line or one that does not answer is dialed again, up to ``max`` tries in all, about ``retry_delay_seconds`` apart. The field ``last_failure_code`` says why the last finished try did not get through. It is null when no try has ended.""" @@ -1579,6 +1261,13 @@ class Organization(_Response): members: int +class OrganizationSummary(_Response): + id: str + name: str + role: Literal["owner", "admin", "member", "viewer"] + suspended_at: str | None = Field(None, description="Set while a review has paused sending for the whole organization. A send answers `account_suspended` until it is cleared. Reads keep working.") + + class OrganizationList(_Response): items: list[OrganizationSummary] @@ -1587,53 +1276,6 @@ class OrganizationPatch(_Request): name: str -class OutboxDiscarded(_Response): - id: str - discarded: bool - - -class OutboxRow(_Response): - id: str - kind: str - status: Literal["queued", "running", "done", "failed", "dead"] - title: str | None = None - error: str | None = None - attempts: int - max_attempts: int - org_id: str | None = None - created_at: str - finished_at: str | None = None - age_s: int - - -class OutboxPage(_Response): - items: list[OutboxRow] - next_cursor: str | None = None - - -class Passkey(_Response): - id: str - label: str | None - aaguid: str | None - transports: list[str] | None - backup_eligible: bool - created_at: str - last_used_at: str | None - - -class PasskeyList(_Response): - items: list[Passkey] - - -class PasskeyLoginVerify(_Request): - credential: dict[str, Any] - - -class PasskeyRegisterVerify(_Request): - credential: dict[str, Any] - label: str | None = None - - class PaymentReceipt(_Response): url: str = Field(..., description="Stripe's hosted receipt for the payment. It says what was paid and when.") pdf_url: str | None = Field(None, description="The same receipt as a PDF, where Stripe has one: the receipt of a paid invoice, which a top-up paid in Checkout has. Null for a charge without an invoice, such as an automatic top-up: its receipt is the page at url.") @@ -1790,29 +1432,6 @@ class PortalSession(_Response): expires_at: str -class ProviderHealth(_Response): - name: str - configured: bool - serves: list[str] = [] - circuit: str - routes_paused: list[str] - breakers: list[dict[str, Any]] = [] - last_success_at: str | None = None - last_failure_at: str | None = None - concurrency_in_use: int - - -class ProviderList(_Response): - items: list[ProviderHealth] - - -class Providers(_Response): - magic_link: bool = True - passkeys: bool = True - github: bool - google: bool - - class Quote(_Response): id: str environment: Literal["live", "test"] @@ -1854,11 +1473,6 @@ class QuoteCreate(_Request): delete_after_send: bool = Field(False, description="Delete the document and the transmitted copy the moment the fax ends in delivered, partial or failed. The job, its receipt and the carrier evidence stay; they hold no document content. A fax that ends unknown keeps the document until a reconcile settles it. Default: keep the document for the retention period.") -class Reauth(_Request): - method: Literal["passkey", "magic_link"] - credential: dict[str, Any] | None = None - - class Seller(_Response): """The company a receipt is issued by.""" @@ -1895,25 +1509,10 @@ class Receipt(_Response): one_time: OneTimeJob | None = Field(None, description="Set on the receipt of a fax that a one-time order paid for. It names the order, its status, the card and the amount held on the card. captured_micro in it is the amount charged, written once the payment provider confirmed the capture. For a card order read the money here. Null for a fax paid from the wallet.") -class ReconcileResult(_Response): - outcome: Literal["no_provider_ref", "skipped", "poll_failed", "finalized", "retry_scheduled", "unknown", "pending"] - job: AdminJob - - -class ReconciliationReport(_Response): - report: dict[str, Any] | None - last_day: str | None - - class ReleaseRequest(_Request): confirm: str | None = Field(None, description="The number itself, typed out, to confirm.") -class ReleaseResult(_Response): - settlement: dict[str, Any] - job: AdminJob - - class Requested(_Response): requested: bool kind: Literal["export", "deletion"] @@ -1922,48 +1521,6 @@ class Requested(_Response): created_at: str | None = None -class ReviewAccessAction(_Request): - reason: str = Field(..., description="Why: recorded on the audit row") - - -class ReviewAccessCreate(_Request): - reason: str = Field(..., description="Why: recorded on the audit row") - email: str - label: str = "Directory review" - ttl_days: int = 30 - - -class ReviewAccessIssued(_Response): - id: str - email: str - label: str - code: str - expires_at: str - - -class ReviewSignIn(_Request): - email: str - code: str - - -class Revoked(_Response): - revoked: int - - -class RouteState(_Response): - route: str - status: Literal["paused", "open", "breaker_open"] - reason: str | None = None - actor: str - updated_at: str - paused_at: str | None = None - open_until: str | None = None - - -class RouteList(_Response): - items: list[RouteState] - - class SandboxFixture(_Response): id: str scenario: str @@ -2017,11 +1574,6 @@ class SenderVerificationCreate(_Request): from_: str = Field(..., alias="from", description="A number your organization owns, E.164.") -class Sent(_Response): - sent: bool - message: str - - class ServiceStatus(_Response): status: Literal["ok", "degraded"] version: str @@ -2032,31 +1584,6 @@ class ServiceStatus(_Response): status_page: str | None = None -class SessionInfo(_Response): - id: str - auth_method: str - authenticated_at: str - fresh_until: str - fresh: bool - expires_at: str - - -class SessionOut(_Response): - id: str - current: bool - auth_method: str - ip: str | None - user_agent: str | None - created_at: str - authenticated_at: str - last_seen_at: str - expires_at: str - - -class SessionList(_Response): - items: list[SessionOut] - - class SignedUrl(_Response): url: str expires_at: str @@ -2117,16 +1644,6 @@ class SummaryCreate(_Request): strong_model_if_below: float = 0.75 -class SwitchOrganization(_Request): - org_id: str - - -class TelnyxAck(_Response): - received: bool - outcome: str - event_id: str | None = None - - class TopupCreate(_Request): amount_usd: int = Field(..., description="Whole US dollars, 10 to 1000 per session.") @@ -2218,15 +1735,6 @@ class UsageReport(_Response): totals: dict[str, int] -class UserOut(_Response): - id: str - email: str - name: str | None - email_verified: bool - created_at: str - last_login_at: str | None - - class Webhook(_Response): id: str url: str @@ -2239,11 +1747,6 @@ class Webhook(_Response): updated_at: str -class WebhookAck(_Response): - received: bool = True - outcome: str - - class WebhookCreate(_Request): url: str description: str | None = None @@ -2274,82 +1777,7 @@ class WebhookWithSecret(_Response): secret: str = Field(..., description="whsec_... Shown once. Verify webhook-signature with it.") -class faxforagents__api__routes__inbox__InboxItem(_Response): - id: str - from_: str | None = Field(None, alias="from") - to: str - pages: int - status: str - document_id: str | None - received_at: str - amount_micro: int = 0 - note: str | None = None - environment: Literal["live", "test"] = "live" - number_id: str | None = None - project_id: str | None = None - partial_content: bool = False - media_status: str = "stored" - duration_secs: int | None = None - provider: str = "" - read_at: str | None = None - expires_at: str | None = None - - -class faxforagents__api__schemas__InboxItem(_Response): - id: str - from_: str | None = Field(None, alias="from") - to: str - pages: int - status: str - document_id: str | None - received_at: str - amount_micro: int = 0 - note: str | None = None - - -class faxforagents__api__schemas__Me(_Response): - org_id: str - project_id: str - key_id: str - key_prefix: str - environment: Literal["live", "test"] - scopes: list[str] - actor: str - - -class faxforagents__auth__schemas__Me(_Response): - user: UserOut - organization: OrganizationSummary | None - organizations: list[OrganizationSummary] - session: SessionInfo - csrf_token: str - passkeys: int - providers: Providers - - __all__ = [ - "AbuseReview", - "AbuseReviewCreate", - "AbuseReviewPage", - "AbuseReviewPatch", - "OrganizationSummary", - "Accepted", - "Adjustment", - "AdjustmentApply", - "AdjustmentCreate", - "AdjustmentPage", - "AdminAction", - "AdminBrief", - "AdminDailyPoint", - "AdminDaily", - "AdminJob", - "AdminJobPage", - "AdminOrganization", - "AdminOrganizationDetail", - "AdminOrganizationPage", - "AdminRevenue", - "AdminStats", - "AdminWhoami", "ApiKey", "Agent", "AgentActivity", @@ -2360,12 +1788,6 @@ class faxforagents__auth__schemas__Me(_Response): "AgentList", "AgentUpdate", "AlreadyAllowed", - "AnalyticsJourneys", - "AnalyticsOrganization", - "AnalyticsSource", - "AnalyticsSources", - "AnalyticsUsage", - "AnalyticsWebsite", "ApiKeyCreate", "ApiKeyList", "ApiKeyWithSecret", @@ -2376,8 +1798,6 @@ class faxforagents__auth__schemas__Me(_Response): "ApprovalRequestPage", "Attempt", "AttemptPage", - "AuditEvent", - "AuditEventPage", "AutoSendSetting", "AutoSendUpdate", "AutoTopup", @@ -2393,8 +1813,6 @@ class faxforagents__auth__schemas__Me(_Response): "BudgetRemoved", "Capabilities", "ClassificationCreate", - "Client", - "ClientList", "Correction", "CorrectionCreate", "Coverage", @@ -2447,7 +1865,6 @@ class faxforagents__auth__schemas__Me(_Response): "InvoicePage", "LedgerEntry", "LedgerPage", - "MagicLinkRequest", "Me", "Member", "MemberList", @@ -2458,11 +1875,6 @@ class faxforagents__auth__schemas__Me(_Response): "NumberOrderCreate", "NumberOrderList", "NumberUpdate", - "OAuthConsentClient", - "OAuthConsentOrganization", - "OAuthConsent", - "OAuthConsentDecision", - "OAuthRedirect", "OneTimeAttempts", "OneTimeCheckout", "OneTimeQueue", @@ -2481,15 +1893,9 @@ class faxforagents__auth__schemas__Me(_Response): "OneTimeOrderCreated", "OneTimeOrderPage", "Organization", + "OrganizationSummary", "OrganizationList", "OrganizationPatch", - "OutboxDiscarded", - "OutboxRow", - "OutboxPage", - "Passkey", - "PasskeyList", - "PasskeyLoginVerify", - "PasskeyRegisterVerify", "PaymentReceipt", "PolicyCreate", "PolicyUsage", @@ -2509,26 +1915,12 @@ class faxforagents__auth__schemas__Me(_Response): "PortabilityCheck", "PortabilityCheckCreate", "PortalSession", - "ProviderHealth", - "ProviderList", - "Providers", "Quote", "QuoteCreate", - "Reauth", "Seller", "Receipt", - "ReconcileResult", - "ReconciliationReport", "ReleaseRequest", - "ReleaseResult", "Requested", - "ReviewAccessAction", - "ReviewAccessCreate", - "ReviewAccessIssued", - "ReviewSignIn", - "Revoked", - "RouteState", - "RouteList", "SandboxFixture", "SandboxInboundCreate", "SandboxReset", @@ -2537,11 +1929,7 @@ class faxforagents__auth__schemas__Me(_Response): "SchemaCreate", "SenderVerification", "SenderVerificationCreate", - "Sent", "ServiceStatus", - "SessionInfo", - "SessionOut", - "SessionList", "SignedUrl", "StatementLine", "StatementPage", @@ -2549,8 +1937,6 @@ class faxforagents__auth__schemas__Me(_Response): "SubscriptionCheckout", "SubscriptionList", "SummaryCreate", - "SwitchOrganization", - "TelnyxAck", "TopupCreate", "TopupSession", "TopupSessionPage", @@ -2561,15 +1947,9 @@ class faxforagents__auth__schemas__Me(_Response): "UsageExportCreate", "UsageItem", "UsageReport", - "UserOut", "Webhook", - "WebhookAck", "WebhookCreate", "WebhookList", "WebhookUpdate", "WebhookWithSecret", - "faxforagents__api__routes__inbox__InboxItem", - "faxforagents__api__schemas__InboxItem", - "faxforagents__api__schemas__Me", - "faxforagents__auth__schemas__Me", ] diff --git a/tests/test_removed_models.py b/tests/test_removed_models.py new file mode 100644 index 0000000..fe3508b --- /dev/null +++ b/tests/test_removed_models.py @@ -0,0 +1,180 @@ +"""The 70 models 0.10.0 removed stay out, and the generator models only what an operation reaches.""" + +from __future__ import annotations + +import copy +import importlib.util +from pathlib import Path +from types import ModuleType +from typing import Any + +import yaml + +from faxforagents import models + +ROOT = Path(__file__).resolve().parents[1] + +#: No method of either client took or returned them, and the public document of API 1.20.11 does not +#: define them. They came from the server's own document, most of them from the admin console and the +#: dashboard sign-in. +REMOVED = ( + "AbuseReview", + "AbuseReviewCreate", + "AbuseReviewPage", + "AbuseReviewPatch", + "Accepted", + "Adjustment", + "AdjustmentApply", + "AdjustmentCreate", + "AdjustmentPage", + "AdminAction", + "AdminBrief", + "AdminDaily", + "AdminDailyPoint", + "AdminJob", + "AdminJobPage", + "AdminOrganization", + "AdminOrganizationDetail", + "AdminOrganizationPage", + "AdminRevenue", + "AdminStats", + "AdminWhoami", + "AnalyticsJourneys", + "AnalyticsOrganization", + "AnalyticsSource", + "AnalyticsSources", + "AnalyticsUsage", + "AnalyticsWebsite", + "AuditEvent", + "AuditEventPage", + "Client", + "ClientList", + "MagicLinkRequest", + "OAuthConsent", + "OAuthConsentClient", + "OAuthConsentDecision", + "OAuthConsentOrganization", + "OAuthRedirect", + "OutboxDiscarded", + "OutboxPage", + "OutboxRow", + "Passkey", + "PasskeyList", + "PasskeyLoginVerify", + "PasskeyRegisterVerify", + "ProviderHealth", + "ProviderList", + "Providers", + "Reauth", + "ReconcileResult", + "ReconciliationReport", + "ReleaseResult", + "ReviewAccessAction", + "ReviewAccessCreate", + "ReviewAccessIssued", + "ReviewSignIn", + "Revoked", + "RouteList", + "RouteState", + "Sent", + "SessionInfo", + "SessionList", + "SessionOut", + "SwitchOrganization", + "TelnyxAck", + "UserOut", + "WebhookAck", + "faxforagents__api__routes__inbox__InboxItem", + "faxforagents__api__schemas__InboxItem", + "faxforagents__api__schemas__Me", + "faxforagents__auth__schemas__Me", +) + + +def generator() -> ModuleType: + spec = importlib.util.spec_from_file_location("gen_models", ROOT / "scripts" / "gen_models.py") + assert spec is not None and spec.loader is not None + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def saved_spec() -> dict[str, Any]: + spec: dict[str, Any] = yaml.safe_load((ROOT / "spec" / "openapi.yaml").read_text("utf-8")) + return spec + + +def test_no_removed_model_is_back_in_the_package() -> None: + assert len(set(REMOVED)) == len(REMOVED) == 70 + back = [name for name in REMOVED if hasattr(models, name) or name in models.__all__] + assert not back, "Removed in 0.10.0, back in faxforagents.models: " + ", ".join(back) + + +def test_every_schema_of_the_saved_spec_is_reached_by_an_operation() -> None: + spec = saved_spec() + orphans = sorted(set(spec["components"]["schemas"]) - generator().reached_schemas(spec)) + hint = "No operation reaches these schemas. Drop them from spec/openapi.yaml: " + assert not orphans, hint + ", ".join(orphans) + + +def test_a_spec_that_carries_them_again_generates_the_same_module() -> None: + gen = generator() + spec = saved_spec() + expected = gen.render(spec) + again = copy.deepcopy(spec) + for name in REMOVED: + # Each points at a model the clients use, as Accepted did, and nothing points at it. + again["components"]["schemas"][name] = { + "type": "object", + "properties": {"organization": {"$ref": "#/components/schemas/OrganizationSummary"}}, + "required": ["organization"], + } + assert gen.render(again) == expected + + +def test_reached_means_through_paths_shared_responses_and_fields() -> None: + def ref(name: str, kind: str = "schemas") -> dict[str, str]: + return {"$ref": f"#/components/{kind}/{name}"} + + def body(schema: dict[str, Any]) -> dict[str, Any]: + return {"content": {"application/json": {"schema": schema}}} + + spec = { + "info": {"version": "0.0.0"}, + "paths": { + "/v1/things": { + "post": { + "requestBody": body(ref("ThingCreate")), + "responses": {"201": body(ref("ThingPage")), "404": ref("NotFound", "responses")}, + } + } + }, + "components": { + "responses": {"NotFound": body(ref("ErrorEnvelope"))}, + "schemas": { + "ThingCreate": { + "type": "object", + "additionalProperties": False, + "properties": {"name": {"type": "string"}}, + }, + "ThingPage": { + "type": "object", + "properties": {"data": {"type": "array", "items": ref("Thing")}}, + }, + "Thing": {"type": "object", "properties": {"id": {"type": "string"}}}, + "ErrorEnvelope": {"type": "object", "properties": {"error": ref("ErrorBody")}}, + "ErrorBody": {"type": "object", "properties": {"code": {"type": "string"}}}, + "AdminStats": {"type": "object", "properties": {"thing": ref("Thing")}}, + "AdminStatsPage": { + "type": "object", + "properties": {"data": {"type": "array", "items": ref("AdminStats")}}, + }, + }, + }, + } + gen = generator() + assert gen.reached_schemas(spec) == {"ThingCreate", "ThingPage", "Thing", "ErrorEnvelope", "ErrorBody"} + text = gen.render(spec) + for name in ("ThingCreate", "ThingPage", "Thing", "ErrorEnvelope", "ErrorBody"): + assert f"class {name}(" in text + assert "AdminStats" not in text