Skip to content

Commit 76434a9

Browse files
feat(api): manual updates
1 parent 2270fd4 commit 76434a9

File tree

5 files changed

+97
-101
lines changed

5 files changed

+97
-101
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml
33
openapi_spec_hash: 1d382866fce3284f26d341f112988d9d
4-
config_hash: 54c05a157f2cc730fac9e1df5dc3ca29
4+
config_hash: 29a2351fe2be89392b15719be8bc964f

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import os
3232
from imagekit import ImageKit
3333

3434
client = ImageKit(
35-
private_api_key=os.environ.get(
35+
private_key=os.environ.get(
3636
"IMAGEKIT_PRIVATE_API_KEY"
3737
), # This is the default and can be omitted
3838
password=os.environ.get(
@@ -47,10 +47,10 @@ response = client.files.upload(
4747
print(response.video_codec)
4848
```
4949

50-
While you can provide a `private_api_key` keyword argument,
50+
While you can provide a `private_key` keyword argument,
5151
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
52-
to add `IMAGEKIT_PRIVATE_API_KEY="My Private API Key"` to your `.env` file
53-
so that your Private API Key is not stored in source control.
52+
to add `IMAGEKIT_PRIVATE_API_KEY="My Private Key"` to your `.env` file
53+
so that your Private Key is not stored in source control.
5454

5555
## Async usage
5656

@@ -62,7 +62,7 @@ import asyncio
6262
from imagekit import AsyncImageKit
6363

6464
client = AsyncImageKit(
65-
private_api_key=os.environ.get(
65+
private_key=os.environ.get(
6666
"IMAGEKIT_PRIVATE_API_KEY"
6767
), # This is the default and can be omitted
6868
password=os.environ.get(
@@ -105,7 +105,7 @@ from imagekit import AsyncImageKit
105105

106106
async def main() -> None:
107107
async with AsyncImageKit(
108-
private_api_key="My Private API Key",
108+
private_key="My Private Key",
109109
password="My Password",
110110
http_client=DefaultAioHttpClient(),
111111
) as client:

src/imagekit/_client.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class ImageKit(SyncAPIClient):
6262
with_streaming_response: ImageKitWithStreamedResponse
6363

6464
# client options
65-
private_api_key: str
65+
private_key: str
6666
password: str | None
6767
webhook_secret: str | None
6868

6969
def __init__(
7070
self,
7171
*,
72-
private_api_key: str | None = None,
72+
private_key: str | None = None,
7373
password: str | None = None,
7474
webhook_secret: str | None = None,
7575
base_url: str | httpx.URL | None = None,
@@ -94,17 +94,17 @@ def __init__(
9494
"""Construct a new synchronous ImageKit client instance.
9595
9696
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
97-
- `private_api_key` from `IMAGEKIT_PRIVATE_API_KEY`
97+
- `private_key` from `IMAGEKIT_PRIVATE_API_KEY`
9898
- `password` from `OPTIONAL_IMAGEKIT_IGNORES_THIS`
9999
- `webhook_secret` from `IMAGEKIT_WEBHOOK_SECRET`
100100
"""
101-
if private_api_key is None:
102-
private_api_key = os.environ.get("IMAGEKIT_PRIVATE_API_KEY")
103-
if private_api_key is None:
101+
if private_key is None:
102+
private_key = os.environ.get("IMAGEKIT_PRIVATE_API_KEY")
103+
if private_key is None:
104104
raise ImageKitError(
105-
"The private_api_key client option must be set either by passing private_api_key to the client or by setting the IMAGEKIT_PRIVATE_API_KEY environment variable"
105+
"The private_key client option must be set either by passing private_key to the client or by setting the IMAGEKIT_PRIVATE_API_KEY environment variable"
106106
)
107-
self.private_api_key = private_api_key
107+
self.private_key = private_key
108108

109109
if password is None:
110110
password = os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS") or "do_not_set"
@@ -152,7 +152,7 @@ def qs(self) -> Querystring:
152152
def auth_headers(self) -> dict[str, str]:
153153
if self.password is None:
154154
return {}
155-
credentials = f"{self.private_api_key}:{self.password}".encode("ascii")
155+
credentials = f"{self.private_key}:{self.password}".encode("ascii")
156156
header = f"Basic {base64.b64encode(credentials).decode('ascii')}"
157157
return {"Authorization": header}
158158

@@ -167,19 +167,19 @@ def default_headers(self) -> dict[str, str | Omit]:
167167

168168
@override
169169
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
170-
if self.private_api_key and self.password and headers.get("Authorization"):
170+
if self.private_key and self.password and headers.get("Authorization"):
171171
return
172172
if isinstance(custom_headers.get("Authorization"), Omit):
173173
return
174174

175175
raise TypeError(
176-
'"Could not resolve authentication method. Expected the private_api_key or password to be set. Or for the `Authorization` headers to be explicitly omitted"'
176+
'"Could not resolve authentication method. Expected the private_key or password to be set. Or for the `Authorization` headers to be explicitly omitted"'
177177
)
178178

179179
def copy(
180180
self,
181181
*,
182-
private_api_key: str | None = None,
182+
private_key: str | None = None,
183183
password: str | None = None,
184184
webhook_secret: str | None = None,
185185
base_url: str | httpx.URL | None = None,
@@ -215,7 +215,7 @@ def copy(
215215

216216
http_client = http_client or self._client
217217
client = self.__class__(
218-
private_api_key=private_api_key or self.private_api_key,
218+
private_key=private_key or self.private_key,
219219
password=password or self.password,
220220
webhook_secret=webhook_secret or self.webhook_secret,
221221
base_url=base_url or self.base_url,
@@ -280,14 +280,14 @@ class AsyncImageKit(AsyncAPIClient):
280280
with_streaming_response: AsyncImageKitWithStreamedResponse
281281

282282
# client options
283-
private_api_key: str
283+
private_key: str
284284
password: str | None
285285
webhook_secret: str | None
286286

287287
def __init__(
288288
self,
289289
*,
290-
private_api_key: str | None = None,
290+
private_key: str | None = None,
291291
password: str | None = None,
292292
webhook_secret: str | None = None,
293293
base_url: str | httpx.URL | None = None,
@@ -312,17 +312,17 @@ def __init__(
312312
"""Construct a new async AsyncImageKit client instance.
313313
314314
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
315-
- `private_api_key` from `IMAGEKIT_PRIVATE_API_KEY`
315+
- `private_key` from `IMAGEKIT_PRIVATE_API_KEY`
316316
- `password` from `OPTIONAL_IMAGEKIT_IGNORES_THIS`
317317
- `webhook_secret` from `IMAGEKIT_WEBHOOK_SECRET`
318318
"""
319-
if private_api_key is None:
320-
private_api_key = os.environ.get("IMAGEKIT_PRIVATE_API_KEY")
321-
if private_api_key is None:
319+
if private_key is None:
320+
private_key = os.environ.get("IMAGEKIT_PRIVATE_API_KEY")
321+
if private_key is None:
322322
raise ImageKitError(
323-
"The private_api_key client option must be set either by passing private_api_key to the client or by setting the IMAGEKIT_PRIVATE_API_KEY environment variable"
323+
"The private_key client option must be set either by passing private_key to the client or by setting the IMAGEKIT_PRIVATE_API_KEY environment variable"
324324
)
325-
self.private_api_key = private_api_key
325+
self.private_key = private_key
326326

327327
if password is None:
328328
password = os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS") or "do_not_set"
@@ -370,7 +370,7 @@ def qs(self) -> Querystring:
370370
def auth_headers(self) -> dict[str, str]:
371371
if self.password is None:
372372
return {}
373-
credentials = f"{self.private_api_key}:{self.password}".encode("ascii")
373+
credentials = f"{self.private_key}:{self.password}".encode("ascii")
374374
header = f"Basic {base64.b64encode(credentials).decode('ascii')}"
375375
return {"Authorization": header}
376376

@@ -385,19 +385,19 @@ def default_headers(self) -> dict[str, str | Omit]:
385385

386386
@override
387387
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
388-
if self.private_api_key and self.password and headers.get("Authorization"):
388+
if self.private_key and self.password and headers.get("Authorization"):
389389
return
390390
if isinstance(custom_headers.get("Authorization"), Omit):
391391
return
392392

393393
raise TypeError(
394-
'"Could not resolve authentication method. Expected the private_api_key or password to be set. Or for the `Authorization` headers to be explicitly omitted"'
394+
'"Could not resolve authentication method. Expected the private_key or password to be set. Or for the `Authorization` headers to be explicitly omitted"'
395395
)
396396

397397
def copy(
398398
self,
399399
*,
400-
private_api_key: str | None = None,
400+
private_key: str | None = None,
401401
password: str | None = None,
402402
webhook_secret: str | None = None,
403403
base_url: str | httpx.URL | None = None,
@@ -433,7 +433,7 @@ def copy(
433433

434434
http_client = http_client or self._client
435435
client = self.__class__(
436-
private_api_key=private_api_key or self.private_api_key,
436+
private_key=private_key or self.private_key,
437437
password=password or self.password,
438438
webhook_secret=webhook_secret or self.webhook_secret,
439439
base_url=base_url or self.base_url,

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def pytest_collection_modifyitems(items: list[pytest.Function]) -> None:
4545

4646
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
4747

48-
private_api_key = "My Private API Key"
48+
private_key = "My Private Key"
4949
password = "My Password"
5050

5151

@@ -56,7 +56,7 @@ def client(request: FixtureRequest) -> Iterator[ImageKit]:
5656
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
5757

5858
with ImageKit(
59-
base_url=base_url, private_api_key=private_api_key, password=password, _strict_response_validation=strict
59+
base_url=base_url, private_key=private_key, password=password, _strict_response_validation=strict
6060
) as client:
6161
yield client
6262

@@ -83,7 +83,7 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncImageKit]:
8383

8484
async with AsyncImageKit(
8585
base_url=base_url,
86-
private_api_key=private_api_key,
86+
private_key=private_key,
8787
password=password,
8888
_strict_response_validation=strict,
8989
http_client=http_client,

0 commit comments

Comments
 (0)