|
| 1 | +# coding=utf-8 |
| 2 | +# |
| 3 | +# Copyright 2018 F5 Networks Inc. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +from f5.bigip.mixins import ExclusiveAttributesMixin |
| 19 | +from f5.bigip.resource import OrganizingCollection |
| 20 | +from f5.bigip.resource import UnnamedResource |
| 21 | +from f5.sdk_exception import UnsupportedOperation |
| 22 | + |
| 23 | + |
| 24 | +class Feature_Module(OrganizingCollection): |
| 25 | + def __init__(self, feature_module): |
| 26 | + super(Feature_Module, self).__init__(feature_module) |
| 27 | + self._meta_data['allowed_lazy_attributes'] = [Cgnat] |
| 28 | + self._meta_data['attribute_registry'] = {'tm:sys:feature-module:feature-modulestate': Cgnat} |
| 29 | + |
| 30 | + |
| 31 | +class Cgnat(UnnamedResource, ExclusiveAttributesMixin): |
| 32 | + def __init__(self, feature_module): |
| 33 | + super(Cgnat, self).__init__(feature_module) |
| 34 | + self._meta_data['required_json_kind'] = 'tm:sys:feature-module:feature-modulestate' |
| 35 | + self._meta_data['exclusive_attributes'].append(('enabled', 'disabled')) |
| 36 | + |
| 37 | + def _endis_attrs(self): |
| 38 | + if 'disabled' in self.__dict__: |
| 39 | + self.__dict__['enabled'] = not self.__dict__['disabled'] |
| 40 | + if 'enabled' in self.__dict__: |
| 41 | + self.__dict__['disabled'] = not self.__dict__['enabled'] |
| 42 | + return None |
| 43 | + |
| 44 | + def load(self, **kwargs): |
| 45 | + kwargs = self._reduce_boolean_pair(kwargs, 'enabled', 'disabled') |
| 46 | + newinst = self._stamp_out_core() |
| 47 | + newinst._refresh(**kwargs) |
| 48 | + newinst._endis_attrs() |
| 49 | + return newinst |
| 50 | + |
| 51 | + def refresh(self, **kwargs): |
| 52 | + kwargs = self._reduce_boolean_pair(kwargs, 'enabled', 'disabled') |
| 53 | + self._refresh(**kwargs) |
| 54 | + self._endis_attrs() |
| 55 | + return self |
| 56 | + |
| 57 | + def update(self, **kwargs): |
| 58 | + if 'enabled' in kwargs or 'disabled' in kwargs: |
| 59 | + self.__dict__.pop('enabled') |
| 60 | + self.__dict__.pop('disabled') |
| 61 | + self._update(**kwargs) |
| 62 | + self._endis_attrs() |
| 63 | + |
| 64 | + def modify(self, **kwargs): |
| 65 | + if 'enabled' in kwargs or 'disabled' in kwargs: |
| 66 | + self.__dict__.pop('enabled') |
| 67 | + self.__dict__.pop('disabled') |
| 68 | + self._modify(**kwargs) |
| 69 | + self._endis_attrs() |
| 70 | + |
| 71 | + def create(self, **kwargs): |
| 72 | + '''Create is not supported for db resources. |
| 73 | +
|
| 74 | + :raises: UnsupportedOperation |
| 75 | + ''' |
| 76 | + raise UnsupportedOperation( |
| 77 | + "Resource doesn't support create." |
| 78 | + ) |
| 79 | + |
| 80 | + def delete(self, **kwargs): |
| 81 | + '''Delete is not supported for db resources. |
| 82 | +
|
| 83 | + :raises: UnsupportedOperation |
| 84 | + ''' |
| 85 | + raise UnsupportedOperation( |
| 86 | + "Resource doesn't support delete." |
| 87 | + ) |
0 commit comments