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

Read subaccount domain from existing subaccount #472

Merged
merged 1 commit into from
Mar 24, 2023
Merged
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
24 changes: 17 additions & 7 deletions libs/python/btp_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def create_subaccount(self):

subaccount = createSubaccountName(self)
subdomain = createSubdomainID(self)

log.success("using subaccount name >" + subaccount + "<")
log.success("using subaccount domain >" + subdomain + "<")

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

subaccountid = checkIfSubaccountAlreadyExists(self)

if subaccountid is None:
subaccountExist = checkIfSubaccountAlreadyExists(self)
if subaccountExist is None:
command = (
"btp --format json create accounts/subaccount \
--display-name '"
Expand Down Expand Up @@ -532,19 +532,29 @@ def create_subaccount(self):
+ "<"
)
else:
subaccountid = subaccountExist[0]
subdomain = subaccountExist[1]
log.success(
"subaccount >"
+ subaccount
+ "< already exists with id >"
+ subaccountid
+ "< and subdomain >"
+ subdomain
+ "<"
)
self.subaccountid = subaccountid
self.subdomain = subdomain

self.accountMetadata = addKeyValuePair(
accountMetadata, "subaccountid", subaccountid
accountMetadata, "subaccountid", subaccountid
)
self.accountMetadata = addKeyValuePair(
accountMetadata, "subdomain", subdomain
)

self.subaccountid = subaccountid
self.subdomain = subdomain
else:
log.header(
"USING CONFIGURED SUBACCOUNT WITH ID >" + self.subaccountid + "<"
Expand Down Expand Up @@ -1387,13 +1397,13 @@ def checkIfSubaccountAlreadyExists(btpUsecase: BTPUSECASE):
+ "'"
)
result = runCommandAndGetJsonResult(btpUsecase, command, "INFO", None)

if "subaccount" in accountMetadata:
subaccountName = accountMetadata["subaccount"]

for account in result["value"]:
if account["displayName"] == subaccountName:
return account["guid"]
return account["guid"], account["subdomain"]
# If the for loop didn't return any value, the subaccount wasn't found
return None
else:
Expand Down