Skip to content

Commit 0de06fb

Browse files
committed
Release 0.1.4
1 parent ef1ba61 commit 0de06fb

File tree

4 files changed

+36
-27
lines changed

4 files changed

+36
-27
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pip install --upgrade fileforge
2121
from fileforge.client import Fileforge
2222

2323
client = Fileforge(
24-
api_key="YOUR_API_KEY",
24+
header="YOUR_HEADER",
2525
)
2626
```
2727
<!-- End Usage -->
@@ -33,7 +33,7 @@ client = Fileforge(
3333
from fileforge.client import AsyncFileforge
3434

3535
client = AsyncFileforge(
36-
api_key="YOUR_API_KEY",
36+
header="YOUR_HEADER",
3737
)
3838
```
3939
<!-- End Async Usage -->

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "fileforge"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
description = ""
55
readme = "README.md"
66
authors = []

src/fileforge/client.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file was auto-generated by Fern from our API Definition.
22

3+
import os
34
import typing
45
import urllib.parse
56
from json.decoder import JSONDecodeError
@@ -46,7 +47,7 @@ class Fileforge:
4647
4748
4849
49-
api_key : str
50+
header : typing.Optional[str]
5051
timeout : typing.Optional[float]
5152
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.
5253
@@ -61,7 +62,7 @@ class Fileforge:
6162
from fileforge.client import Fileforge
6263
6364
client = Fileforge(
64-
api_key="YOUR_API_KEY",
65+
header="YOUR_HEADER",
6566
)
6667
"""
6768

@@ -70,15 +71,19 @@ def __init__(
7071
*,
7172
base_url: typing.Optional[str] = None,
7273
environment: FileforgeEnvironment = FileforgeEnvironment.DEFAULT,
73-
api_key: str,
74+
header: typing.Optional[str] = os.getenv("FILEFORGE_API_KEY"),
7475
timeout: typing.Optional[float] = None,
7576
follow_redirects: typing.Optional[bool] = True,
7677
httpx_client: typing.Optional[httpx.Client] = None,
7778
):
7879
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
80+
if header is None:
81+
raise ApiError(
82+
body="The client must be instantiated be either passing in header or setting FILEFORGE_API_KEY"
83+
)
7984
self._client_wrapper = SyncClientWrapper(
8085
base_url=_get_base_url(base_url=base_url, environment=environment),
81-
api_key=api_key,
86+
header=header,
8287
httpx_client=httpx_client
8388
if httpx_client is not None
8489
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
@@ -103,7 +108,7 @@ def retrieve_server_status(self, *, request_options: typing.Optional[RequestOpti
103108
from fileforge.client import Fileforge
104109
105110
client = Fileforge(
106-
api_key="YOUR_API_KEY",
111+
header="YOUR_HEADER",
107112
)
108113
client.retrieve_server_status()
109114
"""
@@ -206,7 +211,7 @@ def convert_docx(
206211
from fileforge.client import Fileforge
207212
208213
client = Fileforge(
209-
api_key="YOUR_API_KEY",
214+
header="YOUR_HEADER",
210215
)
211216
client.convert_docx()
212217
"""
@@ -287,7 +292,7 @@ def generate(
287292
from fileforge.client import Fileforge
288293
289294
client = Fileforge(
290-
api_key="YOUR_API_KEY",
295+
header="YOUR_HEADER",
291296
)
292297
client.generate()
293298
"""
@@ -367,7 +372,7 @@ def merge(
367372
from fileforge.client import Fileforge
368373
369374
client = Fileforge(
370-
api_key="YOUR_API_KEY",
375+
header="YOUR_HEADER",
371376
)
372377
client.merge()
373378
"""
@@ -436,7 +441,7 @@ class AsyncFileforge:
436441
437442
438443
439-
api_key : str
444+
header : typing.Optional[str]
440445
timeout : typing.Optional[float]
441446
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.
442447
@@ -451,7 +456,7 @@ class AsyncFileforge:
451456
from fileforge.client import AsyncFileforge
452457
453458
client = AsyncFileforge(
454-
api_key="YOUR_API_KEY",
459+
header="YOUR_HEADER",
455460
)
456461
"""
457462

@@ -460,15 +465,19 @@ def __init__(
460465
*,
461466
base_url: typing.Optional[str] = None,
462467
environment: FileforgeEnvironment = FileforgeEnvironment.DEFAULT,
463-
api_key: str,
468+
header: typing.Optional[str] = os.getenv("FILEFORGE_API_KEY"),
464469
timeout: typing.Optional[float] = None,
465470
follow_redirects: typing.Optional[bool] = True,
466471
httpx_client: typing.Optional[httpx.AsyncClient] = None,
467472
):
468473
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
474+
if header is None:
475+
raise ApiError(
476+
body="The client must be instantiated be either passing in header or setting FILEFORGE_API_KEY"
477+
)
469478
self._client_wrapper = AsyncClientWrapper(
470479
base_url=_get_base_url(base_url=base_url, environment=environment),
471-
api_key=api_key,
480+
header=header,
472481
httpx_client=httpx_client
473482
if httpx_client is not None
474483
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
493502
from fileforge.client import AsyncFileforge
494503
495504
client = AsyncFileforge(
496-
api_key="YOUR_API_KEY",
505+
header="YOUR_HEADER",
497506
)
498507
await client.retrieve_server_status()
499508
"""
@@ -596,7 +605,7 @@ async def convert_docx(
596605
from fileforge.client import AsyncFileforge
597606
598607
client = AsyncFileforge(
599-
api_key="YOUR_API_KEY",
608+
header="YOUR_HEADER",
600609
)
601610
await client.convert_docx()
602611
"""
@@ -677,7 +686,7 @@ async def generate(
677686
from fileforge.client import AsyncFileforge
678687
679688
client = AsyncFileforge(
680-
api_key="YOUR_API_KEY",
689+
header="YOUR_HEADER",
681690
)
682691
await client.generate()
683692
"""
@@ -757,7 +766,7 @@ async def merge(
757766
from fileforge.client import AsyncFileforge
758767
759768
client = AsyncFileforge(
760-
api_key="YOUR_API_KEY",
769+
header="YOUR_HEADER",
761770
)
762771
await client.merge()
763772
"""

src/fileforge/core/client_wrapper.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99

1010
class BaseClientWrapper:
11-
def __init__(self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None):
12-
self.api_key = api_key
11+
def __init__(self, *, header: str, base_url: str, timeout: typing.Optional[float] = None):
12+
self.header = header
1313
self._base_url = base_url
1414
self._timeout = timeout
1515

1616
def get_headers(self) -> typing.Dict[str, str]:
1717
headers: typing.Dict[str, str] = {
1818
"X-Fern-Language": "Python",
1919
"X-Fern-SDK-Name": "fileforge",
20-
"X-Fern-SDK-Version": "0.1.3",
20+
"X-Fern-SDK-Version": "0.1.4",
2121
}
22-
headers["X-API-Key"] = self.api_key
22+
headers["X-API-Key"] = self.header
2323
return headers
2424

2525
def get_base_url(self) -> str:
@@ -31,15 +31,15 @@ def get_timeout(self) -> typing.Optional[float]:
3131

3232
class SyncClientWrapper(BaseClientWrapper):
3333
def __init__(
34-
self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
34+
self, *, header: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
3535
):
36-
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
36+
super().__init__(header=header, base_url=base_url, timeout=timeout)
3737
self.httpx_client = HttpClient(httpx_client=httpx_client)
3838

3939

4040
class AsyncClientWrapper(BaseClientWrapper):
4141
def __init__(
42-
self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
42+
self, *, header: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
4343
):
44-
super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
44+
super().__init__(header=header, base_url=base_url, timeout=timeout)
4545
self.httpx_client = AsyncHttpClient(httpx_client=httpx_client)

0 commit comments

Comments
 (0)