-
Notifications
You must be signed in to change notification settings - Fork 8
/
shared_types.py
162 lines (104 loc) · 3.88 KB
/
shared_types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from abc import ABC
from pydantic import BaseModel
from datetime import datetime
from typing import List, Optional, Union
from vortexasdk.api.id import ID
IDsNames = Union[List[Union[ID, str]], str, ID]
ISODate = str
# noinspection PyPep8Naming
def to_ISODate(utc_datetime: datetime) -> ISODate:
return utc_datetime.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
def to_ISODate_Array(days: List[datetime]) -> List[ISODate]:
return [to_ISODate(date) for date in days]
class EntityWithSingleLayer(BaseModel):
"""Holds commonly used properties."""
id: ID
layer: Optional[str] = None
label: Optional[str] = None
class EntityWithSingleLayerAndTimespan(BaseModel):
id: ID
layer: Optional[str] = None
label: Optional[str] = None
start_timestamp: Optional[ISODate] = None
end_timestamp: Optional[ISODate] = None
class EntityWithListLayer(BaseModel):
"""Holds commonly used properties."""
id: ID
layer: Optional[List[str]] = None
label: Optional[str] = None
class EntityWithSingleLayerAndProbability(BaseModel):
"""
Extension of `Entity`, containing additional properties.
- `probability` the probability of an entity occurring.
- `source` the source of this entity, (is typically one of `['model', 'external_data']`
"""
id: ID
probability: Optional[float] = None
source: Optional[str] = None
layer: Optional[str] = None
label: Optional[str] = None
class EntityWithListLayerAndProbability(BaseModel):
"""
Extension of `Entity`, containing additional properties.
- `probability` the probability of an entity occurring.
- `source` the source of this entity, (is typically one of `['model', 'external_data']`
"""
id: ID
probability: Optional[float] = None
source: Optional[str] = None
layer: Optional[List[str]]
label: Optional[str] = None
class IDName(BaseModel):
"""Tuple containing `id` and `name`."""
id: ID
name: Optional[str] = None
class IDLayer(BaseModel):
"""Tuple containing `id` and `layer`."""
id: ID
layer: Optional[str] = None
label: Optional[str] = None
class IDNameLayer(BaseModel):
"""Triple holding `id`, `name`, and `layer`."""
id: ID
layer: Optional[List[str]] = None
name: Optional[str] = None
class Node(ABC, IDName, BaseModel):
"""
Abstract Base Class holding a node of a tree.
# Attributes:
ref_type: Optional[Identifies the reference type data] = None
leaf: Is this node a leaf of the hierarchical tree?
parent: List of parents
"""
ref_type: Optional[str] = None
leaf: Optional[bool] = None
parent: Optional[List[IDNameLayer]] = None
class Tag(BaseModel):
"""
Represents a property that is associated with a period of time.
A good example is if a vessel has acted as an FSO during a time period.
[Tags Further Documentation](https://docs.vortexa.com/reference/intro-tags)
"""
tag: Optional[str] = None
start_timestamp: Optional[ISODate] = None
end_timestamp: Optional[ISODate] = None
class Flag(BaseModel):
"""
Represents a property that is associated with a vessel's flag.
- `flag` key will be a Geography Entity ID.
- `flag_country` key will be the ISO code for the country
[Geography Entity Further Documentation](https://docs.vortexa.com/reference/intro-geography-entries)
"""
tag: Optional[str] = None
flag: Optional[str] = None
flag_country: Optional[str] = None
class Scrubber(BaseModel):
"""
Represents information about scrubbers fitted to a vessel.
- `scrubber` key will be the type of scrubber.
- `planned` key is if this scrubber has not yet been fitted but is planned.
An empty `scrubber` List may mean the scrubber status is unknown or a vessel has none fitted.
"""
tag: Optional[str] = None
scrubber: Optional[str] = None
planned: Optional[bool] = None