Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/special_cases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Some resources have the same `kind` but different API groups.
For example: `Network` which exists in both operator.openshift.io and config.openshift.io API groups
"""
from ocp_resources.network import Network

# To get the Network resource which uses the default API in the class ("config.openshift.io")
Network(name="cluster")

# To get a Network resource with a different API group ("operator.openshift.io")
Network(name="cluster", api_group=Network.ApiGroup.OPERATOR_OPENSHIFT_IO)
3 changes: 3 additions & 0 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def __init__(
context=None,
label=None,
timeout_seconds=TIMEOUT_1MINUTE,
api_group=None,
):
"""
Create an API resource
Expand All @@ -343,8 +344,10 @@ def __init__(
context (str): Context name for connecting to remote cluster.
timeout_seconds (int): timeout for a get api call, call out be terminated after this many seconds
label (dict): Resource labels
api_group (str): Resource API group; will overwrite API group definition in resource class

"""
self.api_group = api_group or self.api_group
if not self.api_group and not self.api_version:
raise NotImplementedError(
"Subclasses of Resource require self.api_group or self.api_version to be defined"
Expand Down