|
120 | 120 | from f5.sdk_exception import MissingRequiredCommandParameter |
121 | 121 | from f5.sdk_exception import MissingRequiredCreationParameter |
122 | 122 | from f5.sdk_exception import MissingRequiredReadParameter |
| 123 | +from f5.sdk_exception import MissingRequiredRequestsParameter |
123 | 124 | from f5.sdk_exception import RequestParamKwargCollision |
124 | 125 | from f5.sdk_exception import UnregisteredKind |
125 | 126 | from f5.sdk_exception import UnsupportedMethod |
@@ -817,6 +818,34 @@ def get_collection(self, **kwargs): |
817 | 818 | raise UnregisteredKind(error_message) |
818 | 819 | return list_of_contents |
819 | 820 |
|
| 821 | + def _delete_collection(self, **kwargs): |
| 822 | + """wrapped with delete_collection, override that in a sublcass to customize """ |
| 823 | + error_message = "The request must include \"requests_params\": {\"params\": \"options=<glob pattern>\"} as kwarg" |
| 824 | + try: |
| 825 | + if kwargs['requests_params']['params'].split('=')[0] != 'options': |
| 826 | + raise MissingRequiredRequestsParameter(error_message) |
| 827 | + except KeyError: |
| 828 | + raise |
| 829 | + |
| 830 | + requests_params = self._handle_requests_params(kwargs) |
| 831 | + delete_uri = self._meta_data['uri'] |
| 832 | + session = self._meta_data['bigip']._meta_data['icr_session'] |
| 833 | + |
| 834 | + session.delete(delete_uri, **requests_params) |
| 835 | + |
| 836 | + def delete_collection(self, **kwargs): |
| 837 | + """One can not simply delete a collection. |
| 838 | +
|
| 839 | + This is to support odata usage via the options request parameter: |
| 840 | +
|
| 841 | + ``requests_params={'params': 'options=glob_pattern'}`` |
| 842 | +
|
| 843 | + where glob_pattern can be used to delete one or all of a particular |
| 844 | + collection. Not submitting the requests params will fail, and specifying |
| 845 | + patterns that match default resources will fail as well. |
| 846 | + """ |
| 847 | + self._delete_collection(**kwargs) |
| 848 | + |
820 | 849 |
|
821 | 850 | class Resource(ResourceBase): |
822 | 851 | """Base class to represent a Configurable Resource on the device. |
|
0 commit comments