Source code for sdk.lusid.models.upsert_instrument_event_request

# 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.instrument_event import InstrumentEvent
from lusid.models.perpetual_property import PerpetualProperty
from lusid.models.year_month_day import YearMonthDay

[docs] class UpsertInstrumentEventRequest(BaseModel): """ UpsertInstrumentEventRequest """ instrument_event_id: StrictStr = Field(...,alias="instrumentEventId", description="Free string that uniquely identifies the event within the corporate action source") instrument_identifiers: Dict[str, Optional[StrictStr]] = Field(description="The set of identifiers which determine the instrument this event relates to.", alias="instrumentIdentifiers") description: Optional[StrictStr] = Field(None,alias="description", description="The description of the instrument event.") 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.") event_date_stamps: Optional[Dict[str, YearMonthDay]] = Field(default=None, description="The date stamps corresponding to the relevant date-time fields for the instrument event. The key for each provided date stamp must match the field name of a valid datetime field from the InstrumentEvent DTO.", alias="eventDateStamps") __properties = ["instrumentEventId", "instrumentIdentifiers", "description", "instrumentEvent", "properties", "sequenceNumber", "participationType", "eventDateStamps"]
[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) -> UpsertInstrumentEventRequest: """Create an instance of UpsertInstrumentEventRequest 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 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 # override the default output from pydantic by calling `to_dict()` of each value in event_date_stamps (dict) _field_dict = {} if self.event_date_stamps: for _key in self.event_date_stamps: if self.event_date_stamps[_key]: _field_dict[_key] = self.event_date_stamps[_key].to_dict() _dict['eventDateStamps'] = _field_dict # set to None if description (nullable) is None # and __fields_set__ contains the field if self.description is None and "description" in self.__fields_set__: _dict['description'] = 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 sequence_number (nullable) is None # and __fields_set__ contains the field if self.sequence_number is None and "sequence_number" in self.__fields_set__: _dict['sequenceNumber'] = 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 event_date_stamps (nullable) is None # and __fields_set__ contains the field if self.event_date_stamps is None and "event_date_stamps" in self.__fields_set__: _dict['eventDateStamps'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> UpsertInstrumentEventRequest: """Create an instance of UpsertInstrumentEventRequest from a dict""" if obj is None: return None if not isinstance(obj, dict): return UpsertInstrumentEventRequest.parse_obj(obj) _obj = UpsertInstrumentEventRequest.parse_obj({ "instrument_event_id": obj.get("instrumentEventId"), "instrument_identifiers": obj.get("instrumentIdentifiers"), "description": obj.get("description"), "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', "event_date_stamps": dict( (_k, YearMonthDay.from_dict(_v)) for _k, _v in obj.get("eventDateStamps").items() ) if obj.get("eventDateStamps") is not None else None }) return _obj
UpsertInstrumentEventRequest.update_forward_refs()