Source code for sdk.lusid.models.result_data_key_rule

# 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.result_key_rule import ResultKeyRule

[docs] class ResultDataKeyRule(ResultKeyRule): """ ResultDataKeyRule """ supplier: StrictStr = Field(...,alias="supplier", description="the result resource supplier (where the data comes from)") data_scope: StrictStr = Field(...,alias="dataScope", description="which is the scope in which the data should be found") document_code: StrictStr = Field(...,alias="documentCode", description="document code that defines which document is desired") quote_interval: Optional[StrictStr] = Field(None,alias="quoteInterval", description="Shorthand for the time interval used to select result data. This must be a dot-separated string specifying a start and end date, for example '5D.0D' to look back 5 days from today (0 days ago).") as_at: Optional[datetime] = Field(default=None, description="The AsAt predicate specification.", alias="asAt") resource_key: StrictStr = Field(...,alias="resourceKey", description="The result data key that identifies the address pattern that this is a rule for") document_result_type: StrictStr = Field(...,alias="documentResultType") use_document_to_infer_holdings: Optional[StrictBool] = Field(default=None, description="Indicates whether the relevant document should be used to infer the set of holdings in the valuation.", alias="useDocumentToInferHoldings") result_key_rule_type: StrictStr = Field(...,alias="resultKeyRuleType", description="Available values: Invalid, ResultDataKeyRule, PortfolioResultDataKeyRule.") additional_properties: Dict[str, Any] = {} __properties = ["resultKeyRuleType", "supplier", "dataScope", "documentCode", "quoteInterval", "asAt", "resourceKey", "documentResultType", "useDocumentToInferHoldings"]
[docs] @validator('result_key_rule_type') def result_key_rule_type_validate_enum(cls, value): """Validates the enum""" # Finbourne have removed enum validation on all models, except for this use case: # Workflow and notification application SDK use the property name 'type' as the discriminator on a number of classes. # During instantiation, the value of 'type' is checked against the enum values, # check it's a class that uses the 'type' property as a discriminator # list of classes can be found by searching for 'actual_instance: Union[' in the generated code if 'ResultDataKeyRule' not in [ # For notification application classes 'AmazonSqsNotificationType', 'AmazonSqsNotificationTypeResponse', 'AmazonSqsPrincipalAuthNotificationType', 'AmazonSqsPrincipalAuthNotificationTypeResponse', 'AzureServiceBusTypeResponse', 'AzureServiceBusNotificationType', 'EmailNotificationType', 'EmailNotificationTypeResponse', 'SmsNotificationType', 'SmsNotificationTypeResponse', 'WebhookNotificationType', 'WebhookNotificationTypeResponse', # For workflow application classes 'CreateChildTasksAction', 'RunWorkerAction', 'TriggerParentTaskAction', 'CreateChildTasksActionResponse', 'RunWorkerActionResponse', 'TriggerChildTasksAction', 'TriggerChildTasksActionResponse', 'TriggerParentTaskActionResponse', 'CreateNewTaskActivity', 'UpdateMatchingTasksActivity', 'CreateNewTaskActivityResponse', 'UpdateMatchingTasksActivityResponse', 'Fail', 'GroupReconciliation', 'HealthCheck', 'LuminesceView', 'SchedulerJob', 'Sleep', 'FailResponse', 'GroupReconciliationResponse', 'HealthCheckResponse', 'LuminesceViewResponse', 'SchedulerJobResponse', 'SleepResponse', 'Library', 'LibraryResponse', 'DayRegularity', 'RelativeMonthRegularity', 'SpecificMonthRegularity', 'WeekRegularity', 'YearRegularity', 'LusidEntityDataQualityCheck', 'LusidEntityDataQualityCheckResponse', 'TriggerChildTasksActionResponse']: return value # Only validate the 'type' property of the class if "result_key_rule_type" != "type": return value if value not in ['Invalid', 'ResultDataKeyRule', 'PortfolioResultDataKeyRule']: raise ValueError("must be one of enum values ('Invalid', 'ResultDataKeyRule', 'PortfolioResultDataKeyRule')") return value
[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) -> ResultDataKeyRule: """Create an instance of ResultDataKeyRule 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={ "additional_properties" }, exclude_none=True) # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: for _key, _value in self.additional_properties.items(): _dict[_key] = _value # set to None if quote_interval (nullable) is None # and __fields_set__ contains the field if self.quote_interval is None and "quote_interval" in self.__fields_set__: _dict['quoteInterval'] = 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 return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> ResultDataKeyRule: """Create an instance of ResultDataKeyRule from a dict""" if obj is None: return None if not isinstance(obj, dict): return ResultDataKeyRule.parse_obj(obj) _obj = ResultDataKeyRule.parse_obj({ "result_key_rule_type": obj.get("resultKeyRuleType"), "supplier": obj.get("supplier"), "data_scope": obj.get("dataScope"), "document_code": obj.get("documentCode"), "quote_interval": obj.get("quoteInterval"), "as_at": obj.get("asAt"), "resource_key": obj.get("resourceKey"), "document_result_type": obj.get("documentResultType"), "use_document_to_infer_holdings": obj.get("useDocumentToInferHoldings") }) # store additional fields in additional_properties for _key in obj.keys(): if _key not in cls.__properties: _obj.additional_properties[_key] = obj.get(_key) return _obj
ResultDataKeyRule.update_forward_refs()