wallaroo.wallaroo_ml_ops_api_client.models.v1_task_get_by_status_response_200_tasks_item

  1from typing import Any, Dict, List, Type, TypeVar, Union
  2
  3import attr
  4
  5from ..models.v1_task_get_by_status_response_200_tasks_item_flavor_type_0 import \
  6    V1TaskGetByStatusResponse200TasksItemFlavorType0
  7from ..models.v1_task_get_by_status_response_200_tasks_item_flavor_type_1 import \
  8    V1TaskGetByStatusResponse200TasksItemFlavorType1
  9from ..models.v1_task_get_by_status_response_200_tasks_item_flavor_type_2 import \
 10    V1TaskGetByStatusResponse200TasksItemFlavorType2
 11
 12T = TypeVar("T", bound="V1TaskGetByStatusResponse200TasksItem")
 13
 14@attr.s(auto_attribs=True)
 15class V1TaskGetByStatusResponse200TasksItem:
 16    """
 17    Attributes:
 18        id (str):
 19        flavor (Union[V1TaskGetByStatusResponse200TasksItemFlavorType0,
 20            V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]):
 21        subject (str):
 22        attempt (int):
 23    """
 24
 25    id: str
 26    flavor: Union[V1TaskGetByStatusResponse200TasksItemFlavorType0, V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]
 27    subject: str
 28    attempt: int
 29    additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
 30
 31
 32    def to_dict(self) -> Dict[str, Any]:
 33        id = self.id
 34        flavor: Union[Dict[str, Any], str]
 35
 36        if isinstance(self.flavor, V1TaskGetByStatusResponse200TasksItemFlavorType0):
 37            flavor = self.flavor.value
 38
 39        elif isinstance(self.flavor, V1TaskGetByStatusResponse200TasksItemFlavorType1):
 40            flavor = self.flavor.value
 41
 42        else:
 43            flavor = self.flavor.to_dict()
 44
 45
 46
 47        subject = self.subject
 48        attempt = self.attempt
 49
 50        field_dict: Dict[str, Any] = {}
 51        field_dict.update(self.additional_properties)
 52        field_dict.update({
 53            "id": id,
 54            "flavor": flavor,
 55            "subject": subject,
 56            "attempt": attempt,
 57        })
 58
 59        return field_dict
 60
 61
 62
 63    @classmethod
 64    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
 65        d = src_dict.copy()
 66        id = d.pop("id")
 67
 68        def _parse_flavor(data: object) -> Union[V1TaskGetByStatusResponse200TasksItemFlavorType0, V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]:
 69            try:
 70                if not isinstance(data, str):
 71                    raise TypeError()
 72                flavor_type_0 = V1TaskGetByStatusResponse200TasksItemFlavorType0(data)
 73
 74
 75
 76                return flavor_type_0
 77            except: # noqa: E722
 78                pass
 79            try:
 80                if not isinstance(data, str):
 81                    raise TypeError()
 82                flavor_type_1 = V1TaskGetByStatusResponse200TasksItemFlavorType1(data)
 83
 84
 85
 86                return flavor_type_1
 87            except: # noqa: E722
 88                pass
 89            if not isinstance(data, dict):
 90                raise TypeError()
 91            flavor_type_2 = V1TaskGetByStatusResponse200TasksItemFlavorType2.from_dict(data)
 92
 93
 94
 95            return flavor_type_2
 96
 97        flavor = _parse_flavor(d.pop("flavor"))
 98
 99
100        subject = d.pop("subject")
101
102        attempt = d.pop("attempt")
103
104        v1_task_get_by_status_response_200_tasks_item = cls(
105            id=id,
106            flavor=flavor,
107            subject=subject,
108            attempt=attempt,
109        )
110
111        v1_task_get_by_status_response_200_tasks_item.additional_properties = d
112        return v1_task_get_by_status_response_200_tasks_item
113
114    @property
115    def additional_keys(self) -> List[str]:
116        return list(self.additional_properties.keys())
117
118    def __getitem__(self, key: str) -> Any:
119        return self.additional_properties[key]
120
121    def __setitem__(self, key: str, value: Any) -> None:
122        self.additional_properties[key] = value
123
124    def __delitem__(self, key: str) -> None:
125        del self.additional_properties[key]
126
127    def __contains__(self, key: str) -> bool:
128        return key in self.additional_properties
@attr.s(auto_attribs=True)
class V1TaskGetByStatusResponse200TasksItem:
 15@attr.s(auto_attribs=True)
 16class V1TaskGetByStatusResponse200TasksItem:
 17    """
 18    Attributes:
 19        id (str):
 20        flavor (Union[V1TaskGetByStatusResponse200TasksItemFlavorType0,
 21            V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]):
 22        subject (str):
 23        attempt (int):
 24    """
 25
 26    id: str
 27    flavor: Union[V1TaskGetByStatusResponse200TasksItemFlavorType0, V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]
 28    subject: str
 29    attempt: int
 30    additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
 31
 32
 33    def to_dict(self) -> Dict[str, Any]:
 34        id = self.id
 35        flavor: Union[Dict[str, Any], str]
 36
 37        if isinstance(self.flavor, V1TaskGetByStatusResponse200TasksItemFlavorType0):
 38            flavor = self.flavor.value
 39
 40        elif isinstance(self.flavor, V1TaskGetByStatusResponse200TasksItemFlavorType1):
 41            flavor = self.flavor.value
 42
 43        else:
 44            flavor = self.flavor.to_dict()
 45
 46
 47
 48        subject = self.subject
 49        attempt = self.attempt
 50
 51        field_dict: Dict[str, Any] = {}
 52        field_dict.update(self.additional_properties)
 53        field_dict.update({
 54            "id": id,
 55            "flavor": flavor,
 56            "subject": subject,
 57            "attempt": attempt,
 58        })
 59
 60        return field_dict
 61
 62
 63
 64    @classmethod
 65    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
 66        d = src_dict.copy()
 67        id = d.pop("id")
 68
 69        def _parse_flavor(data: object) -> Union[V1TaskGetByStatusResponse200TasksItemFlavorType0, V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]:
 70            try:
 71                if not isinstance(data, str):
 72                    raise TypeError()
 73                flavor_type_0 = V1TaskGetByStatusResponse200TasksItemFlavorType0(data)
 74
 75
 76
 77                return flavor_type_0
 78            except: # noqa: E722
 79                pass
 80            try:
 81                if not isinstance(data, str):
 82                    raise TypeError()
 83                flavor_type_1 = V1TaskGetByStatusResponse200TasksItemFlavorType1(data)
 84
 85
 86
 87                return flavor_type_1
 88            except: # noqa: E722
 89                pass
 90            if not isinstance(data, dict):
 91                raise TypeError()
 92            flavor_type_2 = V1TaskGetByStatusResponse200TasksItemFlavorType2.from_dict(data)
 93
 94
 95
 96            return flavor_type_2
 97
 98        flavor = _parse_flavor(d.pop("flavor"))
 99
