Source code for sdk.lusid.models.data_type_summary

# coding: utf-8

"""
    LUSID API

    FINBOURNE Technology  # noqa: E501

    Contact: info@finbourne.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


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


from typing import Any, Dict, List, Optional
from pydantic.v1 import BaseModel, Field, StrictStr, conlist, constr, validator
from lusid.models.i_unit_definition_dto import IUnitDefinitionDto
from lusid.models.resource_id import ResourceId
from lusid.models.version import Version

[docs] class DataTypeSummary(BaseModel): """ DataTypeSummary """ type_value_range: StrictStr = Field(..., alias="typeValueRange", description="Indicates the range of data acceptable by a data type. The available values are: Open, Closed") id: ResourceId = Field(...) display_name: constr(strict=True, min_length=1) = Field(..., alias="displayName", description="The display name of the data type.") description: constr(strict=True, min_length=1) = Field(..., description="The description of the data type.") value_type: StrictStr = Field(..., alias="valueType", description="The expected type of the values. The available values are: String, Int, Decimal, DateTime, Boolean, Map, List, PropertyArray, Percentage, Code, Id, Uri, CurrencyAndAmount, TradePrice, Currency, MetricValue, ResourceId, ResultValue, CutLocalTime, DateOrCutLabel, UnindexedText") acceptable_values: Optional[conlist(StrictStr)] = Field(None, alias="acceptableValues", description="The acceptable set of values for this data type. Only applies to 'open' value type range.") unit_schema: Optional[StrictStr] = Field(None, alias="unitSchema", description="The schema of the data type's units. The available values are: NoUnits, Basic, Iso4217Currency") acceptable_units: Optional[conlist(IUnitDefinitionDto)] = Field(None, alias="acceptableUnits", description="The definitions of the acceptable units.") version: Optional[Version] = None __properties = ["typeValueRange", "id", "displayName", "description", "valueType", "acceptableValues", "unitSchema", "acceptableUnits", "version"]
[docs] @validator('type_value_range') def type_value_range_validate_enum(cls, value): """Validates the enum""" if value not in ('Open', 'Closed'): raise ValueError("must be one of enum values ('Open', 'Closed')") return value
[docs] @validator('value_type') def value_type_validate_enum(cls, value): """Validates the enum""" if value not in ('String', 'Int', 'Decimal', 'DateTime', 'Boolean', 'Map', 'List', 'PropertyArray', 'Percentage', 'Code', 'Id', 'Uri', 'CurrencyAndAmount', 'TradePrice', 'Currency', 'MetricValue', 'ResourceId', 'ResultValue', 'CutLocalTime', 'DateOrCutLabel', 'UnindexedText'): raise ValueError("must be one of enum values ('String', 'Int', 'Decimal', 'DateTime', 'Boolean', 'Map', 'List', 'PropertyArray', 'Percentage', 'Code', 'Id', 'Uri', 'CurrencyAndAmount', 'TradePrice', 'Currency', 'MetricValue', 'ResourceId', 'ResultValue', 'CutLocalTime', 'DateOrCutLabel', 'UnindexedText')") return value
[docs] @validator('unit_schema') def unit_schema_validate_enum(cls, value): """Validates the enum""" if value is None: return value if value not in ('NoUnits', 'Basic', 'Iso4217Currency'): raise ValueError("must be one of enum values ('NoUnits', 'Basic', 'Iso4217Currency')") return value
[docs] class Config: """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True
[docs] def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.dict(by_alias=True))
[docs] def to_json(self) -> str: """Returns the JSON representation of the model using alias""" return json.dumps(self.to_dict())
[docs] @classmethod def from_json(cls, json_str: str) -> DataTypeSummary: """Create an instance of DataTypeSummary from a JSON string""" return cls.from_dict(json.loads(json_str))
[docs] def to_dict(self): """Returns the dictionary representation of the model using alias""" _dict = self.dict(by_alias=True, exclude={ }, exclude_none=True) # override the default output from pydantic by calling `to_dict()` of id if self.id: _dict['id'] = self.id.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in acceptable_units (list) _items = [] if self.acceptable_units: for _item in self.acceptable_units: if _item: _items.append(_item.to_dict()) _dict['acceptableUnits'] = _items # override the default output from pydantic by calling `to_dict()` of version if self.version: _dict['version'] = self.version.to_dict() # set to None if acceptable_values (nullable) is None # and __fields_set__ contains the field if self.acceptable_values is None and "acceptable_values" in self.__fields_set__: _dict['acceptableValues'] = None # set to None if acceptable_units (nullable) is None # and __fields_set__ contains the field if self.acceptable_units is None and "acceptable_units" in self.__fields_set__: _dict['acceptableUnits'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> DataTypeSummary: """Create an instance of DataTypeSummary from a dict""" if obj is None: return None if not isinstance(obj, dict): return DataTypeSummary.parse_obj(obj) _obj = DataTypeSummary.parse_obj({ "type_value_range": obj.get("typeValueRange"), "id": ResourceId.from_dict(obj.get("id")) if obj.get("id") is not None else None, "display_name": obj.get("displayName"), "description": obj.get("description"), "value_type": obj.get("valueType"), "acceptable_values": obj.get("acceptableValues"), "unit_schema": obj.get("unitSchema"), "acceptable_units": [IUnitDefinitionDto.from_dict(_item) for _item in obj.get("acceptableUnits")] if obj.get("acceptableUnits") is not None else None, "version": Version.from_dict(obj.get("version")) if obj.get("version") is not None else None }) return _obj