Repository navigation
Add 23 endpoints from the current spec (Extract, billing, workspace consent) - #92
Open
kriton-dev wants to merge 1 commit into
Open
kriton-dev wants to merge 1 commit into
kriton-dev wants to merge 1 commit into
Conversation
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.
The OpenAPI spec at https://docs.contextual.ai/api-reference/openapi.json (version 1.0) has 66 endpoints and this SDK covers 40. This PR adds 23 of the other 26, following the generated code already in the repo: a params type and a response type for each endpoint, sync and async methods with the raw and streaming variants, entries in
api.md, and tests in the existing pattern. They go on three new resources,client.extract(documents, jobs and schemas, including the document upload as multipart),client.billingandclient.workspaces. Nothing that is already in the SDK is renamed or removed.DELETE /extract/documents/{document_id}client.extract.delete_document()DELETE /extract/schemas/{schema_id}client.extract.delete_schema()GET /extract/documentsclient.extract.list_documents()GET /extract/documents/{document_id}client.extract.retrieve_document()GET /extract/jobsclient.extract.list_jobs()GET /extract/jobs/{job_id}client.extract.retrieve_job()GET /extract/jobs/{job_id}/resultsclient.extract.retrieve_job_results()GET /extract/schemasclient.extract.list_schemas()GET /extract/schemas/{schema_id}client.extract.retrieve_schema()POST /extract/documents/uploadclient.extract.upload_document()POST /extract/jobsclient.extract.create_job()POST /extract/schemasclient.extract.create_schema()PUT /extract/jobs/{job_id}/resultsclient.extract.update_job_results()PUT /extract/schemas/{schema_id}client.extract.update_schema()GET /billing/balanceclient.billing.retrieve_balance()GET /billing/balance/top-upsclient.billing.list_top_ups()GET /billing/billing_mode/historyclient.billing.retrieve_billing_mode_history()GET /billing/metadataclient.billing.retrieve_metadata()GET /billing/usages/aclclient.billing.retrieve_acl_usage()GET /billing/usages/earliest_dateclient.billing.retrieve_earliest_usage_date()GET /billing/usages/monthlyclient.billing.retrieve_monthly_usage()GET /workspaces/consentclient.workspaces.retrieve_consent()PUT /workspaces/consentclient.workspaces.update_consent()I left out three on purpose.
GET /extract/jobs/{job_id}/streamis described as a stream of events but declares a JSON response, so how it should look in the SDK is your call.GET /agents/templates/aclandPOST /agents/{agent_id}/query/aclcarry the same summaries asagents.templates.list()andagents.query.create(), and the spec does not say how they differ. If any of the three should be in the SDK, say how and I will add them the same way.The test suite cannot run as written any more:
scripts/mockstarts Prism from theopenapi_spec_urlin.stats.yml, and that Stainless bucket now answersNoSuchBucket. I ran it against the same Prism version the script pins, started on the live spec. I generated the code from the spec with my own generator, set up to match the Stainless output in this repo, and then read through the result.ruff check,ruff format --check, strictpyrightandmypy, with the versions pinned inrequirements-dev.lock, give the same results as main. Against the mock, 1705 tests pass (1229 on main), including the new endpoints' tests in the existing pattern. Two proxy environment tests fail on main and on this branch alike, because of my machine's proxy settings. 46 of the new tests sit in one file,tests/test_added_calls_stubbed.py, which calls every new method sync and async against a respx stub and checks the request method, path, body, query and headers against the spec, and that the documented response parses into the new type with strict validation on.I found this repo while looking at SDKs that stopped getting updates when Stainless shut down its hosted service. The Node SDK,
contextual-client-node, is missing the same 23 endpoints. Bringing it up to date and keeping both in sync with the API is paid work I do, and I would be glad to talk about it here. If a smaller review is easier, I can start with a PR of justbillingandworkspaces(9 endpoints), and send Extract after.