Skip to content

Commit 8a0e8e1

Browse files
refactor: update generated models from apify-docs PR #2403 (#707)
This PR updates the auto-generated Pydantic models based on OpenAPI specification changes in [apify-docs PR #2403](apify/apify-docs#2403). ## Changes - Regenerated `src/apify_client/_models.py` using `datamodel-codegen` ## Source - apify-docs PR: apify/apify-docs#2403 --------- Co-authored-by: apify-service-account <apify-service-account@users.noreply.github.com> Co-authored-by: Josef Prochazka <josef.prochazka@apify.com>
1 parent dd17027 commit 8a0e8e1

File tree

3 files changed

+38
-49
lines changed

3 files changed

+38
-49
lines changed

src/apify_client/_models.py

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
2-
# filename: https://docs.apify.com/api/openapi.json
3-
# timestamp: 2026-04-09T08:30:29+00:00
2+
# filename: openapi.json
3+
# timestamp: 2026-04-13T07:02:33+00:00
44

55
from __future__ import annotations
66

@@ -152,8 +152,8 @@ class SourceCodeFile(BaseModel):
152152
extra='allow',
153153
populate_by_name=True,
154154
)
155-
format: SourceCodeFileFormat
156-
content: Annotated[str, Field(examples=["console.log('This is the main.js file');"])]
155+
format: SourceCodeFileFormat | None = None
156+
content: Annotated[str | None, Field(examples=["console.log('This is the main.js file');"])] = None
157157
name: Annotated[str, Field(examples=['src/main.js'])]
158158

159159

@@ -229,14 +229,6 @@ class CommonActorPricingInfo(BaseModel):
229229
reason_for_change: Annotated[str | None, Field(alias='reasonForChange')] = None
230230

231231

