Skip to content
Draft
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
16 changes: 14 additions & 2 deletions src/apify_client/_resource_clients/actor_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def create(
actor_standby_memory_mbytes: int | None = None,
actor_standby_disable_standby_fields_override: bool | None = None,
actor_standby_should_pass_actor_input: bool | None = None,
actor_permission_level: ActorPermissionLevel | None = None,
timeout: Timeout = 'medium',
) -> ActorResource:
"""Create a new Actor.
Expand Down Expand Up @@ -176,6 +177,7 @@ def create(
overridden elsewhere.
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
the Standby runs start with no input.
actor_permission_level: The permission level of the Actor on Apify platform.
timeout: Timeout for the API HTTP request.

Returns:
Expand Down Expand Up @@ -214,7 +216,11 @@ def create(
content_type=example_run_input_content_type,
),
)
result = self._create(timeout=timeout, **actor_fields.model_dump(by_alias=True, exclude_none=True))
actor_body = actor_fields.model_dump(by_alias=True, exclude_none=True)
# The generated `CreateActorRequest` has no `actor_permission_level` field, so it goes into the body directly.
if actor_permission_level is not None:
actor_body['actorPermissionLevel'] = actor_permission_level
result = self._create(timeout=timeout, **actor_body)
return ActorResponse.model_validate(result).data


Expand Down Expand Up @@ -327,6 +333,7 @@ async def create(
actor_standby_memory_mbytes: int | None = None,
actor_standby_disable_standby_fields_override: bool | None = None,
actor_standby_should_pass_actor_input: bool | None = None,
actor_permission_level: ActorPermissionLevel | None = None,
timeout: Timeout = 'medium',
) -> ActorResource:
"""Create a new Actor.
Expand Down Expand Up @@ -368,6 +375,7 @@ async def create(
overridden elsewhere.
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
the Standby runs start with no input.
actor_permission_level: The permission level of the Actor on Apify platform.
timeout: Timeout for the API HTTP request.

Returns:
Expand Down Expand Up @@ -406,5 +414,9 @@ async def create(
content_type=example_run_input_content_type,
),
)
result = await self._create(timeout=timeout, **actor_fields.model_dump(by_alias=True, exclude_none=True))
actor_body = actor_fields.model_dump(by_alias=True, exclude_none=True)
# The generated `CreateActorRequest` has no `actor_permission_level` field, so it goes into the body directly.
if actor_permission_level is not None:
actor_body['actorPermissionLevel'] = actor_permission_level
result = await self._create(timeout=timeout, **actor_body)
return ActorResponse.model_validate(result).data
54 changes: 54 additions & 0 deletions src/apify_client/_resource_clients/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def update(
self,
*,
name: str | None = None,
title: str | None = None,
general_access: GeneralAccess | None = None,
timeout: Timeout = 'short',
) -> DatasetResource:
Expand All @@ -99,6 +100,7 @@ def update(

Args:
name: The new name for the dataset.
title: The new title for the dataset.
general_access: Determines how others can access the dataset.
timeout: Timeout for the API HTTP request.

Expand All @@ -108,6 +110,7 @@ def update(
result = self._update(
timeout=timeout,
name=name,
title=title,
generalAccess=general_access,
)
return DatasetResponse.model_validate(result).data
Expand Down Expand Up @@ -224,6 +227,8 @@ def iterate_items(
unwind: list[str] | None = None,
skip_empty: bool | None = None,
skip_hidden: bool | None = None,
flatten: list[str] | None = None,
view: str | None = None,
signature: str | None = None,
chunk_size: int | None = None,
timeout: Timeout = 'long',
Expand Down Expand Up @@ -260,6 +265,8 @@ def iterate_items(
contain less items than the limit value.
skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with
the # character.
flatten: A list of fields that should be flattened.
view: Name of the dataset view to be used.
signature: Signature used to access the items.
chunk_size: Maximum number of dataset rows requested per API call when iterating across pages.
timeout: Timeout for the API HTTP request.
Expand All @@ -279,6 +286,8 @@ def _callback(*, limit: int | None = None, offset: int | None = None) -> Dataset
unwind=unwind,
skip_empty=skip_empty,
skip_hidden=skip_hidden,
flatten=flatten,
view=view,
signature=signature,
timeout=timeout,
)
Expand All @@ -304,6 +313,8 @@ def get_items_as_bytes(
xml_root: str | None = None,
xml_row: str | None = None,
flatten: list[str] | None = None,
view: str | None = None,
attachment: bool | None = None,
signature: str | None = None,
timeout: Timeout = 'long',
) -> bytes:
Expand Down Expand Up @@ -348,6 +359,9 @@ def get_items_as_bytes(
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
By default the element name is item.
flatten: A list of fields that should be flattened.
view: Name of the dataset view to be used.
attachment: If True, the response defines the `Content-Disposition: attachment` header, which makes a web
browser download the file without displaying it.
signature: Signature used to access the items.
timeout: Timeout for the API HTTP request.

Expand All @@ -371,6 +385,8 @@ def get_items_as_bytes(
xmlRoot=xml_root,
xmlRow=xml_row,
flatten=flatten,
view=view,
attachment=attachment,
signature=signature,
)

Expand Down Expand Up @@ -403,6 +419,8 @@ def stream_items(
xml_root: str | None = None,
xml_row: str | None = None,
flatten: list[str] | None = None,
view: str | None = None,
attachment: bool | None = None,
signature: str | None = None,
timeout: Timeout = 'long',
) -> Generator[HttpResponse]:
Expand Down Expand Up @@ -447,6 +465,9 @@ def stream_items(
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
By default the element name is item.
flatten: A list of fields that should be flattened.
view: Name of the dataset view to be used.
attachment: If True, the response defines the `Content-Disposition: attachment` header, which makes a web
browser download the file without displaying it.
signature: Signature used to access the items.
timeout: Timeout for the API HTTP request.

Expand All @@ -472,6 +493,8 @@ def stream_items(
xmlRoot=xml_root,
xmlRow=xml_row,
flatten=flatten,
view=view,
attachment=attachment,
signature=signature,
)

Expand Down Expand Up @@ -541,6 +564,7 @@ def get_statistics(self, *, timeout: Timeout = 'short') -> DatasetStatistics:
def create_items_public_url(
self,
*,
item_format: str | None = None,
offset: int | None = None,
limit: int | None = None,
clean: bool | None = None,
Expand All @@ -567,6 +591,8 @@ def create_items_public_url(
Any other options (like `limit` or `offset`) will be included as query parameters in the URL.

Args:
item_format: Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss.
By default, the URL serves JSON.
offset: Number of items that should be skipped at the start. The default value is 0.
limit: Maximum number of items to return. By default there is no limit.
clean: If True, returns only non-empty items and skips hidden fields.
Expand All @@ -588,6 +614,7 @@ def create_items_public_url(
dataset = self.get(timeout=timeout)

request_params = self._build_params(
format=item_format,
offset=offset,
limit=limit,
desc=desc,
Expand Down Expand Up @@ -653,6 +680,7 @@ async def update(
self,
*,
name: str | None = None,
title: str | None = None,
general_access: GeneralAccess | None = None,
timeout: Timeout = 'short',
) -> DatasetResource:
Expand All @@ -662,6 +690,7 @@ async def update(

Args:
name: The new name for the dataset.
title: The new title for the dataset.
general_access: Determines how others can access the dataset.
timeout: Timeout for the API HTTP request.

Expand All @@ -671,6 +700,7 @@ async def update(
result = await self._update(
timeout=timeout,
name=name,
title=title,
generalAccess=general_access,
)
return DatasetResponse.model_validate(result).data
Expand Down Expand Up @@ -787,6 +817,8 @@ def iterate_items(
unwind: list[str] | None = None,
skip_empty: bool | None = None,
skip_hidden: bool | None = None,
flatten: list[str] | None = None,
view: str | None = None,
signature: str | None = None,
chunk_size: int | None = None,
timeout: Timeout = 'long',
Expand Down Expand Up @@ -823,6 +855,8 @@ def iterate_items(
contain less items than the limit value.
skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with
the # character.
flatten: A list of fields that should be flattened.
view: Name of the dataset view to be used.
signature: Signature used to access the items.
chunk_size: Maximum number of dataset rows requested per API call when iterating across pages.
timeout: Timeout for the API HTTP request.
Expand All @@ -842,6 +876,8 @@ async def _callback(*, limit: int | None = None, offset: int | None = None) -> D
unwind=unwind,
skip_empty=skip_empty,
skip_hidden=skip_hidden,
flatten=flatten,
view=view,
signature=signature,
timeout=timeout,
)
Expand Down Expand Up @@ -869,6 +905,8 @@ async def get_items_as_bytes(
xml_root: str | None = None,
xml_row: str | None = None,
flatten: list[str] | None = None,
view: str | None = None,
attachment: bool | None = None,
signature: str | None = None,
timeout: Timeout = 'long',
) -> bytes:
Expand Down Expand Up @@ -913,6 +951,9 @@ async def get_items_as_bytes(
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
By default the element name is item.
flatten: A list of fields that should be flattened.
view: Name of the dataset view to be used.
attachment: If True, the response defines the `Content-Disposition: attachment` header, which makes a web
browser download the file without displaying it.
signature: Signature used to access the items.
timeout: Timeout for the API HTTP request.

Expand All @@ -936,6 +977,8 @@ async def get_items_as_bytes(
xmlRoot=xml_root,
xmlRow=xml_row,
flatten=flatten,
view=view,
attachment=attachment,
signature=signature,
)

Expand Down Expand Up @@ -968,6 +1011,8 @@ async def stream_items(
xml_root: str | None = None,
xml_row: str | None = None,
flatten: list[str] | None = None,
view: str | None = None,
attachment: bool | None = None,
signature: str | None = None,
timeout: Timeout = 'long',
) -> AsyncGenerator[HttpResponse]:
Expand Down Expand Up @@ -1012,6 +1057,9 @@ async def stream_items(
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
By default the element name is item.
flatten: A list of fields that should be flattened.
view: Name of the dataset view to be used.
attachment: If True, the response defines the `Content-Disposition: attachment` header, which makes a web
browser download the file without displaying it.
signature: Signature used to access the items.
timeout: Timeout for the API HTTP request.

Expand All @@ -1037,6 +1085,8 @@ async def stream_items(
xmlRoot=xml_root,
xmlRow=xml_row,
flatten=flatten,
view=view,
attachment=attachment,
signature=signature,
)

Expand Down Expand Up @@ -1106,6 +1156,7 @@ async def get_statistics(self, *, timeout: Timeout = 'short') -> DatasetStatisti
async def create_items_public_url(
self,
*,
item_format: str | None = None,
offset: int | None = None,
limit: int | None = None,
clean: bool | None = None,
Expand All @@ -1132,6 +1183,8 @@ async def create_items_public_url(
Any other options (like `limit` or `offset`) will be included as query parameters in the URL.

Args:
item_format: Format of the results, possible values are: json, jsonl, csv, html, xlsx, xml and rss.
By default, the URL serves JSON.
offset: Number of items that should be skipped at the start. The default value is 0.
limit: Maximum number of items to return. By default there is no limit.
clean: If True, returns only non-empty items and skips hidden fields.
Expand All @@ -1153,6 +1206,7 @@ async def create_items_public_url(
dataset = await self.get(timeout=timeout)

request_params = self._build_params(
format=item_format,
offset=offset,
limit=limit,
desc=desc,
Expand Down
8 changes: 6 additions & 2 deletions src/apify_client/_resource_clients/key_value_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def update(
self,
*,
name: str | None = None,
title: str | None = None,
general_access: GeneralAccess | None = None,
timeout: Timeout = 'long',
) -> KeyValueStoreResource:
Expand All @@ -114,13 +115,14 @@ def update(

Args:
name: The new name for key-value store.
title: The new title for the key-value store.
general_access: Determines how others can access the key-value store.
timeout: Timeout for the API HTTP request.

Returns:
The updated key-value store.
"""
result = self._update(timeout=timeout, name=name, generalAccess=general_access)
result = self._update(timeout=timeout, name=name, title=title, generalAccess=general_access)
return KeyValueStoreResponse.model_validate(result).data

def delete(self, *, timeout: Timeout = 'short') -> None:
Expand Down Expand Up @@ -541,6 +543,7 @@ async def update(
self,
*,
name: str | None = None,
title: str | None = None,
general_access: GeneralAccess | None = None,
timeout: Timeout = 'long',
) -> KeyValueStoreResource:
Expand All @@ -550,13 +553,14 @@ async def update(

Args:
name: The new name for key-value store.
title: The new title for the key-value store.
general_access: Determines how others can access the key-value store.
timeout: Timeout for the API HTTP request.

Returns:
The updated key-value store.
"""
result = await self._update(timeout=timeout, name=name, generalAccess=general_access)
result = await self._update(timeout=timeout, name=name, title=title, generalAccess=general_access)
return KeyValueStoreResponse.model_validate(result).data

async def delete(self, *, timeout: Timeout = 'short') -> None:
Expand Down
Loading
Loading