From ae7e3109b085cb5e665907b626d9c78a55201206 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 30 Sep 2025 15:00:10 +0100 Subject: [PATCH] [patch] Add getAppsSubscriptionChannel in mas.py --- src/mas/devops/mas.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/mas/devops/mas.py b/src/mas/devops/mas.py index 4a7ca8c6..1a2a8f75 100644 --- a/src/mas/devops/mas.py +++ b/src/mas/devops/mas.py @@ -225,6 +225,41 @@ def getMasChannel(dynClient: DynamicClient, instanceId: str) -> str: return masSubscription.spec.channel +def getAppsSubscriptionChannel(dynClient: DynamicClient, instanceId: str) -> list: + """ + Return list of installed apps with their subscribed channel + """ + try: + installedApps = [] + appKinds = [ + "assist", + "facilities", + "health", + "hputilities", + "iot", + "manage", + "monitor", + "mso", + "optimizer", + "safety", + "predict", + "visualinspection", + "aibroker" + ] + for appKind in appKinds: + appSubscription = getSubscription(dynClient, f"mas-{instanceId}-{appKind}", f"ibm-mas-{appKind}") + if appSubscription is not None: + installedApps.append({"appId": appKind, "channel": appSubscription.spec.channel}) + return installedApps + except NotFoundError: + return [] + except ResourceNotFoundError: + return [] + except UnauthorizedError: + logger.error("Error: Unable to get MAS app subscriptions due to failed authorization: {e}") + return [] + + def updateIBMEntitlementKey(dynClient: DynamicClient, namespace: str, icrUsername: str, icrPassword: str, artifactoryUsername: str = None, artifactoryPassword: str = None, secretName: str = "ibm-entitlement") -> ResourceInstance: if secretName is None: secretName = "ibm-entitlement"