Skip to content

Add Database Reco Counts report client support #3133

Description

@adamtheturtle

Summary

Add client support for the Database Reco Counts report, the last VWS endpoint with no vws-python equivalent.

Real Vuforia exposes POST /imagetargets/databases/{database_id}/reports/recoCounts, which asks for a per-target recognition-count report for a month and returns a presigned URL. The URL serves a CSV with a target_id,reco_count header once the report has been generated, and 404s until then.

vws-python-mock implements both halves of this as of VWS-Python/vws-python-mock#3357, including database ID validation, month validation and the generation delay, so a client can be tested end to end through a real HTTP transport.

What the endpoint does

  • The request body is {"month": "YYYY-mm"}. Only the current month and the previous month are accepted; anything else gets a 400 with the Fail result code.
  • The success body has result_code, transaction_id and presigned_url.
  • The database_id in the path must be the ID of the database the server keys belong to. Naming any other database — including naming the database by its name rather than its ID — gets a 401 with AuthenticationFailure.
  • The download URL needs no authorization headers. It returns 404 while the report is still being generated and 200 with text/plain (not text/csv) once it is ready. Rows end with CRLF.
  • Real presigned URLs expire after just under seven days.

Why this needs more than a new method

VWS is constructed with a server access key and a server secret key only. This endpoint is the first to need the database ID, which is not derivable from the keys and is not returned by any other VWS endpoint — the target manager shows it, and vws-web-tools exposes it via get_database_details. So either VWS.__init__ grows an optional database_id, or the report method takes one. An optional constructor argument that raises a clear error when the method is called without it seems the better fit, but the trade-off is worth deciding explicitly.

The download is also unlike every other call in the library: it is unsigned, it is not against base_vws_url, and its "not ready yet" state is a 404 rather than a result code. It should not go through make_request.

Suggested scope

  • Add a get_database_reco_counts_report-style method to VWS and AsyncVWS which requests the report and returns the presigned URL alongside the transaction ID.
  • Add a way to download a report from its URL, without signing, exposing "not ready" distinctly from an error.
  • Add a wait/poll helper in the style of wait_for_target_processed.
  • Parse the CSV into a typed report structure in reports.py — a sequence of target ID and count pairs — rather than handing back raw bytes. Keeping a raw-bytes accessor as well is worth considering, since the CSV shape is not documented by Vuforia and could gain columns.
  • Map the failure responses onto the existing exception types, including the Fail for a bad month and the AuthenticationFailure for a mismatched database ID.
  • Document the month restriction, the URL expiry and the delay before the report is ready.

Acceptance criteria

  • Synchronous and asynchronous APIs cover request → wait → download → parse.
  • Tests exercise both clients against vws-python-mock, covering a successful report, a download attempted before the report is ready, a rejected month, and a mismatched database ID.
  • A report for a database with no recognitions parses as an empty sequence of rows rather than failing.
  • API reference documentation, an example, and a news fragment are included.

Notes

The mock's coverage of this endpoint is not verified against real Vuforia yet: the shared test credentials carry no database ID, so the tests are mock-only (VWS-Python/vws-python-mock#3359, VWS-Python/vws-python-mock#3360). The presigned URL's name, query parameters and expiry differ from real Vuforia (VWS-Python/vws-python-mock#3364), and the mock's reports are always header-only until VWS-Python/vws-python-mock#3356 lands. Client tests should avoid depending on the URL's shape, and cannot yet assert on non-empty report bodies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions