Debian Codegraph @

ansible_collections/kubernetes/core/plugins/module_utils/client/resource.py

raw symbols SCIP
1 # Copyright [2017] [Red Hat, Inc.]
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain 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,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15
16 from __future__ import absolute_import, division, print_function
17
18 __metaclass__ = type
19
20
21 import kubernetes.dynamic
22
23
24 class ResourceList(kubernetes.dynamic.resource.ResourceList):
25 def __init__(
26 self,
27 client,
28 group="",
29 api_version="v1",
30 base_kind="",
31 kind=None,
32 base_resource_lookup=None,
33 ):
34 self.client = client
35 self.group = group
36 self.api_version = api_version
37 self.kind = kind or "{0}List".format(base_kind)
38 self.base_kind = base_kind
39 self.base_resource_lookup = base_resource_lookup
40 self.__base_resource = None
41
42 def base_resource(self):
43 if self.__base_resource:
44 return self.__base_resource
45 elif self.base_resource_lookup:
46 self.__base_resource = self.client.resources.get(
47 **self.base_resource_lookup
48 )
49 return self.__base_resource
50 return None
51
52 def to_dict(self):
53 return {
54 "_type": "ResourceList",
55 "group": self.group,
56 "api_version": self.api_version,
57 "kind": self.kind,
58 "base_kind": self.base_kind,
59 "base_resource_lookup": self.base_resource_lookup,
60 }