553bec2aab53fa40916e977b8e2437f1618c72fa
[dcaegen2/platform.git] / oti / event-handler / otihandler / dbclient / models / event.py
1 # ================================================================================
2 # Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=========================================================
16
17 """ ORM - mapping class for dtih_event table """
18
19 from sqlalchemy import Column, String, Integer, ForeignKey, func
20 from sqlalchemy.dialects.postgresql import JSONB, TIMESTAMP
21 from sqlalchemy.ext.declarative import declarative_base
22 import datetime
23
24
25 Base = declarative_base()
26
27 class Event(Base):
28     __tablename__ = 'dtih_event'
29     __table_args__ = {'schema': 'dti'}
30     dtih_event_id = Column(Integer, primary_key=True)
31     event = Column(JSONB)
32     create_ts = Column(TIMESTAMP(timezone=True), default=func.now())
33     last_modified_ts = Column(TIMESTAMP(timezone=True), default=func.now())
34     target_name = Column(String)
35     target_type = Column(String)
36     location_clli = Column(String)
37     # def __repr__(self):
38     #     return "<Event(event_id='%s', target_type='%s', target_name='%s')" % (
39     #         self.event_id, self.target_type, self.target_name
40     #     )