Skip to content

Commit 67ddd05

Browse files
authored
Merge branch 'master' into fix/remove-volatile-metadata-from-generated-models
2 parents 14fb6dd + 8a0e8e1 commit 67ddd05

File tree

3 files changed

+36
-47
lines changed

3 files changed

+36
-47
lines changed

src/apify_client/_models.py

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ class SourceCodeFile(BaseModel):
150150
extra='allow',
151151
populate_by_name=True,
152152
)
153-
format: SourceCodeFileFormat
154-
content: Annotated[str, Field(examples=["console.log('This is the main.js file');"])]
153+
format: SourceCodeFileFormat | None = None
154+
content: Annotated[str | None, Field(examples=["console.log('This is the main.js file');"])] = None
155155
name: Annotated[str, Field(examples=['src/main.js'])]
156156

157157

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

229229

230-
@docs_group('Models')
231-
class PricingModel(StrEnum):
232-
PAY_PER_EVENT = 'PAY_PER_EVENT'
233-
PRICE_PER_DATASET_ITEM = 'PRICE_PER_DATASET_ITEM'
234-
FLAT_PRICE_PER_MONTH = 'FLAT_PRICE_PER_MONTH'
235-
FREE = 'FREE'
236-
237-
238230
@docs_group('Models')
239231
class ActorChargeEvent(BaseModel):
240232
model_config = ConfigDict(
@@ -676,6 +668,27 @@ class ActorNotFoundError(BaseModel):
676668
error: ActorNotFoundErrorDetail | None = None
677669

678670

671+
@docs_group('Models')
672+
class RecordOrTokenNotFoundErrorDetail(ErrorDetail):
673+
model_config = ConfigDict(
674+
extra='allow',
675+
populate_by_name=True,
676+
)
677+
type: Annotated[Literal['record-or-token-not-found'], Field(title='ErrorType')] = 'record-or-token-not-found'
678+
"""
679+
Machine-processable error type identifier.
680+
"""
681+
682+
683+
@docs_group('Models')
684+
class RecordOrTokenNotFoundError(BaseModel):
685+
model_config = ConfigDict(
686+
extra='allow',
687+
populate_by_name=True,
688+
)
689+
error: RecordOrTokenNotFoundErrorDetail | None = None
690+
691+
679692
@docs_group('Models')
680693
class RecordNotFoundErrorDetail(ErrorDetail):
681694
model_config = ConfigDict(
@@ -1629,7 +1642,7 @@ class CreateTaskRequest(BaseModel):
16291642
populate_by_name=True,
16301643
)
16311644
act_id: Annotated[str, Field(alias='actId', examples=['asADASadYvn4mBZmm'])]
1632-
name: Annotated[str, Field(examples=['my-task'])]
1645+
name: Annotated[str | None, Field(examples=['my-task'])] = None
16331646
options: TaskOptions | None = None
16341647
input: TaskInput | None = None
16351648
title: str | None = None
@@ -1732,27 +1745,6 @@ class ChargeRunRequest(BaseModel):
17321745
count: Annotated[int, Field(examples=[1])]
17331746

17341747

1735-
@docs_group('Models')
1736-
class RecordOrTokenNotFoundErrorDetail(ErrorDetail):
1737-
model_config = ConfigDict(
1738-
extra='allow',
1739-
populate_by_name=True,
1740-
)
1741-
type: Annotated[Literal['record-or-token-not-found'], Field(title='ErrorType')] = 'record-or-token-not-found'
1742-
"""
1743-
Machine-processable error type identifier.
1744-
"""
1745-
1746-
1747-
@docs_group('Models')
1748-
class RecordOrTokenNotFoundError(BaseModel):
1749-
model_config = ConfigDict(
1750-
extra='allow',
1751-
populate_by_name=True,
1752-
)
1753-
error: RecordOrTokenNotFoundErrorDetail | None = None
1754-
1755-
17561748
@docs_group('Models')
17571749
class StorageOwnership(StrEnum):
17581750
OWNED_BY_ME = 'ownedByMe'
@@ -2472,7 +2464,7 @@ class RequestBase(BaseModel):
24722464
"""
24732465
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
24742466
"""
2475-
url: Annotated[AnyUrl | None, Field(examples=['https://apify.com'])] = None
2467+
url: Annotated[str | None, Field(examples=['https://apify.com'])] = None
24762468
"""
24772469
The URL of the request.
24782470
"""
@@ -2485,7 +2477,7 @@ class RequestBase(BaseModel):
24852477
"""
24862478
The final URL that was loaded, after redirects (if any).
24872479
"""
2488-
payload: Annotated[dict[str, Any] | None, Field(examples=[None])] = None
2480+
payload: Annotated[str | dict[str, Any] | None, Field(examples=[None])] = None
24892481
"""
24902482
The request payload, typically used with POST or PUT requests.
24912483
"""
@@ -2550,7 +2542,7 @@ class RequestDraft(BaseModel):
25502542
"""
25512543
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
25522544
"""
2553-
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
2545+
url: Annotated[str, Field(examples=['https://apify.com'])]
25542546
"""
25552547
The URL of the request.
25562548
"""
@@ -2869,7 +2861,7 @@ class HeadRequest(BaseModel):
28692861
"""
28702862
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
28712863
"""
2872-
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
2864+
url: Annotated[str, Field(examples=['https://apify.com'])]
28732865
"""
28742866
The URL of the request.
28752867
"""
@@ -2933,7 +2925,7 @@ class LockedHeadRequest(BaseModel):
29332925
"""
29342926
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
29352927
"""
2936-
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
2928+
url: Annotated[str, Field(examples=['https://apify.com'])]
29372929
"""
29382930
The URL of the request.
29392931
"""
@@ -3034,7 +3026,7 @@ class WebhookCreate(BaseModel):
30343026
idempotency_key: Annotated[str | None, Field(alias='idempotencyKey', examples=['fdSJmdP3nfs7sfk3y'])] = None
30353027
ignore_ssl_errors: Annotated[bool | None, Field(alias='ignoreSslErrors', examples=[False])] = None
30363028
do_not_retry: Annotated[bool | None, Field(alias='doNotRetry', examples=[False])] = None
3037-
request_url: Annotated[AnyUrl, Field(alias='requestUrl', examples=['http://example.com/'])]
3029+
request_url: Annotated[str, Field(alias='requestUrl', examples=['http://example.com/'])]
30383030
payload_template: Annotated[
30393031
str | None, Field(alias='payloadTemplate', examples=['{\\n "userId": {{userId}}...'])
30403032
] = 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)