|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +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. |
| 5 | +""" |
| 6 | + |
| 7 | +from __future__ import annotations |
| 8 | + |
| 9 | +from json import loads |
| 10 | +from sys import version_info |
| 11 | +from typing import Any, Dict, List, Optional |
| 12 | + |
| 13 | +from pydantic import BaseModel, ConfigDict |
| 14 | + |
| 15 | +if version_info >= (3, 11): |
| 16 | + from typing import Self |
| 17 | +else: |
| 18 | + from typing_extensions import Self |
| 19 | + |
| 20 | + |
| 21 | +from algoliasearch.search.models.event import Event |
| 22 | + |
| 23 | +_ALIASES = { |
| 24 | + "run_id": "runID", |
| 25 | + "event_id": "eventID", |
| 26 | + "data": "data", |
| 27 | + "events": "events", |
| 28 | + "message": "message", |
| 29 | + "created_at": "createdAt", |
| 30 | +} |
| 31 | + |
| 32 | + |
| 33 | +def _alias_generator(name: str) -> str: |
| 34 | + return _ALIASES.get(name, name) |
| 35 | + |
| 36 | + |
| 37 | +class WatchResponse(BaseModel): |
| 38 | + """ |
| 39 | + WatchResponse |
| 40 | + """ |
| 41 | + |
| 42 | + run_id: str |
| 43 | + """ Universally unique identifier (UUID) of a task run. """ |
| 44 | + event_id: Optional[str] = None |
| 45 | + """ Universally unique identifier (UUID) of an event. """ |
| 46 | + data: Optional[List[object]] = None |
| 47 | + """ This field is always null when used with the Push endpoint. When used for a source discover or source validate run, it will include the sampled data of the source. """ |
| 48 | + events: Optional[List[Event]] = None |
| 49 | + """ in case of error, observability events will be added to the response. """ |
| 50 | + message: Optional[str] = None |
| 51 | + """ a message describing the outcome of the operation that has been ran (push, discover or validate) run. """ |
| 52 | + created_at: Optional[str] = None |
| 53 | + """ Date of creation in RFC 3339 format. """ |
| 54 | + |
| 55 | + model_config = ConfigDict( |
| 56 | + strict=False, |
| 57 | + use_enum_values=True, |
| 58 | + populate_by_name=True, |
| 59 | + validate_assignment=True, |
| 60 | + protected_namespaces=(), |
| 61 | + alias_generator=_alias_generator, |
| 62 | + extra="allow", |
| 63 | + ) |
| 64 | + |
| 65 | + def to_json(self) -> str: |
| 66 | + return self.model_dump_json(by_alias=True, exclude_unset=True) |
| 67 | + |
| 68 | + @classmethod |
| 69 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 70 | + """Create an instance of WatchResponse from a JSON string""" |
| 71 | + return cls.from_dict(loads(json_str)) |
| 72 | + |
| 73 | + def to_dict(self) -> Dict[str, Any]: |
| 74 | + """Return the dictionary representation of the model using alias.""" |
| 75 | + return self.model_dump( |
| 76 | + by_alias=True, |
| 77 | + exclude_none=True, |
| 78 | + exclude_unset=True, |
| 79 | + ) |
| 80 | + |
| 81 | + @classmethod |
| 82 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 83 | + """Create an instance of WatchResponse from a dict""" |
| 84 | + if obj is None: |
| 85 | + return None |
| 86 | + |
| 87 | + if not isinstance(obj, dict): |
| 88 | + return cls.model_validate(obj) |
| 89 | + |
| 90 | + obj["events"] = ( |
| 91 | + [Event.from_dict(_item) for _item in obj["events"]] |
| 92 | + if obj.get("events") is not None |
| 93 | + else None |
| 94 | + ) |
| 95 | + |
| 96 | + return cls.model_validate(obj) |
0 commit comments