1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 class HandlerBase(object):
18 def __init__(self, topology, model):
19 self._topology = topology
22 def coerce(self, **kwargs):
23 raise NotImplementedError
25 def _coerce(self, *models, **kwargs):
26 for template in models:
27 self._topology.coerce(template, **kwargs)
29 def validate(self, **kwargs):
30 raise NotImplementedError
32 def _validate(self, *models, **kwargs):
33 for template in models:
34 self._topology.validate(template, **kwargs)
36 def dump(self, out_stream):
37 raise NotImplementedError
40 class TemplateHandlerBase(HandlerBase):
42 Base handler for template based models
45 def instantiate(self, instance_cls, **kwargs):
46 raise NotImplementedError
49 class InstanceHandlerBase(HandlerBase):
51 Base handler for instance based models
54 def validate(self, **kwargs):
55 raise NotImplementedError
57 def coerce(self, **kwargs):
58 raise NotImplementedError
60 def dump(self, out_stream):
61 raise NotImplementedError
64 class ActorHandlerBase(HandlerBase):
66 Base handler for any model which has (or contains a field which references) an operation
68 def configure_operations(self):
69 raise NotImplementedError