diff --git a/README.md b/README.md index e12a304..588899a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ pip install --upgrade fileforge from fileforge.client import Fileforge client = Fileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) ``` @@ -33,7 +33,7 @@ client = Fileforge( from fileforge.client import AsyncFileforge client = AsyncFileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) ``` diff --git a/pyproject.toml b/pyproject.toml index 99527e0..fbc691d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fileforge" -version = "0.1.3" +version = "0.1.4" description = "" readme = "README.md" authors = [] diff --git a/src/fileforge/client.py b/src/fileforge/client.py index 99e8a0a..553c0bb 100644 --- a/src/fileforge/client.py +++ b/src/fileforge/client.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. +import os import typing import urllib.parse from json.decoder import JSONDecodeError @@ -46,7 +47,7 @@ class Fileforge: - api_key : str + header : typing.Optional[str] timeout : typing.Optional[float] The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set. @@ -61,7 +62,7 @@ class Fileforge: from fileforge.client import Fileforge client = Fileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) """ @@ -70,15 +71,19 @@ def __init__( *, base_url: typing.Optional[str] = None, environment: FileforgeEnvironment = FileforgeEnvironment.DEFAULT, - api_key: str, + header: typing.Optional[str] = os.getenv("FILEFORGE_API_KEY"), timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.Client] = None, ): _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None + if header is None: + raise ApiError( + body="The client must be instantiated be either passing in header or setting FILEFORGE_API_KEY" + ) self._client_wrapper = SyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), - api_key=api_key, + header=header, httpx_client=httpx_client if httpx_client is not None else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects) @@ -103,7 +108,7 @@ def retrieve_server_status(self, *, request_options: typing.Optional[RequestOpti from fileforge.client import Fileforge client = Fileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) client.retrieve_server_status() """ @@ -206,7 +211,7 @@ def convert_docx( from fileforge.client import Fileforge client = Fileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) client.convert_docx() """ @@ -287,7 +292,7 @@ def generate( from fileforge.client import Fileforge client = Fileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) client.generate() """ @@ -367,7 +372,7 @@ def merge( from fileforge.client import Fileforge client = Fileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) client.merge() """ @@ -436,7 +441,7 @@ class AsyncFileforge: - api_key : str + header : typing.Optional[str] timeout : typing.Optional[float] The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set. @@ -451,7 +456,7 @@ class AsyncFileforge: from fileforge.client import AsyncFileforge client = AsyncFileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) """ @@ -460,15 +465,19 @@ def __init__( *, base_url: typing.Optional[str] = None, environment: FileforgeEnvironment = FileforgeEnvironment.DEFAULT, - api_key: str, + header: typing.Optional[str] = os.getenv("FILEFORGE_API_KEY"), timeout: typing.Optional[float] = None, follow_redirects: typing.Optional[bool] = True, httpx_client: typing.Optional[httpx.AsyncClient] = None, ): _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None + if header is None: + raise ApiError( + body="The client must be instantiated be either passing in header or setting FILEFORGE_API_KEY" + ) self._client_wrapper = AsyncClientWrapper( base_url=_get_base_url(base_url=base_url, environment=environment), - api_key=api_key, + header=header, httpx_client=httpx_client if httpx_client is not None else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects) @@ -493,7 +502,7 @@ async def retrieve_server_status(self, *, request_options: typing.Optional[Reque from fileforge.client import AsyncFileforge client = AsyncFileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) await client.retrieve_server_status() """ @@ -596,7 +605,7 @@ async def convert_docx( from fileforge.client import AsyncFileforge client = AsyncFileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) await client.convert_docx() """ @@ -677,7 +686,7 @@ async def generate( from fileforge.client import AsyncFileforge client = AsyncFileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) await client.generate() """ @@ -757,7 +766,7 @@ async def merge( from fileforge.client import AsyncFileforge client = AsyncFileforge( - api_key="YOUR_API_KEY", + header="YOUR_HEADER", ) await client.merge() """ diff --git a/src/fileforge/core/client_wrapper.py b/src/fileforge/core/client_wrapper.py index c3337b3..67d851b 100644 --- a/src/fileforge/core/client_wrapper.py +++ b/src/fileforge/core/client_wrapper.py @@ -8,8 +8,8 @@ class BaseClientWrapper: - def __init__(self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None): - self.api_key = api_key + def __init__(self, *, header: str, base_url: str, timeout: typing.Optional[float] = None): + self.header = header self._base_url = base_url self._timeout = timeout @@ -17,9 +17,9 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "fileforge", - "X-Fern-SDK-Version": "0.1.3", + "X-Fern-SDK-Version": "0.1.4", } - headers["X-API-Key"] = self.api_key + headers["X-API-Key"] = self.header return headers def get_base_url(self) -> str: @@ -31,15 +31,15 @@ def get_timeout(self) -> typing.Optional[float]: class SyncClientWrapper(BaseClientWrapper): def __init__( - self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client + self, *, header: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client ): - super().__init__(api_key=api_key, base_url=base_url, timeout=timeout) + super().__init__(header=header, base_url=base_url, timeout=timeout) self.httpx_client = HttpClient(httpx_client=httpx_client) class AsyncClientWrapper(BaseClientWrapper): def __init__( - self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient + self, *, header: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient ): - super().__init__(api_key=api_key, base_url=base_url, timeout=timeout) + super().__init__(header=header, base_url=base_url, timeout=timeout) self.httpx_client = AsyncHttpClient(httpx_client=httpx_client)