1 # Copyright (C) 2021 Wind River Systems, Inc.
\r
3 # Licensed under the Apache License, Version 2.0 (the "License");
\r
4 # you may not use this file except in compliance with the License.
\r
5 # You may obtain a copy of the License at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
9 # Unless required by applicable law or agreed to in writing, software
\r
10 # distributed under the License is distributed on an "AS IS" BASIS,
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 # See the License for the specific language governing permissions and
\r
13 # limitations under the License.
\r
16 from typing import List, Set
\r
17 from o2ims.domain.stx_object import StxGenericModel
\r
18 from o2ims.domain.resource_type import ResourceTypeEnum
\r
21 class StxObjectRepository(abc.ABC):
\r
23 self.seen = set() # type: Set[StxGenericModel]
\r
25 def add(self, stx_obj: StxGenericModel):
\r
27 self.seen.add(stx_obj)
\r
29 def get(self, stx_obj_id) -> StxGenericModel:
\r
30 stx_obj = self._get(stx_obj_id)
\r
32 self.seen.add(stx_obj)
\r
35 def list(self, type: ResourceTypeEnum) -> List[StxGenericModel]:
\r
36 return self._list(type)
\r
38 def update(self, stx_obj: StxGenericModel):
\r
39 self._update(stx_obj)
\r
41 # def update_fields(self, stx_obj_id: str, updatefields: dict):
\r
42 # self._update(stx_obj_id, updatefields)
\r
45 def _add(self, stx_obj: StxGenericModel):
\r
46 raise NotImplementedError
\r
49 def _get(self, stx_obj_id) -> StxGenericModel:
\r
50 raise NotImplementedError
\r
53 def _update(self, stx_obj: StxGenericModel):
\r
54 raise NotImplementedError
\r
57 def _list(self, type: ResourceTypeEnum):
\r
58 raise NotImplementedError
\r