|
| 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 | +"""BIG-IP® SMTP Server module |
| 19 | +
|
| 20 | +REST URI |
| 21 | + ``http://localhost/mgmt/sys/smtp-server/`` |
| 22 | +
|
| 23 | +GUI Path |
| 24 | + ``Systems > Configuration > Device > SMTP`` |
| 25 | +
|
| 26 | +REST Kind |
| 27 | + ``tm:sys:smtp-server:*`` |
| 28 | +""" |
| 29 | + |
| 30 | +from f5.bigip.mixins import ExclusiveAttributesMixin |
| 31 | +from f5.bigip.resource import Collection |
| 32 | +from f5.bigip.resource import Resource |
| 33 | + |
| 34 | + |
| 35 | +class Smtp_Servers(Collection): |
| 36 | + def __init__(self, sys): |
| 37 | + super(Smtp_Servers, self).__init__(sys) |
| 38 | + self._meta_data['allowed_lazy_attributes'] = [Smtp_Server] |
| 39 | + self._meta_data['attribute_registry'] = { |
| 40 | + 'tm:sys:smtp-server:smtp-serverstate': Smtp_Server |
| 41 | + } |
| 42 | + |
| 43 | + |
| 44 | +class Smtp_Server(Resource, ExclusiveAttributesMixin): |
| 45 | + def __init__(self, smtp_servers): |
| 46 | + super(Smtp_Server, self).__init__(smtp_servers) |
| 47 | + self._meta_data['required_json_kind'] = 'tm:sys:smtp-server:smtp-serverstate' |
| 48 | + self._meta_data['exclusive_attributes'].append(('authenticationDisabled', 'authenticationEnabled')) |
| 49 | + |
| 50 | + def _endis_attrs(self): |
| 51 | + if 'authenticationDisabled' in self.__dict__: |
| 52 | + self.__dict__['authenticationEnabled'] = not self.__dict__['authenticationDisabled'] |
| 53 | + if 'authenticationEnabled' in self.__dict__: |
| 54 | + self.__dict__['authenticationDisabled'] = not self.__dict__['authenticationEnabled'] |
| 55 | + return None |
| 56 | + |
| 57 | + def create(self, **kwargs): |
| 58 | + inst = self._create(**kwargs) |
| 59 | + inst._endis_attrs() |
| 60 | + return inst |
| 61 | + |
| 62 | + def load(self, **kwargs): |
| 63 | + kwargs = self._reduce_boolean_pair(kwargs, 'authenticationEnabled', 'authenticationDisabled') |
| 64 | + inst = self._load(**kwargs) |
| 65 | + inst._endis_attrs() |
| 66 | + return inst |
| 67 | + |
| 68 | + def refresh(self, **kwargs): |
| 69 | + kwargs = self._reduce_boolean_pair(kwargs, 'authenticationEnabled', 'authenticationDisabled') |
| 70 | + self._refresh(**kwargs) |
| 71 | + self._endis_attrs() |
| 72 | + return self |
| 73 | + |
| 74 | + def update(self, **kwargs): |
| 75 | + if 'authenticationEnabled' in kwargs or 'authenticationDisabled' in kwargs: |
| 76 | + self.__dict__.pop('authenticationEnabled') |
| 77 | + self.__dict__.pop('authenticationDisabled') |
| 78 | + kwargs = self._reduce_boolean_pair(kwargs, 'authenticationEnabled', 'authenticationDisabled') |
| 79 | + self.__dict__ = self._reduce_boolean_pair(self.__dict__, 'authenticationEnabled', 'authenticationDisabled') |
| 80 | + self._update(**kwargs) |
| 81 | + self._endis_attrs() |
0 commit comments