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 o2dms.domain import dms
20 class NfDeploymentRepository(abc.ABC):
22 self.seen = set() # type: Set[dms.NfDeployment]
24 def add(self, nfdeployment: dms.NfDeployment):
25 self._add(nfdeployment)
26 self.seen.add(nfdeployment)
28 def get(self, nfdeployment_id) -> dms.NfDeployment:
29 nfdeployment = self._get(nfdeployment_id)
31 self.seen.add(nfdeployment)
34 def list(self) -> List[dms.NfDeployment]:
37 def update(self, id, **kwargs):
38 self._update(id, **kwargs)
40 def delete(self, nfdeployment_id):
41 self._delete(nfdeployment_id)
43 def count(self, **kwargs):
44 return self._count(**kwargs)
47 def _add(self, nfdeployment: dms.NfDeployment):
48 raise NotImplementedError
51 def _get(self, nfdeployment_id) -> dms.NfDeployment:
52 raise NotImplementedError
55 def _update(self, id, **kwargs):
56 raise NotImplementedError
59 def _delete(self, nfdeployment_id):
60 raise NotImplementedError
63 def _count(self, **kwargs):
64 raise NotImplementedError
67 class NfDeploymentDescRepository(abc.ABC):
69 self.seen = set() # type: Set[dms.NfDeploymentDesc]
71 def add(self, nfdeployment_descriptor: dms.NfDeploymentDesc):
72 self._add(nfdeployment_descriptor)
73 self.seen.add(nfdeployment_descriptor)
75 def get(self, nfdeployment_descriptor_id) -> dms.NfDeploymentDesc:
76 nfdeployment_descriptor = self._get(nfdeployment_descriptor_id)
77 if nfdeployment_descriptor:
78 self.seen.add(nfdeployment_descriptor)
79 return nfdeployment_descriptor
81 def list(self) -> List[dms.NfDeploymentDesc]:
84 def update(self, id, **kwargs):
85 self._update(id, **kwargs)
87 def delete(self, nfdeployment_descriptor_id):
88 self._delete(nfdeployment_descriptor_id)
90 def count(self, **kwargs):
91 return self._count(**kwargs)
94 def _add(self, nfdeployment_descriptor: dms.NfDeploymentDesc):
95 raise NotImplementedError
98 def _get(self, nfdeployment_descriptor_id) -> dms.NfDeploymentDesc:
99 raise NotImplementedError
102 def _update(self, id, **kwargs):
103 raise NotImplementedError
106 def _delete(self, nfdeployment_descriptor_id):
107 raise NotImplementedError
110 def _count(self, **kwargs):
111 raise NotImplementedError
114 class NfOCloudVResourceRepository(abc.ABC):
116 self.seen = set() # type: Set[dms.NfOCloudVResource]
118 def add(self, nfocloudvres: dms.NfOCloudVResource):
119 self._add(nfocloudvres)
120 self.seen.add(nfocloudvres)
122 def get(self, nfocloudvres_id) -> dms.NfOCloudVResource:
123 nfocloudvres = self._get(nfocloudvres_id)
125 self.seen.add(nfocloudvres)
128 def list(self) -> List[dms.NfOCloudVResource]:
131 def update(self, nfocloudvres_id, **kwargs):
132 self._update(nfocloudvres_id, **kwargs)
134 def delete(self, nfocloudvres_id):
135 self._delete(nfocloudvres_id)
138 def _add(self, nfocloudvres: dms.NfOCloudVResource):
139 raise NotImplementedError
142 def _get(self, nfocloudvres_id) -> dms.NfOCloudVResource:
143 raise NotImplementedError
146 def _update(self, nfocloudvres_id, **kwargs):
147 raise NotImplementedError
150 def _delete(self, nfocloudvres_id):
151 raise NotImplementedError