diff --git a/algoliasearch/ingestion/client.py b/algoliasearch/ingestion/client.py index 85570c15f..7f0411146 100644 --- a/algoliasearch/ingestion/client.py +++ b/algoliasearch/ingestion/client.py @@ -2933,6 +2933,12 @@ async def list_tasks_with_http_info( Optional[List[TriggerType]], Field(description="Type of task trigger for filtering the list of tasks."), ] = None, + with_email_notifications: Annotated[ + Optional[StrictBool], + Field( + description="If specified, the response only includes tasks with notifications.email.enabled set to this value." + ), + ] = None, sort: Union[ Annotated[ Optional[TaskSortKeys], @@ -2975,6 +2981,8 @@ async def list_tasks_with_http_info( :type destination_id: List[str] :param trigger_type: Type of task trigger for filtering the list of tasks. :type trigger_type: List[TriggerType] + :param with_email_notifications: If specified, the response only includes tasks with notifications.email.enabled set to this value. + :type with_email_notifications: bool :param sort: Property by which to sort the list of tasks. :type sort: TaskSortKeys :param order: Sort order of the response, ascending or descending. @@ -3001,6 +3009,8 @@ async def list_tasks_with_http_info( _query_parameters["destinationID"] = destination_id if trigger_type is not None: _query_parameters["triggerType"] = trigger_type + if with_email_notifications is not None: + _query_parameters["withEmailNotifications"] = with_email_notifications if sort is not None: _query_parameters["sort"] = sort if order is not None: @@ -3052,6 +3062,12 @@ async def list_tasks( Optional[List[TriggerType]], Field(description="Type of task trigger for filtering the list of tasks."), ] = None, + with_email_notifications: Annotated[ + Optional[StrictBool], + Field( + description="If specified, the response only includes tasks with notifications.email.enabled set to this value." + ), + ] = None, sort: Union[ Annotated[ Optional[TaskSortKeys], @@ -3094,6 +3110,8 @@ async def list_tasks( :type destination_id: List[str] :param trigger_type: Type of task trigger for filtering the list of tasks. :type trigger_type: List[TriggerType] + :param with_email_notifications: If specified, the response only includes tasks with notifications.email.enabled set to this value. + :type with_email_notifications: bool :param sort: Property by which to sort the list of tasks. :type sort: TaskSortKeys :param order: Sort order of the response, ascending or descending. @@ -3110,6 +3128,7 @@ async def list_tasks( source_type, destination_id, trigger_type, + with_email_notifications, sort, order, request_options, @@ -7708,6 +7727,12 @@ def list_tasks_with_http_info( Optional[List[TriggerType]], Field(description="Type of task trigger for filtering the list of tasks."), ] = None, + with_email_notifications: Annotated[ + Optional[StrictBool], + Field( + description="If specified, the response only includes tasks with notifications.email.enabled set to this value." + ), + ] = None, sort: Union[ Annotated[ Optional[TaskSortKeys], @@ -7750,6 +7775,8 @@ def list_tasks_with_http_info( :type destination_id: List[str] :param trigger_type: Type of task trigger for filtering the list of tasks. :type trigger_type: List[TriggerType] + :param with_email_notifications: If specified, the response only includes tasks with notifications.email.enabled set to this value. + :type with_email_notifications: bool :param sort: Property by which to sort the list of tasks. :type sort: TaskSortKeys :param order: Sort order of the response, ascending or descending. @@ -7776,6 +7803,8 @@ def list_tasks_with_http_info( _query_parameters["destinationID"] = destination_id if trigger_type is not None: _query_parameters["triggerType"] = trigger_type + if with_email_notifications is not None: + _query_parameters["withEmailNotifications"] = with_email_notifications if sort is not None: _query_parameters["sort"] = sort if order is not None: @@ -7827,6 +7856,12 @@ def list_tasks( Optional[List[TriggerType]], Field(description="Type of task trigger for filtering the list of tasks."), ] = None, + with_email_notifications: Annotated[ + Optional[StrictBool], + Field( + description="If specified, the response only includes tasks with notifications.email.enabled set to this value." + ), + ] = None, sort: Union[ Annotated[ Optional[TaskSortKeys], @@ -7869,6 +7904,8 @@ def list_tasks( :type destination_id: List[str] :param trigger_type: Type of task trigger for filtering the list of tasks. :type trigger_type: List[TriggerType] + :param with_email_notifications: If specified, the response only includes tasks with notifications.email.enabled set to this value. + :type with_email_notifications: bool :param sort: Property by which to sort the list of tasks. :type sort: TaskSortKeys :param order: Sort order of the response, ascending or descending. @@ -7885,6 +7922,7 @@ def list_tasks( source_type, destination_id, trigger_type, + with_email_notifications, sort, order, request_options, diff --git a/algoliasearch/ingestion/models/email_notifications.py b/algoliasearch/ingestion/models/email_notifications.py new file mode 100644 index 000000000..9b4ec16ee --- /dev/null +++ b/algoliasearch/ingestion/models/email_notifications.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" +Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. +""" + +from __future__ import annotations + +from json import loads +from sys import version_info +from typing import Any, Dict, Optional + +from pydantic import BaseModel, ConfigDict + +if version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +_ALIASES = { + "enabled": "enabled", +} + + +def _alias_generator(name: str) -> str: + return _ALIASES.get(name, name) + + +class EmailNotifications(BaseModel): + """ + EmailNotifications + """ + + enabled: Optional[bool] = None + """ Whether to send email notifications, note that this doesn't prevent the task from being blocked. """ + + model_config = ConfigDict( + strict=False, + use_enum_values=True, + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + alias_generator=_alias_generator, + extra="allow", + ) + + def to_json(self) -> str: + return self.model_dump_json(by_alias=True, exclude_unset=True) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of EmailNotifications from a JSON string""" + return cls.from_dict(loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias.""" + return self.model_dump( + by_alias=True, + exclude_none=True, + exclude_unset=True, + ) + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of EmailNotifications from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + return cls.model_validate(obj) diff --git a/algoliasearch/ingestion/models/notifications.py b/algoliasearch/ingestion/models/notifications.py new file mode 100644 index 000000000..75412302d --- /dev/null +++ b/algoliasearch/ingestion/models/notifications.py @@ -0,0 +1,80 @@ +# coding: utf-8 + +""" +Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. +""" + +from __future__ import annotations + +from json import loads +from sys import version_info +from typing import Any, Dict, Optional + +from pydantic import BaseModel, ConfigDict + +if version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +from algoliasearch.ingestion.models.email_notifications import EmailNotifications + +_ALIASES = { + "email": "email", +} + + +def _alias_generator(name: str) -> str: + return _ALIASES.get(name, name) + + +class Notifications(BaseModel): + """ + Notifications settings for a task. + """ + + email: EmailNotifications + + model_config = ConfigDict( + strict=False, + use_enum_values=True, + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + alias_generator=_alias_generator, + extra="allow", + ) + + def to_json(self) -> str: + return self.model_dump_json(by_alias=True, exclude_unset=True) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Notifications from a JSON string""" + return cls.from_dict(loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias.""" + return self.model_dump( + by_alias=True, + exclude_none=True, + exclude_unset=True, + ) + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Notifications from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + obj["email"] = ( + EmailNotifications.from_dict(obj["email"]) + if obj.get("email") is not None + else None + ) + + return cls.model_validate(obj) diff --git a/algoliasearch/ingestion/models/policies.py b/algoliasearch/ingestion/models/policies.py new file mode 100644 index 000000000..c6c71c8fc --- /dev/null +++ b/algoliasearch/ingestion/models/policies.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" +Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. +""" + +from __future__ import annotations + +from json import loads +from sys import version_info +from typing import Any, Dict, Optional + +from pydantic import BaseModel, ConfigDict + +if version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +_ALIASES = { + "critical_threshold": "criticalThreshold", +} + + +def _alias_generator(name: str) -> str: + return _ALIASES.get(name, name) + + +class Policies(BaseModel): + """ + Set of rules for a task. + """ + + critical_threshold: Optional[int] = None + """ The number of critical failures in a row before blocking the task and sending a notification. """ + + model_config = ConfigDict( + strict=False, + use_enum_values=True, + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + alias_generator=_alias_generator, + extra="allow", + ) + + def to_json(self) -> str: + return self.model_dump_json(by_alias=True, exclude_unset=True) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Policies from a JSON string""" + return cls.from_dict(loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias.""" + return self.model_dump( + by_alias=True, + exclude_none=True, + exclude_unset=True, + ) + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Policies from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + return cls.model_validate(obj) diff --git a/algoliasearch/ingestion/models/task.py b/algoliasearch/ingestion/models/task.py index 5005ea14c..23e5e91b2 100644 --- a/algoliasearch/ingestion/models/task.py +++ b/algoliasearch/ingestion/models/task.py @@ -19,6 +19,8 @@ from algoliasearch.ingestion.models.action_type import ActionType +from algoliasearch.ingestion.models.notifications import Notifications +from algoliasearch.ingestion.models.policies import Policies from algoliasearch.ingestion.models.task_input import TaskInput _ALIASES = { @@ -33,6 +35,8 @@ "failure_threshold": "failureThreshold", "action": "action", "cursor": "cursor", + "notifications": "notifications", + "policies": "policies", "created_at": "createdAt", "updated_at": "updatedAt", } @@ -67,6 +71,8 @@ class Task(BaseModel): action: Optional[ActionType] = None cursor: Optional[str] = None """ Date of the last cursor in RFC 3339 format. """ + notifications: Optional[Notifications] = None + policies: Optional[Policies] = None created_at: str """ Date of creation in RFC 3339 format. """ updated_at: Optional[str] = None @@ -111,5 +117,15 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: TaskInput.from_dict(obj["input"]) if obj.get("input") is not None else None ) obj["action"] = obj.get("action") + obj["notifications"] = ( + Notifications.from_dict(obj["notifications"]) + if obj.get("notifications") is not None + else None + ) + obj["policies"] = ( + Policies.from_dict(obj["policies"]) + if obj.get("policies") is not None + else None + ) return cls.model_validate(obj) diff --git a/algoliasearch/ingestion/models/task_create.py b/algoliasearch/ingestion/models/task_create.py index e2118e4ad..c3ec14901 100644 --- a/algoliasearch/ingestion/models/task_create.py +++ b/algoliasearch/ingestion/models/task_create.py @@ -19,6 +19,8 @@ from algoliasearch.ingestion.models.action_type import ActionType +from algoliasearch.ingestion.models.notifications import Notifications +from algoliasearch.ingestion.models.policies import Policies from algoliasearch.ingestion.models.task_input import TaskInput _ALIASES = { @@ -30,6 +32,8 @@ "failure_threshold": "failureThreshold", "input": "input", "cursor": "cursor", + "notifications": "notifications", + "policies": "policies", } @@ -56,6 +60,8 @@ class TaskCreate(BaseModel): input: Optional[TaskInput] = None cursor: Optional[str] = None """ Date of the last cursor in RFC 3339 format. """ + notifications: Optional[Notifications] = None + policies: Optional[Policies] = None model_config = ConfigDict( strict=False, @@ -96,5 +102,15 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: obj["input"] = ( TaskInput.from_dict(obj["input"]) if obj.get("input") is not None else None ) + obj["notifications"] = ( + Notifications.from_dict(obj["notifications"]) + if obj.get("notifications") is not None + else None + ) + obj["policies"] = ( + Policies.from_dict(obj["policies"]) + if obj.get("policies") is not None + else None + ) return cls.model_validate(obj) diff --git a/algoliasearch/ingestion/models/task_update.py b/algoliasearch/ingestion/models/task_update.py index 939804654..d1c0c21db 100644 --- a/algoliasearch/ingestion/models/task_update.py +++ b/algoliasearch/ingestion/models/task_update.py @@ -18,6 +18,8 @@ from typing_extensions import Self +from algoliasearch.ingestion.models.notifications import Notifications +from algoliasearch.ingestion.models.policies import Policies from algoliasearch.ingestion.models.task_input import TaskInput _ALIASES = { @@ -26,6 +28,8 @@ "input": "input", "enabled": "enabled", "failure_threshold": "failureThreshold", + "notifications": "notifications", + "policies": "policies", } @@ -47,6 +51,8 @@ class TaskUpdate(BaseModel): """ Whether the task is enabled. """ failure_threshold: Optional[int] = None """ Maximum accepted percentage of failures for a task run to finish successfully. """ + notifications: Optional[Notifications] = None + policies: Optional[Policies] = None model_config = ConfigDict( strict=False, @@ -86,5 +92,15 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: obj["input"] = ( TaskInput.from_dict(obj["input"]) if obj.get("input") is not None else None ) + obj["notifications"] = ( + Notifications.from_dict(obj["notifications"]) + if obj.get("notifications") is not None + else None + ) + obj["policies"] = ( + Policies.from_dict(obj["policies"]) + if obj.get("policies") is not None + else None + ) return cls.model_validate(obj) diff --git a/algoliasearch/ingestion/models/task_v1.py b/algoliasearch/ingestion/models/task_v1.py index 6cbc1363b..8c6a0390e 100644 --- a/algoliasearch/ingestion/models/task_v1.py +++ b/algoliasearch/ingestion/models/task_v1.py @@ -19,6 +19,8 @@ from algoliasearch.ingestion.models.action_type import ActionType +from algoliasearch.ingestion.models.notifications import Notifications +from algoliasearch.ingestion.models.policies import Policies from algoliasearch.ingestion.models.task_input import TaskInput from algoliasearch.ingestion.models.trigger import Trigger @@ -32,6 +34,8 @@ "failure_threshold": "failureThreshold", "action": "action", "cursor": "cursor", + "notifications": "notifications", + "policies": "policies", "created_at": "createdAt", "updated_at": "updatedAt", } @@ -61,6 +65,8 @@ class TaskV1(BaseModel): action: Optional[ActionType] = None cursor: Optional[str] = None """ Date of the last cursor in RFC 3339 format. """ + notifications: Optional[Notifications] = None + policies: Optional[Policies] = None created_at: str """ Date of creation in RFC 3339 format. """ updated_at: Optional[str] = None @@ -110,5 +116,15 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: TaskInput.from_dict(obj["input"]) if obj.get("input") is not None else None ) obj["action"] = obj.get("action") + obj["notifications"] = ( + Notifications.from_dict(obj["notifications"]) + if obj.get("notifications") is not None + else None + ) + obj["policies"] = ( + Policies.from_dict(obj["policies"]) + if obj.get("policies") is not None + else None + ) return cls.model_validate(obj)