Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit e98393a

Browse files
authored
Read subaccount domain from existing subaccount (#472)
1 parent 3e1039f commit e98393a

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

libs/python/btp_cli.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def create_subaccount(self):
454454

455455
subaccount = createSubaccountName(self)
456456
subdomain = createSubdomainID(self)
457-
457+
458458
log.success("using subaccount name >" + subaccount + "<")
459459
log.success("using subaccount domain >" + subdomain + "<")
460460

@@ -468,9 +468,9 @@ def create_subaccount(self):
468468
"Create sub account >" + subaccount + "< (if not already existing)"
469469
)
470470

471-
subaccountid = checkIfSubaccountAlreadyExists(self)
472-
473-
if subaccountid is None:
471+
subaccountExist = checkIfSubaccountAlreadyExists(self)
472+
473+
if subaccountExist is None:
474474
command = (
475475
"btp --format json create accounts/subaccount \
476476
--display-name '"
@@ -532,19 +532,29 @@ def create_subaccount(self):
532532
+ "<"
533533
)
534534
else:
535+
subaccountid = subaccountExist[0]
536+
subdomain = subaccountExist[1]
535537
log.success(
536538
"subaccount >"
537539
+ subaccount
538540
+ "< already exists with id >"
539541
+ subaccountid
542+
+ "< and subdomain >"
543+
+ subdomain
540544
+ "<"
541545
)
542546
self.subaccountid = subaccountid
547+
self.subdomain = subdomain
543548

544549
self.accountMetadata = addKeyValuePair(
545-
accountMetadata, "subaccountid", subaccountid
550+
accountMetadata, "subaccountid", subaccountid
546551
)
552+
self.accountMetadata = addKeyValuePair(
553+
accountMetadata, "subdomain", subdomain
554+
)
555+
547556
self.subaccountid = subaccountid
557+
self.subdomain = subdomain
548558
else:
549559
log.header(
550560
"USING CONFIGURED SUBACCOUNT WITH ID >" + self.subaccountid + "<"
@@ -1387,13 +1397,13 @@ def checkIfSubaccountAlreadyExists(btpUsecase: BTPUSECASE):
13871397
+ "'"
13881398
)
13891399
result = runCommandAndGetJsonResult(btpUsecase, command, "INFO", None)
1390-
1400+
13911401
if "subaccount" in accountMetadata:
13921402
subaccountName = accountMetadata["subaccount"]
13931403

13941404
for account in result["value"]:
13951405
if account["displayName"] == subaccountName:
1396-
return account["guid"]
1406+
return account["guid"], account["subdomain"]
13971407
# If the for loop didn't return any value, the subaccount wasn't found
13981408
return None
13991409
else:

0 commit comments

Comments
 (0)