Skip to content

Commit 9f2b43d

Browse files
authored
[patch] Add getAppsSubscriptionChannel in mas.py (#117)
1 parent ce4c382 commit 9f2b43d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/mas/devops/mas.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,41 @@ def getMasChannel(dynClient: DynamicClient, instanceId: str) -> str:
225225
return masSubscription.spec.channel
226226

227227

228+
def getAppsSubscriptionChannel(dynClient: DynamicClient, instanceId: str) -> list:
229+
"""
230+
Return list of installed apps with their subscribed channel
231+
"""
232+
try:
233+
installedApps = []
234+
appKinds = [
235+
"assist",
236+
"facilities",
237+
"health",
238+
"hputilities",
239+
"iot",
240+
"manage",
241+
"monitor",
242+
"mso",
243+
"optimizer",
244+
"safety",
245+
"predict",
246+
"visualinspection",
247+
"aibroker"
248+
]
249+
for appKind in appKinds:
250+
appSubscription = getSubscription(dynClient, f"mas-{instanceId}-{appKind}", f"ibm-mas-{appKind}")
251+
if appSubscription is not None:
252+
installedApps.append({"appId": appKind, "channel": appSubscription.spec.channel})
253+
return installedApps
254+
except NotFoundError:
255+
return []
256+
except ResourceNotFoundError:
257+
return []
258+
except UnauthorizedError:
259+
logger.error("Error: Unable to get MAS app subscriptions due to failed authorization: {e}")
260+
return []
261+
262+
228263
def updateIBMEntitlementKey(dynClient: DynamicClient, namespace: str, icrUsername: str, icrPassword: str, artifactoryUsername: str = None, artifactoryPassword: str = None, secretName: str = "ibm-entitlement") -> ResourceInstance:
229264
if secretName is None:
230265
secretName = "ibm-entitlement"

0 commit comments

Comments
 (0)