X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fdomain%2Fconfiguration_repo.py;fp=o2ims%2Fdomain%2Fconfiguration_repo.py;h=9ff95fa8bcffaf6323759e05b933b821ae871177;hb=209f349b35b0919ac133bc2264f25753a73e5b8f;hp=0000000000000000000000000000000000000000;hpb=a413c895f34fd2aa0eaa72254243673ae0477d27;p=pti%2Fo2.git diff --git a/o2ims/domain/configuration_repo.py b/o2ims/domain/configuration_repo.py new file mode 100644 index 0000000..9ff95fa --- /dev/null +++ b/o2ims/domain/configuration_repo.py @@ -0,0 +1,57 @@ +# Copyright (C) 2021 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import abc +from typing import List, Set +from o2ims.domain import configuration_obj as obj + + +class ConfigurationRepository(abc.ABC): + def __init__(self): + self.seen = set() # type: Set[obj.Configuration] + + def add(self, configuration: obj.Configuration): + self._add(configuration) + self.seen.add(configuration) + + def get(self, configuration_id) -> obj.Configuration: + configuration = self._get(configuration_id) + if configuration: + self.seen.add(configuration) + return configuration + + def list(self) -> List[obj.Configuration]: + return self._list() + + def update(self, configuration: obj.Configuration): + self._update(configuration) + + def delete(self, configuration_id): + self._delete(configuration_id) + + @abc.abstractmethod + def _add(self, configuration: obj.Configuration): + raise NotImplementedError + + @abc.abstractmethod + def _get(self, configuration_id) -> obj.Configuration: + raise NotImplementedError + + @abc.abstractmethod + def _update(self, configuration: obj.Configuration): + raise NotImplementedError + + @abc.abstractmethod + def _delete(self, configuration_id): + raise NotImplementedError