Source code for openapi_client.models.datasource_flows_details_dataflow_config_table_mappings_rules_inner

# coding: utf-8

"""
    Amorphic Data Platform

    Amorphic Data Platform - API Definition documentation

    The version of the OpenAPI document: 0.3.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.dataset_lineage_task_filters_info_filter_rules_inner import DatasetLineageTaskFiltersInfoFilterRulesInner
from openapi_client.models.dataset_lineage_task_filters_info_source_table_info import DatasetLineageTaskFiltersInfoSourceTableInfo
from openapi_client.models.datasource_flows_details_dataflow_config_table_mappings_rules_inner_data_type import DatasourceFlowsDetailsDataflowConfigTableMappingsRulesInnerDataType
from typing import Optional, Set
from typing_extensions import Self

[docs] class DatasourceFlowsDetailsDataflowConfigTableMappingsRulesInner(BaseModel): """ DatasourceFlowsDetailsDataflowConfigTableMappingsRulesInner """ # noqa: E501 old_value: Optional[StrictStr] = Field(default=None, alias="old-value") rule_action: Optional[StrictStr] = Field(default=None, alias="rule-action") rule_id: Optional[StrictStr] = Field(default=None, alias="rule-id") rule_name: Optional[StrictStr] = Field(default=None, alias="rule-name") rule_target: Optional[StrictStr] = Field(default=None, alias="rule-target") rule_type: Optional[StrictStr] = Field(default=None, alias="rule-type") value: Optional[StrictStr] = None object_locator: Optional[DatasetLineageTaskFiltersInfoSourceTableInfo] = Field(default=None, alias="object-locator") data_type: Optional[DatasourceFlowsDetailsDataflowConfigTableMappingsRulesInnerDataType] = Field(default=None, alias="data-type") filters: Optional[List[DatasetLineageTaskFiltersInfoFilterRulesInner]] = None __properties: ClassVar[List[str]] = ["old-value", "rule-action", "rule-id", "rule-name", "rule-target", "rule-type", "value", "object-locator", "data-type", "filters"] model_config = ConfigDict( populate_by_name=True, validate_assignment=True, protected_namespaces=(), )
[docs] def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True))
[docs] def to_json(self) -> str: """Returns the JSON representation of the model using alias""" # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead return json.dumps(self.to_dict())
[docs] @classmethod def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DatasourceFlowsDetailsDataflowConfigTableMappingsRulesInner from a JSON string""" return cls.from_dict(json.loads(json_str))
[docs] def to_dict(self) -> Dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's `self.model_dump(by_alias=True)`: * `None` is only added to the output dict for nullable fields that were set at model initialization. Other fields with value `None` are ignored. """ excluded_fields: Set[str] = set([ ]) _dict = self.model_dump( by_alias=True, exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of object_locator if self.object_locator: _dict['object-locator'] = self.object_locator.to_dict() # override the default output from pydantic by calling `to_dict()` of data_type if self.data_type: _dict['data-type'] = self.data_type.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in filters (list) _items = [] if self.filters: for _item_filters in self.filters: if _item_filters: _items.append(_item_filters.to_dict()) _dict['filters'] = _items return _dict
[docs] @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of DatasourceFlowsDetailsDataflowConfigTableMappingsRulesInner from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) _obj = cls.model_validate({ "old-value": obj.get("old-value"), "rule-action": obj.get("rule-action"), "rule-id": obj.get("rule-id"), "rule-name": obj.get("rule-name"), "rule-target": obj.get("rule-target"), "rule-type": obj.get("rule-type"), "value": obj.get("value"), "object-locator": DatasetLineageTaskFiltersInfoSourceTableInfo.from_dict(obj["object-locator"]) if obj.get("object-locator") is not None else None, "data-type": DatasourceFlowsDetailsDataflowConfigTableMappingsRulesInnerDataType.from_dict(obj["data-type"]) if obj.get("data-type") is not None else None, "filters": [DatasetLineageTaskFiltersInfoFilterRulesInner.from_dict(_item) for _item in obj["filters"]] if obj.get("filters") is not None else None }) return _obj