|
| 1 | +# coding=utf-8 |
| 2 | +# |
| 3 | +# Copyright 2014-2016 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 | +"""BIG-IP® LTM data-group submodule. |
| 18 | +
|
| 19 | +REST URI |
| 20 | + ``http://localhost/mgmt/tm/ltm/data-group/`` |
| 21 | +
|
| 22 | +GUI Path |
| 23 | + ``Local Traffic --> iRules --> Data Group List`` |
| 24 | +
|
| 25 | +REST Kind |
| 26 | + ``tm:ltm:data-group*`` |
| 27 | +""" |
| 28 | + |
| 29 | +from f5.bigip.resource import Collection |
| 30 | +from f5.bigip.resource import OrganizingCollection |
| 31 | +from f5.bigip.resource import Resource |
| 32 | + |
| 33 | + |
| 34 | +class Data_Group(OrganizingCollection): |
| 35 | + def __init__(self, ltm): |
| 36 | + super(Data_Group, self).__init__(ltm) |
| 37 | + self._meta_data['allowed_lazy_attributes'] = [ |
| 38 | + Internals, |
| 39 | + Internal, |
| 40 | + Externals, |
| 41 | + External |
| 42 | + ] |
| 43 | + |
| 44 | + |
| 45 | +class Internals(Collection): |
| 46 | + def __init__(self, data_groups): |
| 47 | + super(Internals, self).__init__(data_groups) |
| 48 | + self._meta_data['allowed_lazy_attributes'] = [Internal] |
| 49 | + self._meta_data['required_json_kind'] = \ |
| 50 | + u'tm:ltm:data-group:internal:internalcollectionstate' |
| 51 | + self._meta_data['attribute_registry'] = \ |
| 52 | + {u'tm:ltm:data-group:internal:internalstate': Internal} |
| 53 | + self._meta_data['uri'] = self._meta_data['uri'].replace('_', '-') |
| 54 | + |
| 55 | + |
| 56 | +class Internal(Resource): |
| 57 | + def __init__(self, internals): |
| 58 | + super(Internal, self).__init__(internals) |
| 59 | + self._meta_data['required_json_kind'] = \ |
| 60 | + u'tm:ltm:data-group:internal:internalstate' |
| 61 | + self._meta_data['required_creation_parameters'].update( |
| 62 | + ('name', 'type', 'records') |
| 63 | + ) |
| 64 | + |
| 65 | + def update(self, **kwargs): |
| 66 | + if 'type' in self.__dict__: |
| 67 | + del self.__dict__['type'] |
| 68 | + return self._update(**kwargs) |
| 69 | + |
| 70 | + |
| 71 | +class Externals(Collection): |
| 72 | + def __init__(self, data_groups): |
| 73 | + super(Externals, self).__init__(data_groups) |
| 74 | + self._meta_data['allowed_lazy_attributes'] = [External] |
| 75 | + self._meta_data['required_json_kind'] =\ |
| 76 | + u'tm:ltm:data-group:external:externalcollectionstate' |
| 77 | + self._meta_data['attribute_registry'] =\ |
| 78 | + {u'tm:ltm:data-group:external:externalstate': External} |
| 79 | + self._meta_data['uri'] = self._meta_data['uri'].replace('_', '-') |
| 80 | + |
| 81 | + |
| 82 | +class External(Resource): |
| 83 | + def __init__(self, externals): |
| 84 | + super(External, self).__init__(externals) |
| 85 | + self._meta_data['required_json_kind'] =\ |
| 86 | + u'tm:ltm:data-group:external:externalstate' |
| 87 | + self._meta_data['required_creation_parameters'].update( |
| 88 | + ('name', 'externalFileName') |
| 89 | + ) |
0 commit comments