Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 32 additions & 40 deletions src/apify_client/_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: https://docs.apify.com/api/openapi.json
Comment thread
vdusek marked this conversation as resolved.
# timestamp: 2026-04-09T08:30:29+00:00
# filename: openapi.json
# timestamp: 2026-04-13T07:02:33+00:00

from __future__ import annotations

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


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


@docs_group('Models')
class PricingModel(StrEnum):
PAY_PER_EVENT = 'PAY_PER_EVENT'
PRICE_PER_DATASET_ITEM = 'PRICE_PER_DATASET_ITEM'
FLAT_PRICE_PER_MONTH = 'FLAT_PRICE_PER_MONTH'
FREE = 'FREE'


@docs_group('Models')
class ActorChargeEvent(BaseModel):
model_config = ConfigDict(
Expand Down Expand Up @@ -678,6 +670,27 @@ class ActorNotFoundError(BaseModel):
error: ActorNotFoundErrorDetail | None = None


@docs_group('Models')
class RecordOrTokenNotFoundErrorDetail(ErrorDetail):
model_config = ConfigDict(
extra='allow',
populate_by_name=True,
)
type: Annotated[Literal['record-or-token-not-found'], Field(title='ErrorType')] = 'record-or-token-not-found'
"""
Machine-processable error type identifier.
"""


@docs_group('Models')
class RecordOrTokenNotFoundError(BaseModel):
model_config = ConfigDict(
extra='allow',
populate_by_name=True,
)
error: RecordOrTokenNotFoundErrorDetail | None = None


@docs_group('Models')
class RecordNotFoundErrorDetail(ErrorDetail):
model_config = ConfigDict(
Expand Down Expand Up @@ -1631,7 +1644,7 @@ class CreateTaskRequest(BaseModel):
populate_by_name=True,
)
act_id: Annotated[str, Field(alias='actId', examples=['asADASadYvn4mBZmm'])]
name: Annotated[str, Field(examples=['my-task'])]
name: Annotated[str | None, Field(examples=['my-task'])] = None
options: TaskOptions | None = None
input: TaskInput | None = None
title: str | None = None
Expand Down Expand Up @@ -1734,27 +1747,6 @@ class ChargeRunRequest(BaseModel):
count: Annotated[int, Field(examples=[1])]


@docs_group('Models')
class RecordOrTokenNotFoundErrorDetail(ErrorDetail):
model_config = ConfigDict(
extra='allow',
populate_by_name=True,
)
type: Annotated[Literal['record-or-token-not-found'], Field(title='ErrorType')] = 'record-or-token-not-found'
"""
Machine-processable error type identifier.
"""


@docs_group('Models')
class RecordOrTokenNotFoundError(BaseModel):
model_config = ConfigDict(
extra='allow',
populate_by_name=True,
)
error: RecordOrTokenNotFoundErrorDetail | None = None


@docs_group('Models')
class StorageOwnership(StrEnum):
OWNED_BY_ME = 'ownedByMe'
Expand Down Expand Up @@ -2474,7 +2466,7 @@ class RequestBase(BaseModel):
"""
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
"""
url: Annotated[AnyUrl | None, Field(examples=['https://apify.com'])] = None
url: Annotated[str | None, Field(examples=['https://apify.com'])] = None
"""
The URL of the request.
"""
Expand All @@ -2487,7 +2479,7 @@ class RequestBase(BaseModel):
"""
The final URL that was loaded, after redirects (if any).
"""
payload: Annotated[dict[str, Any] | None, Field(examples=[None])] = None
payload: Annotated[str | dict[str, Any] | None, Field(examples=[None])] = None
"""
The request payload, typically used with POST or PUT requests.
"""
Expand Down Expand Up @@ -2552,7 +2544,7 @@ class RequestDraft(BaseModel):
"""
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
"""
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
url: Annotated[str, Field(examples=['https://apify.com'])]
"""
The URL of the request.
"""
Expand Down Expand Up @@ -2871,7 +2863,7 @@ class HeadRequest(BaseModel):
"""
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
"""
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
url: Annotated[str, Field(examples=['https://apify.com'])]
"""
The URL of the request.
"""
Expand Down Expand Up @@ -2935,7 +2927,7 @@ class LockedHeadRequest(BaseModel):
"""
A unique key used for request de-duplication. Requests with the same unique key are considered identical.
"""
url: Annotated[AnyUrl, Field(examples=['https://apify.com'])]
url: Annotated[str, Field(examples=['https://apify.com'])]
"""
The URL of the request.
"""
Expand Down Expand Up @@ -3036,7 +3028,7 @@ class WebhookCreate(BaseModel):
idempotency_key: Annotated[str | None, Field(alias='idempotencyKey', examples=['fdSJmdP3nfs7sfk3y'])] = None
ignore_ssl_errors: Annotated[bool | None, Field(alias='ignoreSslErrors', examples=[False])] = None
do_not_retry: Annotated[bool | None, Field(alias='doNotRetry', examples=[False])] = None
request_url: Annotated[AnyUrl, Field(alias='requestUrl', examples=['http://example.com/'])]
request_url: Annotated[str, Field(alias='requestUrl', examples=['http://example.com/'])]
payload_template: Annotated[
str | None, Field(alias='payloadTemplate', examples=['{\\n "userId": {{userId}}...'])
] = None
Expand Down
6 changes: 2 additions & 4 deletions src/apify_client/_resource_clients/webhook_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from typing import TYPE_CHECKING, Any

from pydantic import AnyUrl

from apify_client._docs import docs_group
from apify_client._models import (
ListOfWebhooks,
Expand Down Expand Up @@ -105,7 +103,7 @@ def create(
"""
webhook_create = WebhookCreate(
event_types=list(event_types),
request_url=AnyUrl(request_url),
request_url=request_url,
payload_template=payload_template,
headers_template=headers_template,
ignore_ssl_errors=ignore_ssl_errors,
Expand Down Expand Up @@ -208,7 +206,7 @@ async def create(
"""
webhook_create = WebhookCreate(
event_types=list(event_types),
request_url=AnyUrl(request_url),
request_url=request_url,
payload_template=payload_template,
headers_template=headers_template,
ignore_ssl_errors=ignore_ssl_errors,
Expand Down
9 changes: 4 additions & 5 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import impit
import pytest
from pydantic import AnyUrl

from apify_client._models import WebhookCondition, WebhookCreate, WebhookEventType
from apify_client._resource_clients._resource_client import ResourceClientBase
Expand Down Expand Up @@ -39,12 +38,12 @@ def test_webhook_representation_list_to_base64() -> None:
WebhookCreate(
event_types=[WebhookEventType.ACTOR_RUN_CREATED],
condition=WebhookCondition(),
request_url=AnyUrl('https://example.com/run-created'),
request_url='https://example.com/run-created',
),
WebhookCreate(
event_types=[WebhookEventType.ACTOR_RUN_SUCCEEDED],
condition=WebhookCondition(),
request_url=AnyUrl('https://example.com/run-succeeded'),
request_url='https://example.com/run-succeeded',
payload_template='{"hello": "world", "resource":{{resource}}}',
),
]
Expand Down Expand Up @@ -77,12 +76,12 @@ def test_webhook_representation_list_from_dicts() -> None:
WebhookCreate(
event_types=[WebhookEventType.ACTOR_RUN_CREATED],
condition=WebhookCondition(),
request_url=AnyUrl('https://example.com/run-created'),
request_url='https://example.com/run-created',
),
WebhookCreate(
event_types=[WebhookEventType.ACTOR_RUN_SUCCEEDED],
condition=WebhookCondition(),
request_url=AnyUrl('https://example.com/run-succeeded'),
request_url='https://example.com/run-succeeded',
payload_template='{"hello": "world"}',
),
]
Expand Down