5555
5656def getAppResource (dynClient : DynamicClient , instanceId : str , applicationId : str , workspaceId : str = None ) -> bool :
5757 """
58- Get the application or workspace Custom Resource
59-
60- :param dynClient: Description
61- :type dynClient: DynamicClient
62- :param instanceId: Description
63- :type instanceId: str
64- :param applicationId: Description
65- :type applicationId: str
66- :return: Description
67- :rtype: bool
68- :type workspaceId: str
69- :return: Description
70- :rtype: bool
58+ Retrieve a MAS application or workspace custom resource.
59+
60+ This function fetches either an application-level CR (e.g., ManageApp) or a
61+ workspace-level CR (e.g., ManageWorkspace) depending on whether workspaceId is provided.
62+
63+ Args:
64+ dynClient (DynamicClient): OpenShift dynamic client for cluster API interactions.
65+ instanceId (str): The MAS instance identifier (e.g., "inst1").
66+ applicationId (str): The MAS application identifier (e.g., "manage", "iot", "monitor").
67+ workspaceId (str, optional): The workspace identifier. If provided, retrieves workspace CR.
68+ Defaults to None (retrieves application CR).
69+
70+ Returns:
71+ ResourceInstance: The custom resource object if found, None otherwise.
72+ Returns None if the resource doesn't exist, CRD is missing, or authorization fails.
73+
74+ Example:
75+ >>> # Get application CR
76+ >>> app = getAppResource(client, "inst1", "manage")
77+ >>> # Get workspace CR
78+ >>> workspace = getAppResource(client, "inst1", "manage", "masdev")
7179 """
7280
7381 apiVersion = APP_API_VERSIONS [applicationId ] if applicationId in APP_API_VERSIONS else "apps.mas.ibm.com/v1"
@@ -93,7 +101,19 @@ def getAppResource(dynClient: DynamicClient, instanceId: str, applicationId: str
93101
94102def verifyAppInstance (dynClient : DynamicClient , instanceId : str , applicationId : str ) -> bool :
95103 """
96- Validate that the chosen app instance exists
104+ Verify that a MAS application instance exists in the cluster.
105+
106+ Args:
107+ dynClient (DynamicClient): OpenShift dynamic client for cluster API interactions.
108+ instanceId (str): The MAS instance identifier.
109+ applicationId (str): The MAS application identifier (e.g., "manage", "iot").
110+
111+ Returns:
112+ bool: True if the application instance exists, False otherwise.
113+
114+ Example:
115+ >>> if verifyAppInstance(client, "inst1", "manage"):
116+ ... print("Manage application is installed")
97117 """
98118 return getAppResource (dynClient , instanceId , applicationId ) is not None
99119
@@ -108,22 +128,33 @@ def waitForAppReady(
108128 debugLogFunction = logger .debug ,
109129 infoLogFunction = logger .info ) -> bool :
110130 """
111- Docstring for waitForAppReady
112-
113- :param dynClient: Description
114- :type dynClient: DynamicClient
115- :param instanceId: Description
116- :type instanceId: str
117- :param applicationId: Description
118- :type applicationId: str
119- :param workspaceId: Description
120- :type workspaceId: str
121- :param retries: Description
122- :type retries: int
123- :param delay: Description
124- :type delay: int
125- :return: Description
126- :rtype: bool
131+ Wait for a MAS application or workspace to reach ready state.
132+
133+ This function polls the application/workspace custom resource until its Ready condition
134+ status becomes True, or until the retry limit is reached. It checks the status.conditions
135+ array for a condition with type="Ready" and status="True".
136+
137+ Args:
138+ dynClient (DynamicClient): OpenShift dynamic client for cluster API interactions.
139+ instanceId (str): The MAS instance identifier.
140+ applicationId (str): The MAS application identifier (e.g., "manage", "iot").
141+ workspaceId (str, optional): The workspace identifier. If provided, waits for workspace CR.
142+ Defaults to None (waits for application CR).
143+ retries (int, optional): Maximum number of polling attempts. Defaults to 100.
144+ delay (int, optional): Delay in seconds between polling attempts. Defaults to 600 (10 minutes).
145+ debugLogFunction (callable, optional): Function for debug logging. Defaults to logger.debug.
146+ infoLogFunction (callable, optional): Function for info logging. Defaults to logger.info.
147+
148+ Returns:
149+ bool: True if the resource reaches ready state within the retry limit, False otherwise.
150+
151+ Example:
152+ >>> # Wait for Manage application to be ready
153+ >>> if waitForAppReady(client, "inst1", "manage", retries=50, delay=300):
154+ ... print("Manage is ready")
155+ >>> # Wait for Manage workspace to be ready
156+ >>> if waitForAppReady(client, "inst1", "manage", "masdev", retries=50):
157+ ... print("Manage workspace is ready")
127158 """
128159
129160 resourceName = f"{ APP_KINDS [applicationId ]} /{ instanceId } "
@@ -176,7 +207,25 @@ def waitForAppReady(
176207
177208def getAppsSubscriptionChannel (dynClient : DynamicClient , instanceId : str ) -> list :
178209 """
179- Return list of installed apps with their subscribed channel
210+ Retrieve the OLM subscription channels for all installed MAS applications.
211+
212+ This function queries the Operator Lifecycle Manager subscriptions for each known
213+ MAS application and returns a list of installed applications with their update channels.
214+
215+ Args:
216+ dynClient (DynamicClient): OpenShift dynamic client for cluster API interactions.
217+ instanceId (str): The MAS instance identifier.
218+
219+ Returns:
220+ list: List of dictionaries with 'appId' and 'channel' keys for each installed app.
221+ Returns empty list if no apps are found or if errors occur.
222+
223+ Example:
224+ >>> apps = getAppsSubscriptionChannel(client, "inst1")
225+ >>> for app in apps:
226+ ... print(f"{app['appId']}: {app['channel']}")
227+ manage: 8.7.x
228+ iot: 8.8.x
180229 """
181230 try :
182231 installedApps = []
0 commit comments