Skip to content

Commit

Permalink
feat(specs): add notification settings to tasks [skip-bc] (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4297

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
algolia-bot and millotp committed Jan 6, 2025
1 parent 0787cfa commit e561c4e
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 0 deletions.
38 changes: 38 additions & 0 deletions algoliasearch/ingestion/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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.
Expand All @@ -3110,6 +3128,7 @@ async def list_tasks(
source_type,
destination_id,
trigger_type,
with_email_notifications,
sort,
order,
request_options,
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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.
Expand All @@ -7885,6 +7922,7 @@ def list_tasks(
source_type,
destination_id,
trigger_type,
with_email_notifications,
sort,
order,
request_options,
Expand Down
73 changes: 73 additions & 0 deletions algoliasearch/ingestion/models/email_notifications.py
Original file line number Diff line number Diff line change
@@ -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)
80 changes: 80 additions & 0 deletions algoliasearch/ingestion/models/notifications.py
Original file line number Diff line number Diff line change
@@ -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)
73 changes: 73 additions & 0 deletions algoliasearch/ingestion/models/policies.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions algoliasearch/ingestion/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -33,6 +35,8 @@
"failure_threshold": "failureThreshold",
"action": "action",
"cursor": "cursor",
"notifications": "notifications",
"policies": "policies",
"created_at": "createdAt",
"updated_at": "updatedAt",
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Loading

0 comments on commit e561c4e

Please sign in to comment.