| Requires any of the roles: | Riskstore.Write, Riskstore.Admin |
| GET | /api/riskstore/analysis | Search for analyses |
|---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryBase:
skip: Optional[int] = None
take: Optional[int] = None
order_by: Optional[str] = None
order_by_desc: Optional[str] = None
include: Optional[str] = None
fields: Optional[str] = None
meta: Optional[Dict[str, str]] = None
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryDb(Generic[T], QueryBase, IReturn[QueryResponse[T]]):
@staticmethod
def response_type(): return QueryResponse[T]
class ResultOutputLevel(str, Enum):
NOT_SET = 'NotSet'
PORTFOLIO_METRICS = 'PortfolioMetrics'
CURVE = 'Curve'
YLT = 'YLT'
TAIL_INTENSITY = 'TailIntensity'
DEAL_YLT = 'DealYlt'
DEAL_ELT = 'DealElt'
DEAL_ELT_WITH_INDUSTRY_LOSS = 'DealEltWithIndustryLoss'
PORTFOLIO_ELT = 'PortfolioElt'
PORTFOLIO_ELT_WITH_INDUSTRY_LOSS = 'PortfolioEltWithIndustryLoss'
EVENT_SET_GENERATION = 'EventSetGeneration'
PORTFOLIO_RAPS = 'PortfolioRaps'
DEAL_RAPS = 'DealRaps'
PORTFOLIO_SEPY_INDUSTRY_LOSS = 'PortfolioSepyIndustryLoss'
DEAL_SEPY_INDUSTRY_LOSS = 'DealSepyIndustryLoss'
class ProcessingStatus(IntEnum):
NEW = 0
PROCESSING = 1
FAILED = 10
SUCCESSFUL = 20
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisPortfolioEventSetConfiguration(IObjectWithId, IHasAnalysisId):
id: int = 0
analysis_id: int = 0
analysis_configuration_id: int = 0
portfolio_name: Optional[str] = None
model_id: Optional[str] = None
row_identifier: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisConfiguration(IObjectWithId, IHasAnalysisId):
id: int = 0
analysis_id: int = 0
window_start_date: Optional[datetime.datetime] = None
window_end_date: Optional[datetime.datetime] = None
standard_enabled: bool = False
run_off_enabled: bool = False
aggregate_enabled: bool = False
occurrence_enabled: bool = False
nett_enabled: bool = False
gross_enabled: bool = False
tail_intensity_percentage_start: Optional[Decimal] = None
tail_intensity_percentage_end: Optional[Decimal] = None
meta_risk_id: int = 0
output_level: Optional[ResultOutputLevel] = None
processing_status: Optional[ProcessingStatus] = None
event_loss_floor_start_range: Optional[Decimal] = None
event_loss_floor_end_range: Optional[Decimal] = None
analysis_portfolio_event_set_configurations: Optional[List[AnalysisPortfolioEventSetConfiguration]] = None
row_identifier: Optional[str] = None
class TransactionType(str, Enum):
NOT_SET = 'NotSet'
S = 'S'
B = 'B'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisPortfolioAllocation(IObjectWithId):
id: int = 0
analysis_deal_id: int = 0
# @Validate(Validator="NotEmpty", Message="PortfolioName is mandatory")
portfolio_name: Optional[str] = None
allocation_percentage: float = 0.0
row_identifier: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisDeal(IObjectWithId, IHasAnalysisId):
id: int = 0
analysis_id: int = 0
source_deal_id: Optional[str] = None
deal_ref: Optional[str] = None
source_deal_system: Optional[str] = None
event_set_id: int = 0
rol: float = 0.0
limit: float = 0.0
inception_date: datetime.datetime = datetime.datetime(1, 1, 1)
expiry_date: datetime.datetime = datetime.datetime(1, 1, 1)
transaction_type: Optional[TransactionType] = None
allocations: Optional[List[AnalysisPortfolioAllocation]] = None
perspective_id_override: Optional[int] = None
event_set_id_override: Optional[int] = None
model_as_of_date_override: Optional[datetime.datetime] = None
source_model_system_override: Optional[str] = None
source_model_id_override: Optional[str] = None
source_event_set_id_override: Optional[str] = None
event_source_system_override: Optional[str] = None
row_identifier: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AnalysisEventIdFilter(IObjectWithId, IHasAnalysisId):
id: int = 0
analysis_id: int = 0
event_source_id: int = 0
event_id: int = 0
row_identifier: Optional[str] = None
class MessageType(str, Enum):
NOT_SET = 'NotSet'
PERSISTENCE = 'Persistence'
ARCHIVAL = 'Archival'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class MessageTracking:
id: Optional[str] = None
analysis_id: Optional[int] = None
processing_status: Optional[ProcessingStatus] = None
message_type: Optional[MessageType] = None
created_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)
updated_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Analysis(IObjectWithId):
id: int = 0
name: Optional[str] = None
model_as_of_date: Optional[datetime.datetime] = None
perspective_id: int = 0
configurations: Optional[List[AnalysisConfiguration]] = None
deals: Optional[List[AnalysisDeal]] = None
event_id_filters: Optional[List[AnalysisEventIdFilter]] = None
created_by: Optional[str] = None
created_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)
completed_date_utc: Optional[datetime.datetime] = None
legacy_analysis_id: Optional[int] = None
result_persistence_tracking: Optional[List[MessageTracking]] = None
processing_status: Optional[ProcessingStatus] = None
save_results: bool = False
event_source_system: Optional[str] = None
updated_date_utc: datetime.datetime = datetime.datetime(1, 1, 1)
is_expired: bool = False
row_identifier: Optional[str] = None
error_message: Optional[str] = None
# @ApiMember(DataType="boolean", Description="Take the minimum simulation count when we have different simulations between event sets")
ignore_simulation_count_mismatch: bool = False
"""
Take the minimum simulation count when we have different simulations between event sets
"""
# @Ignore()
final_status: Optional[ProcessingStatus] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FindAnalysisRequest(QueryDb[Analysis]):
# @ApiMember(DataType="integer", Description="The Ids of the Analyses", Format="int64")
ids: Optional[List[int]] = None
"""
The Ids of the Analyses
"""
# @ApiMember(DataType="string", Description="The partial name of the analyses")
name: Optional[str] = None
"""
The partial name of the analyses
"""
# @ApiMember(DataType="boolean", Description="Filter only Standard analysis type")
standard_enabled: Optional[bool] = None
"""
Filter only Standard analysis type
"""
# @ApiMember(DataType="boolean", Description="Filter only Run Off analysis type")
run_off_enabled: Optional[bool] = None
"""
Filter only Run Off analysis type
"""
# @ApiMember(DataType="integer", Description="The perspective id used for the analysis", Format="int32")
perspective_id: Optional[int] = None
"""
The perspective id used for the analysis
"""
# @ApiMember(DataType="string", Description="The partial name of the user who run the analysis")
created_by: Optional[str] = None
"""
The partial name of the user who run the analysis
"""
# @ApiMember(DataType="string", Description="The analysis run date to filter from", Format="date-time")
analysis_run_from_date_time: Optional[datetime.datetime] = None
"""
The analysis run date to filter from
"""
# @ApiMember(DataType="string", Description="The analysis run date to filter to", Format="date-time")
analysis_run_to_date_time: Optional[datetime.datetime] = None
"""
The analysis run date to filter to
"""
# @ApiMember(DataType="integer", Description="The status of the analysis. 1 = Processing, 10 = Failed, 20 = Successful", Format="int32")
processing_status: Optional[ProcessingStatus] = None
"""
The status of the analysis. 1 = Processing, 10 = Failed, 20 = Successful
"""
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryResponse(Generic[T]):
offset: int = 0
total: int = 0
results: Optional[List[Analysis]] = None
meta: Optional[Dict[str, str]] = None
response_status: Optional[ResponseStatus] = None
Python FindAnalysisRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /api/riskstore/analysis HTTP/1.1 Host: riskstoreng-dev.nephila.com Accept: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"offset":0,"total":0,"results":[{"id":0,"name":"String","modelAsOfDate":"0001-01-01T00:00:00.0000000Z","perspectiveId":0,"configurations":[{"id":0,"analysisId":0,"windowStartDate":"0001-01-01T00:00:00.0000000Z","windowEndDate":"0001-01-01T00:00:00.0000000Z","standardEnabled":false,"runOffEnabled":false,"aggregateEnabled":false,"occurrenceEnabled":false,"nettEnabled":false,"grossEnabled":false,"tailIntensityPercentageStart":0,"tailIntensityPercentageEnd":0,"metaRiskId":0,"outputLevel":"NotSet","processingStatus":"New","eventLossFloorStartRange":0,"eventLossFloorEndRange":0,"analysisPortfolioEventSetConfigurations":[{"id":0,"analysisId":0,"analysisConfigurationId":0,"portfolioName":"String","modelId":"String","rowIdentifier":"00000000000000000000000000000000"}],"rowIdentifier":"00000000000000000000000000000000"}],"deals":[{"id":0,"analysisId":0,"sourceDealId":"String","dealRef":"String","sourceDealSystem":"String","eventSetId":0,"rol":0,"limit":0,"inceptionDate":"0001-01-01T00:00:00.0000000Z","expiryDate":"0001-01-01T00:00:00.0000000Z","transactionType":"NotSet","allocations":[{"id":0,"analysisDealId":0,"portfolioName":"String","allocationPercentage":0,"rowIdentifier":"00000000000000000000000000000000"}],"perspectiveIdOverride":0,"eventSetIdOverride":0,"modelAsOfDateOverride":"0001-01-01T00:00:00.0000000Z","sourceModelSystemOverride":"String","sourceModelIdOverride":"String","sourceEventSetIdOverride":"String","eventSourceSystemOverride":"String","rowIdentifier":"00000000000000000000000000000000"}],"eventIdFilters":[{"id":0,"analysisId":0,"eventSourceId":0,"eventId":0,"rowIdentifier":"00000000000000000000000000000000"}],"createdBy":"String","createdDateUtc":"0001-01-01T00:00:00.0000000Z","completedDateUtc":"0001-01-01T00:00:00.0000000Z","legacyAnalysisId":0,"resultPersistenceTracking":[{"id":"00000000000000000000000000000000","analysisId":0,"processingStatus":"New","messageType":"NotSet","createdDateUtc":"0001-01-01T00:00:00.0000000Z","updatedDateUtc":"0001-01-01T00:00:00.0000000Z"}],"processingStatus":"New","saveResults":false,"eventSourceSystem":"String","updatedDateUtc":"0001-01-01T00:00:00.0000000Z","isExpired":false,"rowIdentifier":"00000000000000000000000000000000","errorMessage":"String","ignoreSimulationCountMismatch":false,"finalStatus":"New"}],"meta":{"String":"String"},"responseStatus":{"__type":"ServiceStack.ResponseStatus, ServiceStack.Interfaces","errorCode":"String","message":"String","stackTrace":"String","errors":[{"__type":"ServiceStack.ResponseError, ServiceStack.Interfaces","errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}