MCPcopy Index your code
hub / github.com/kubernetes-client/python / get

Method get

kubernetes/base/dynamic/discovery.py:197–216  ·  view source on GitHub ↗

Same as search, but will throw an error if there are multiple or no results. If there are multiple results and only one is an exact match on api_version, that resource will be returned.

(self, **kwargs)

Source from the content-addressed store, hash-verified

195 return resources
196
197 def get(self, **kwargs):
198 """ Same as search, but will throw an error if there are multiple or no
199 results. If there are multiple results and only one is an exact match
200 on api_version, that resource will be returned.
201 """
202 results = self.search(**kwargs)
203 # If there are multiple matches, prefer exact matches on api_version
204 if len(results) > 1 and kwargs.get('api_version'):
205 results = [
206 result for result in results if result.group_version == kwargs['api_version']
207 ]
208 # If there are multiple matches, prefer non-List kinds
209 if len(results) > 1 and not all([isinstance(x, ResourceList) for x in results]):
210 results = [result for result in results if not isinstance(result, ResourceList)]
211 if len(results) == 1:
212 return results[0]
213 elif not results:
214 raise ResourceNotFoundError('No matches found for {}'.format(kwargs))
215 else:
216 raise ResourceNotUniqueError('Multiple matches found for {}: {}'.format(kwargs, results))
217
218
219class LazyDiscoverer(Discoverer):

Callers 6

__init_cacheMethod · 0.45
parse_api_groupsMethod · 0.45
_load_server_infoMethod · 0.45
__searchMethod · 0.45
__searchMethod · 0.45

Calls 4

searchMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected