Skip to content

Commit cc7cb35

Browse files
author
Elias Nygren
committed
allow login_block without username
1 parent 48c68fe commit cc7cb35

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

upcloud_api/server.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ def login_user_block(username, ssh_keys, create_password=True):
1818
Helper function for creating Server.login_user blocks.
1919
(see: https://www.upcloud.com/api/8-servers/#create-server)
2020
"""
21-
return {
22-
'username': username,
21+
block = {
2322
'create_password': 'yes' if create_password is True else 'no',
2423
'ssh_keys': {
2524
'ssh_key': ssh_keys
2625
}
2726
}
2827

28+
if username:
29+
block['username'] = username
30+
31+
return block
32+
2933

3034
class Server(BaseAPI):
3135
"""

0 commit comments

Comments
 (0)