# 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 List, Dict, Optional, Any, Union, TYPE_CHECKING
from typing_extensions import Annotated
from pydantic.v1 import BaseModel, StrictStr, StrictInt, StrictBool, StrictFloat, StrictBytes, Field, validator, ValidationError, conlist, constr
from datetime import datetime
from lusid.models.event_date_range import EventDateRange
from lusid.models.instrument_event import InstrumentEvent
from lusid.models.perpetual_property import PerpetualProperty
from lusid.models.resource_id import ResourceId
[docs]
class InstrumentEventHolder(BaseModel):
"""
An instrument event equipped with additional metadata. # noqa: E501
"""
instrument_event_id: StrictStr = Field(...,alias="instrumentEventId", description="The unique identifier of this corporate action.")
corporate_action_source_id: Optional[ResourceId] = Field(default=None, alias="corporateActionSourceId")
instrument_identifiers: Dict[str, Optional[StrictStr]] = Field(description="The set of identifiers which determine the instrument this event relates to.", alias="instrumentIdentifiers")
lusid_instrument_id: StrictStr = Field(...,alias="lusidInstrumentId", description="The LUID for the instrument.")
instrument_scope: StrictStr = Field(...,alias="instrumentScope", description="The scope of the instrument.")
description: StrictStr = Field(...,alias="description", description="The description of the instrument event.")
event_date_range: EventDateRange = Field(alias="eventDateRange")
completeness: Optional[StrictStr] = Field(None,alias="completeness", description="Is the event Economically Complete, or is it missing some DataDependent fields (Incomplete). Available values: Complete, Incomplete.")
instrument_event: InstrumentEvent = Field(alias="instrumentEvent")
properties: Optional[List[PerpetualProperty]] = Field(default=None, description="The properties attached to this instrument event.")
sequence_number: Optional[StrictInt] = Field(default=None, description="The order of the instrument event relative others on the same date (0 being processed first). Must be non negative.", alias="sequenceNumber")
participation_type: Optional[StrictStr] = Field(None,alias="participationType", description="Indicates the type of participation in this event. Default value: Mandatory. Available values: Mandatory, MandatoryWithChoices, Voluntary.")
as_at: Optional[datetime] = Field(default=None, description="The AsAt time of the instrument event, if available. This is a readonly field and should not be provided on upsert.", alias="asAt")
group_code: Optional[StrictStr] = Field(None,alias="groupCode", description="The group code that determines the processing order of instrument events with the same effective datetime. Available values: Tier1, Tier2, Tier3, Legacy.")
__properties = ["instrumentEventId", "corporateActionSourceId", "instrumentIdentifiers", "lusidInstrumentId", "instrumentScope", "description", "eventDateRange", "completeness", "instrumentEvent", "properties", "sequenceNumber", "participationType", "asAt", "groupCode"]
[docs]
class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
validate_assignment = True
def __str__(self):
"""For `print` and `pprint`"""
return pprint.pformat(self.dict(by_alias=False))
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
[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) -> InstrumentEventHolder:
"""Create an instance of InstrumentEventHolder 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={
"completeness",
"as_at",
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of corporate_action_source_id
if self.corporate_action_source_id:
_dict['corporateActionSourceId'] = self.corporate_action_source_id.to_dict()
# override the default output from pydantic by calling `to_dict()` of event_date_range
if self.event_date_range:
_dict['eventDateRange'] = self.event_date_range.to_dict()
# override the default output from pydantic by calling `to_dict()` of instrument_event
if self.instrument_event:
_dict['instrumentEvent'] = self.instrument_event.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in properties (list)
_items = []
if self.properties:
for _item in self.properties:
if _item:
_items.append(_item.to_dict())
_dict['properties'] = _items
# set to None if completeness (nullable) is None
# and __fields_set__ contains the field
if self.completeness is None and "completeness" in self.__fields_set__:
_dict['completeness'] = None
# set to None if properties (nullable) is None
# and __fields_set__ contains the field
if self.properties is None and "properties" in self.__fields_set__:
_dict['properties'] = None
# set to None if participation_type (nullable) is None
# and __fields_set__ contains the field
if self.participation_type is None and "participation_type" in self.__fields_set__:
_dict['participationType'] = None
# set to None if as_at (nullable) is None
# and __fields_set__ contains the field
if self.as_at is None and "as_at" in self.__fields_set__:
_dict['asAt'] = None
# set to None if group_code (nullable) is None
# and __fields_set__ contains the field
if self.group_code is None and "group_code" in self.__fields_set__:
_dict['groupCode'] = None
return _dict
[docs]
@classmethod
def from_dict(cls, obj: dict) -> InstrumentEventHolder:
"""Create an instance of InstrumentEventHolder from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return InstrumentEventHolder.parse_obj(obj)
_obj = InstrumentEventHolder.parse_obj({
"instrument_event_id": obj.get("instrumentEventId"),
"corporate_action_source_id": ResourceId.from_dict(obj.get("corporateActionSourceId")) if obj.get("corporateActionSourceId") is not None else None,
"instrument_identifiers": obj.get("instrumentIdentifiers"),
"lusid_instrument_id": obj.get("lusidInstrumentId"),
"instrument_scope": obj.get("instrumentScope"),
"description": obj.get("description"),
"event_date_range": EventDateRange.from_dict(obj.get("eventDateRange")) if obj.get("eventDateRange") is not None else None,
"completeness": obj.get("completeness"),
"instrument_event": InstrumentEvent.from_dict(obj.get("instrumentEvent")) if obj.get("instrumentEvent") is not None else None,
"properties": [PerpetualProperty.from_dict(_item) for _item in obj.get("properties")] if obj.get("properties") is not None else None,
"sequence_number": obj.get("sequenceNumber"),
"participation_type": obj.get("participationType") if obj.get("participationType") is not None else 'Mandatory',
"as_at": obj.get("asAt"),
"group_code": obj.get("groupCode")
})
return _obj
InstrumentEventHolder.update_forward_refs()