Skip to content

Commit

Permalink
Fix create cluster user
Browse files Browse the repository at this point in the history
  • Loading branch information
romasku committed Nov 8, 2021
1 parent 9320337 commit 244fbf9
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions neuro_admin_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,15 @@ async def create_cluster_user(
payload = {
"user_name": user_name,
"role": role.value,
"quota": {"total_running_jobs": quota.total_running_jobs},
"balance": {
"credits": str(balance.credits) if balance.credits else None,
"spent_credits": str(balance.spent_credits)
if balance.spent_credits
else None,
},
"quota": {},
"balance": {},
}
if quota.total_running_jobs:
payload["quota"]["total_running_jobs"] = quota.total_running_jobs
if balance.credits:
payload["balance"]["credits"] = str(balance.credits)
if balance.spent_credits:
payload["balance"]["spent_credits"] = str(balance.spent_credits)

async with self._request(
"POST",
Expand Down Expand Up @@ -380,16 +381,19 @@ async def update_cluster_user(
payload = {
"user_name": cluster_user.user_name,
"role": cluster_user.role.value,
"quota": {"total_running_jobs": cluster_user.quota.total_running_jobs},
"balance": {
"credits": str(cluster_user.balance.credits)
if cluster_user.balance.credits
else None,
"spent_credits": str(cluster_user.balance.spent_credits)
if cluster_user.balance.spent_credits
else None,
},
"quota": {},
"balance": {},
}
if cluster_user.quota.total_running_jobs:
payload["quota"][
"total_running_jobs"
] = cluster_user.quota.total_running_jobs
if cluster_user.balance.credits:
payload["balance"]["credits"] = str(cluster_user.balance.credits)
if cluster_user.balance.spent_credits:
payload["balance"]["spent_credits"] = str(
cluster_user.balance.spent_credits
)

async with self._request(
"PUT",
Expand Down

0 comments on commit 244fbf9

Please sign in to comment.