blob: d9588174e373191df2599839a87199ad70d360b1 [file] [log] [blame]
Vladimir Jigulin57ecae92018-09-10 22:51:15 +04001# Copyright 2017 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13
14
15from kubernetes import client
16
17from tcp_tests.managers.k8s.base import K8sBaseResource
18from tcp_tests.managers.k8s.base import K8sBaseManager
19
20
21class K8sClusterRoleBinding(K8sBaseResource):
22 resource_type = 'clusterrolebindings'
23
24 def _read(self, **kwargs):
25 return self._manager.api.read_cluster_role_binding(self.name, **kwargs)
26
27 def _create(self, body, **kwargs):
28 return self._manager.api.create_cluster_role_binding(body, **kwargs)
29
30 def _patch(self, body, **kwargs):
31 return self._manager.api.patch_cluster_role_binding(
32 self.name, body, **kwargs)
33
34 def _replace(self, body, **kwargs):
35 return self._manager.api.replace_cluster_role_binding(
36 self.name, body, **kwargs)
37
38 def _delete(self, **kwargs):
39 self._manager.api.delete_cluster_role_binding(
40 self.name, client.V1DeleteOptions(), **kwargs)
41
42
43class K8sClusterRoleBindingManager(K8sBaseManager):
44 resource_class = K8sClusterRoleBinding
45
46 @property
47 def api(self):
48 return self._cluster.api_rbac_auth
49
50 def _list(self, namespace, **kwargs):
51 return self.api.list_cluster_role_binding(**kwargs)
52
53 def _list_all(self, **kwargs):
54 return self._list(None, **kwargs)