232-
@docs_group('Models')
233-
class PricingModel(StrEnum):
234-
PAY_PER_EVENT = 'PAY_PER_EVENT'
235-
PRICE_PER_DATASET_ITEM = 'PRICE_PER_DATASET_ITEM'
236-
FLAT_PRICE_PER_MONTH = 'FLAT_PRICE_PER_MONTH'
237-
FREE = 'FREE'
238-
239-
240232
@docs_group('Models')
241233
class ActorChargeEvent(BaseModel):
242234
model_config = ConfigDict(
@@ -678,6 +670,27 @@ class ActorNotFoundError(BaseModel):
678670
error: ActorNotFoundErrorDetail | None = None
679671

680672

673+
@docs_group('Models')
674+
class RecordOrTokenNotFoundErrorDetail(ErrorDetail):
675+
model_config = ConfigDict(
676+
extra='allow',
677+
populate_by_name=True,
678+
)
679+
type: Annotated[Literal['record-or-token-not-found'], Field(title='ErrorType')] = 'record-or-token-not-found'
680+
"""
681+
Machine-processable error type identifier.
682+
"""
683+
684+
685+
@docs_group('Models')
686+
class RecordOrTokenNotFoundError(BaseModel):
687+
model_config = ConfigDict(
688+
extra='allow',
689+
populate_by_name=True,
690+
)
691+
error: RecordOrTokenNotFoundErrorDetail | None = None
692+
693+
681694
@docs_group('Models')
682695
class RecordNotFoundErrorDetail(ErrorDetail):
683696
model_config = ConfigDict(
@@ -1631,7 +1644,7 @@ class CreateTaskRequest(BaseModel):
16311644
populate_by_name=True,
16321645
)
16331646
act_id: Annotated[str, Field(alias='actId', examples=['asADASadYvn4mBZmm'])]
1634-
name: Annotated[str, Field(examples=['my-task'])]
1647+
name: Annotated[str | None, Field(examples=['my-task'])] = None
16351648
options: TaskOptions | None = None
16361649
input: TaskInput | None = None
16371650
title: str | None = None
@@ -1734,27 +1747,6 @@ class ChargeRunRequest(BaseModel):
17341747
count: Annotated[int, Field(examples=[1])]
17351748

17361749

1737-
@docs_group('Models')
1738-
class RecordOrTokenNotFoundErrorDetail(ErrorDetail):
1739-
model_config = ConfigDict(
1740-
extra='allow',
1741-
populate_by_name=True,
1742-
)
1743-
type: Annotated[Literal['record-or-token-not-found'], Field(title='ErrorType')] = 'record-or-token-not-found'
1744-
"""
1745-
Machine-processable error type identifier.
1746-
"""
1747-
1748-
1749-
@docs_group('Models')
1750-
class RecordOrTokenNotFoundError(BaseModel):
1751-
model_config = ConfigDict(
1752-
extra='allow',
1753-
populate_by_name=True,
1754-
)
1755-
error: RecordOrTokenNotFoundErrorDetail | None = None
1756-
1757-
17581750
@docs_group('Models')
17591751
class StorageOwnership(StrEnum):
17601752
OWNED_BY_ME = 'ownedByMe'
@@ -2474,7 +2466,7 @@ class RequestBase(BaseModel):
24742466
"""
24752467
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
24762468
"""
2477-
url: Annotated[AnyUrl | None, Field(examples=['https://apify.com'])] = None
2469+
url: Annotated[str | None, Field(examples=['https://apify.com'])] = None
24782470
"""
24792471
The URL of the request.
24802472
"""
@@ -2487,7 +2479,7 @@ class RequestBase(BaseModel):
24872479
"""
24882480
The final URL that was loaded, after redirects (if any).
24892481
"""
2490-
payload: Annotated[dict[str, Any] | None, Field(examples=[None])] = None
2482+
payload: Annotated[str | dict[str, Any] | None, Field(examples=[None])] = None
24912483
"""
24922484
The request payload, typically used with POST or PUT requests.
24932485
"""
@@ -2552,7 +2544,7 @@ class RequestDraft(BaseModel):
25522544
"""
25532545
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
25542546
"""
2555-
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
2547+
url: Annotated[str, Field(examples=['https://apify.com'])]
25562548
"""
25572549
The URL of the request.
25582550
"""
@@ -2871,7 +2863,7 @@ class HeadRequest(BaseModel):
28712863
"""
28722864
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
28732865
"""
2874-
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
2866+
url: Annotated[str, Field(examples=['https://apify.com'])]
28752867
"""
28762868
The URL of the request.
28772869
"""
@@ -2935,7 +2927,7 @@ class LockedHeadRequest(BaseModel):
29352927
"""
29362928
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
29372929
"""
2938-
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
2930+
url: Annotated[str, Field(examples=['https://apify.com'])]
29392931
"""
29402932
The URL of the request.
29412933
"""
@@ -3036,7 +3028,7 @@ class WebhookCreate(BaseModel):
30363028
idempotency_key: Annotated[str | None, Field(alias='idempotencyKey', examples=['fdSJmdP3nfs7sfk3y'])] = None
30373029
ignore_ssl_errors: Annotated[bool | None, Field(alias='ignoreSslErrors', examples=[False])] = None
30383030
do_not_retry: Annotated[bool | None, Field(alias='doNotRetry', examples=[False])] = None
3039-
request_url: Annotated[AnyUrl, Field(alias='requestUrl', examples=['http://example.com/'])]
3031+
request_url: Annotated[str, Field(alias='requestUrl', examples=['http://example.com/'])]
30403032
payload_template: Annotated[
30413033
str | None, Field(alias='payloadTemplate', examples=['{\\n "userId": {{userId}}...'])
30423034
] = None

src/apify_client/_resource_clients/webhook_collection.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from typing import TYPE_CHECKING, Any
44

5-
from pydantic import AnyUrl
6-
75
from apify_client._docs import docs_group
86
from apify_client._models import (
97
ListOfWebhooks,
@@ -105,7 +103,7 @@ def create(
105103
"""
106104
webhook_create = WebhookCreate(
107105
event_types=list(event_types),
108-
request_url=AnyUrl(request_url),
106+
request_url=request_url,
109107
payload_template=payload_template,
110108
headers_template=headers_template,
111109
ignore_ssl_errors=ignore_ssl_errors,
@@ -208,7 +206,7 @@ async def create(
208206
"""
209207
webhook_create = WebhookCreate(
210208
event_types=list(event_types),
211-
request_url=AnyUrl(request_url),
209+
request_url=request_url,
212210
payload_template=payload_template,
213211
headers_template=headers_template,
214212
ignore_ssl_errors=ignore_ssl_errors,

tests/unit/test_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import impit
77
import pytest
8-
from pydantic import AnyUrl
98

109
from apify_client._models import WebhookCondition, WebhookCreate, WebhookEventType
1110
from apify_client._resource_clients._resource_client import ResourceClientBase
@@ -39,12 +38,12 @@ def test_webhook_representation_list_to_base64() -> None:
3938
WebhookCreate(
4039
event_types=[WebhookEventType.ACTOR_RUN_CREATED],
4140
condition=WebhookCondition(),
42-
request_url=AnyUrl('https://example.com/run-created'),
41+
request_url='https://example.com/run-created',
4342
),
4443
WebhookCreate(
4544
event_types=[WebhookEventType.ACTOR_RUN_SUCCEEDED],
4645
condition=WebhookCondition(),
47-
request_url=AnyUrl('https://example.com/run-succeeded'),
46+
request_url='https://example.com/run-succeeded',
4847
payload_template='{"hello": "world", "resource":{{resource}}}',
4948
),
5049
]
@@ -77,12 +76,12 @@ def test_webhook_representation_list_from_dicts() -> None:
7776
WebhookCreate(
7877
event_types=[WebhookEventType.ACTOR_RUN_CREATED],
7978
condition=WebhookCondition(),
80-
request_url=AnyUrl('https://example.com/run-created'),
79+
request_url='https://example.com/run-created',
8180
),
8281
WebhookCreate(
8382
event_types=[WebhookEventType.ACTOR_RUN_SUCCEEDED],
8483
condition=WebhookCondition(),
85-
request_url=AnyUrl('https://example.com/run-succeeded'),
84+
request_url='https://example.com/run-succeeded',
8685
payload_template='{"hello": "world"}',
8786
),
8887
]

0 commit comments

Comments
 (0)