Skip to content
Open
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
3 changes: 1 addition & 2 deletions docs/02_concepts/code/03_nested_async.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from apify_client import ApifyClientAsync
from apify_client._models_generated import ActorJobStatus

TOKEN = 'MY-APIFY-TOKEN'

Expand All @@ -14,7 +13,7 @@ async def main() -> None:
actor_runs = (await runs_client.list(limit=10, desc=True)).items

# Select the last run of the Actor that finished with a SUCCEEDED status.
last_succeeded_run_client = actor_client.last_run(status=ActorJobStatus.SUCCEEDED)
last_succeeded_run_client = actor_client.last_run(status='SUCCEEDED')

# Get dataset
actor_run_dataset_client = last_succeeded_run_client.dataset()
Expand Down
3 changes: 1 addition & 2 deletions docs/02_concepts/code/03_nested_sync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from apify_client import ApifyClient
from apify_client._models_generated import ActorJobStatus

TOKEN = 'MY-APIFY-TOKEN'

Expand All @@ -14,7 +13,7 @@ def main() -> None:
actor_runs = runs_client.list(limit=10, desc=True).items

# Select the last run of the Actor that finished with a SUCCEEDED status.
last_succeeded_run_client = actor_client.last_run(status=ActorJobStatus.SUCCEEDED)
last_succeeded_run_client = actor_client.last_run(status='SUCCEEDED')

# Get dataset
actor_run_dataset_client = last_succeeded_run_client.dataset()
Expand Down
50 changes: 50 additions & 0 deletions docs/04_upgrading/upgrading_to_v3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,53 @@ client.actors().list(sort_by='last_run_started_at')
```

The default value also changed from `'createdAt'` to `'created_at'` (behavior is unchanged). The client translates the snake_case value to the form expected by the API internally.

## `Literal` type aliases instead of `StrEnum` classes

Generated enum-like types are now [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal) type aliases instead of `StrEnum` classes. Pass plain strings instead of enum members; type checkers will validate them against the allowed set.

Affected types: `ActorJobStatus`, `ActorPermissionLevel`, `ErrorType`, `GeneralAccess`, `HttpMethod`, `RunOrigin`, `SourceCodeFileFormat`, `StorageOwnership`, `VersionSourceType`, `WebhookDispatchStatus`, `WebhookEventType`.

Before (v2):

```python
from apify_client._models_generated import WebhookEventType

client.actor('apify/hello-world').webhooks().create(
event_types=[WebhookEventType.ACTOR_RUN_SUCCEEDED],
request_url='https://example.com/webhook',
)
```

After (v3):

```python
client.actor('apify/hello-world').webhooks().create(
event_types=['ACTOR.RUN.SUCCEEDED'],
request_url='https://example.com/webhook',
)
```

The aliases now live in `apify_client._literals_generated` (previously `apify_client._models_generated`) and can be imported for use in type annotations:

```python
from apify_client._literals_generated import WebhookEventType

events: list[WebhookEventType] = ['ACTOR.RUN.SUCCEEDED', 'ACTOR.RUN.FAILED']
```

### Snake_case `StorageOwnership` values

`StorageOwnership` previously carried the camelCase wire values (`'ownedByMe'` / `'sharedWithMe'`). It now uses pythonic snake_case values; the client translates them to the camelCase form expected by the API internally.

Before (v2):

```python
client.datasets().list(ownership='ownedByMe')
```

After (v3):

```python
client.datasets().list(ownership='owned_by_me')
```
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ indent-style = "space"
"**/__init__.py" = [
"F401", # Unused imports
]
"**/{_models,_models_generated}.py" = [
"TC001", # Pydantic needs the literal aliases importable at runtime to resolve forward references
]
"**/{scripts}/*" = [
"D", # Everything from the pydocstyle
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
Expand Down
Loading