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