100
101        subject = d.pop("subject")
102
103        attempt = d.pop("attempt")
104
105        v1_task_get_by_status_response_200_tasks_item = cls(
106            id=id,
107            flavor=flavor,
108            subject=subject,
109            attempt=attempt,
110        )
111
112        v1_task_get_by_status_response_200_tasks_item.additional_properties = d
113        return v1_task_get_by_status_response_200_tasks_item
114
115    @property
116    def additional_keys(self) -> List[str]:
117        return list(self.additional_properties.keys())
118
119    def __getitem__(self, key: str) -> Any:
120        return self.additional_properties[key]
121
122    def __setitem__(self, key: str, value: Any) -> None:
123        self.additional_properties[key] = value
124
125    def __delitem__(self, key: str) -> None:
126        del self.additional_properties[key]
127
128    def __contains__(self, key: str) -> bool:
129        return key in self.additional_properties

Attributes: id (str): flavor (Union[V1TaskGetByStatusResponse200TasksItemFlavorType0, V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]): subject (str): attempt (int):

2def __init__(self, id, flavor, subject, attempt):
3    self.id = id
4    self.flavor = flavor
5    self.subject = subject
6    self.attempt = attempt
7    self.additional_properties = __attr_factory_additional_properties()

Method generated by attrs for class V1TaskGetByStatusResponse200TasksItem.

def to_dict(self) -> Dict[str, Any]:
33    def to_dict(self) -> Dict[str, Any]:
34        id = self.id
35        flavor: Union[Dict[str, Any], str]
36
37        if isinstance(self.flavor, V1TaskGetByStatusResponse200TasksItemFlavorType0):
38            flavor = self.flavor.value
39
40        elif isinstance(self.flavor, V1TaskGetByStatusResponse200TasksItemFlavorType1):
41            flavor = self.flavor.value
42
43        else:
44            flavor = self.flavor.to_dict()
45
46
47
48        subject = self.subject
49        attempt = self.attempt
50
51        field_dict: Dict[str, Any] = {}
52        field_dict.update(self.additional_properties)
53        field_dict.update({
54            "id": id,
55            "flavor": flavor,
56            "subject": subject,
57            "attempt": attempt,
58        })
59
60        return field_dict
@classmethod
def from_dict(cls: Type[~T], src_dict: Dict[str, Any]) -> ~T:
 64    @classmethod
 65    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
 66        d = src_dict.copy()
 67        id = d.pop("id")
 68
 69        def _parse_flavor(data: object) -> Union[V1TaskGetByStatusResponse200TasksItemFlavorType0, V1TaskGetByStatusResponse200TasksItemFlavorType1, V1TaskGetByStatusResponse200TasksItemFlavorType2]:
 70            try:
 71                if not isinstance(data, str):
 72                    raise TypeError()
 73                flavor_type_0 = V1TaskGetByStatusResponse200TasksItemFlavorType0(data)
 74
 75
 76
 77                return flavor_type_0
 78            except: # noqa: E722
 79                pass
 80            try:
 81                if not isinstance(data, str):
 82                    raise TypeError()
 83                flavor_type_1 = V1TaskGetByStatusResponse200TasksItemFlavorType1(data)
 84
 85
 86
 87                return flavor_type_1
 88            except: # noqa: E722
 89                pass
 90            if not isinstance(data, dict):
 91                raise TypeError()
 92            flavor_type_2 = V1TaskGetByStatusResponse200TasksItemFlavorType2.from_dict(data)
 93
 94
 95
 96            return flavor_type_2
 97
 98        flavor = _parse_flavor(d.pop("flavor"))
 99
100
101        subject = d.pop("subject")
102
103        attempt = d.pop("attempt")
104
105        v1_task_get_by_status_response_200_tasks_item = cls(
106            id=id,
107            flavor=flavor,
108            subject=subject,
109            attempt=attempt,
110        )
111
112        v1_task_get_by_status_response_200_tasks_item.additional_properties = d
113        return v1_task_get_by_status_response_200_tasks_item
additional_keys: List[str]