|
| 1 | +# This file was auto-generated by Fern from our API Definition. |
| 2 | + |
| 3 | +from ...core.client_wrapper import SyncClientWrapper |
| 4 | +import typing |
| 5 | +from ...core.request_options import RequestOptions |
| 6 | +from ...core.pydantic_utilities import parse_obj_as |
| 7 | +from json.decoder import JSONDecodeError |
| 8 | +from ...core.api_error import ApiError |
| 9 | +from ...core.client_wrapper import AsyncClientWrapper |
| 10 | + |
| 11 | + |
| 12 | +class EquationClient: |
| 13 | + def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 14 | + self._client_wrapper = client_wrapper |
| 15 | + |
| 16 | + def user_variables(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Dict[str, str]: |
| 17 | + """ |
| 18 | + Get all variables from the DB so the user can choose which variables they want to use in axtract for for their consistency checks. |
| 19 | +
|
| 20 | + Parameters |
| 21 | + ---------- |
| 22 | + request_options : typing.Optional[RequestOptions] |
| 23 | + Request-specific configuration. |
| 24 | +
|
| 25 | + Returns |
| 26 | + ------- |
| 27 | + typing.Dict[str, str] |
| 28 | + Successful Response |
| 29 | +
|
| 30 | + Examples |
| 31 | + -------- |
| 32 | + from axiomatic import Axiomatic |
| 33 | +
|
| 34 | + client = Axiomatic( |
| 35 | + api_key="YOUR_API_KEY", |
| 36 | + ) |
| 37 | + client.document.equation.user_variables() |
| 38 | + """ |
| 39 | + _response = self._client_wrapper.httpx_client.request( |
| 40 | + "document/expression/user-variables", |
| 41 | + method="GET", |
| 42 | + request_options=request_options, |
| 43 | + ) |
| 44 | + try: |
| 45 | + if 200 <= _response.status_code < 300: |
| 46 | + return typing.cast( |
| 47 | + typing.Dict[str, str], |
| 48 | + parse_obj_as( |
| 49 | + type_=typing.Dict[str, str], # type: ignore |
| 50 | + object_=_response.json(), |
| 51 | + ), |
| 52 | + ) |
| 53 | + _response_json = _response.json() |
| 54 | + except JSONDecodeError: |
| 55 | + raise ApiError(status_code=_response.status_code, body=_response.text) |
| 56 | + raise ApiError(status_code=_response.status_code, body=_response_json) |
| 57 | + |
| 58 | + |
| 59 | +class AsyncEquationClient: |
| 60 | + def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 61 | + self._client_wrapper = client_wrapper |
| 62 | + |
| 63 | + async def user_variables(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Dict[str, str]: |
| 64 | + """ |
| 65 | + Get all variables from the DB so the user can choose which variables they want to use in axtract for for their consistency checks. |
| 66 | +
|
| 67 | + Parameters |
| 68 | + ---------- |
| 69 | + request_options : typing.Optional[RequestOptions] |
| 70 | + Request-specific configuration. |
| 71 | +
|
| 72 | + Returns |
| 73 | + ------- |
| 74 | + typing.Dict[str, str] |
| 75 | + Successful Response |
| 76 | +
|
| 77 | + Examples |
| 78 | + -------- |
| 79 | + import asyncio |
| 80 | +
|
| 81 | + from axiomatic import AsyncAxiomatic |
| 82 | +
|
| 83 | + client = AsyncAxiomatic( |
| 84 | + api_key="YOUR_API_KEY", |
| 85 | + ) |
| 86 | +
|
| 87 | +
|
| 88 | + async def main() -> None: |
| 89 | + await client.document.equation.user_variables() |
| 90 | +
|
| 91 | +
|
| 92 | + asyncio.run(main()) |
| 93 | + """ |
| 94 | + _response = await self._client_wrapper.httpx_client.request( |
| 95 | + "document/expression/user-variables", |
| 96 | + method="GET", |
| 97 | + request_options=request_options, |
| 98 | + ) |
| 99 | + try: |
| 100 | + if 200 <= _response.status_code < 300: |
| 101 | + return typing.cast( |
| 102 | + typing.Dict[str, str], |
| 103 | + parse_obj_as( |
| 104 | + type_=typing.Dict[str, str], # type: ignore |
| 105 | + object_=_response.json(), |
| 106 | + ), |
| 107 | + ) |
| 108 | + _response_json = _response.json() |
| 109 | + except JSONDecodeError: |
| 110 | + raise ApiError(status_code=_response.status_code, body=_response.text) |
| 111 | + raise ApiError(status_code=_response.status_code, body=_response_json) |
0 commit comments