Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from maas.client.bones import SessionAPI
>>> credentials=['zbL4fkkuxqxhDRauv9', 'tfymrvVay9qZGJFAR9', 'A4dJNDB8LUNFKUWx46gtCdhsVAg8aSkB']
>>> client = SessionAPI.fromURL(url="http://192.168.61.8:5240/MAAS/api/2.0/",credentials=credentials, insecure=True)
>>> client.SSHKeys.import(keysource='gh:canozyurt')
File "<stdin>", line 1
client.SSHKeys.import(keysource='gh:canozyurt')
^
SyntaxError: invalid syntax
>>>
I modified the API description json to export "import" action as "add" instead and published the json via 8080. I left the paths and URIs untouched so SessionAPI can still connect to the same MAAS instance.
{
"anon":null,
"auth":{
"actions":[
{
"method":"POST",
"name":"add",
"doc":"Import SSH keys\n\nImport the requesting user's SSH keys for a given protocol\nand authorization ID in protocol:auth_id format.\n\n:param keysource: Required. The source\nof the keys to import should be provided in the request payload as form\ndata:\n\nE.g.\n\n source:user\n\n- ``source``: lp (Launchpad), gh (GitHub)\n- ``user``: User login\n:type keysource: String\n\n ",
"op":"import",
"restful":false
},
{
"method":"GET",
"name":"read",
"doc":"List SSH keys\n\nList all keys belonging to the requesting user.\n\n",
"op":null,
"restful":true
},
{
"method":"POST",
"name":"create",
"doc":"Add a new SSH key\n\nAdd a new SSH key to the requesting or supplied user's\naccount.\n\n:param key: Required. A public SSH key\nshould be provided in the request payload as form data with the name\n'key':\n\n key: \"key-type public-key-data\"\n\n- ``key-type``: ecdsa-sha2-nistp256, ecdsa-sha2-nistp384,\n ecdsa-sha2-nistp521, ssh-dss, ssh-ed25519, ssh-rsa\n- ``public key data``: Base64-encoded key data.\n:type key: String\n\n ",
"op":null,
"restful":true
}
],
"doc":"Manage the collection of all the SSH keys in this MAAS.",
"name":"SSHKeysHandler",
"params":[
],
"path":"/MAAS/api/2.0/account/prefs/sshkeys/",
"uri":"http://192.168.61.8:5240/MAAS/api/2.0/account/prefs/sshkeys/"
},
"name":"SSHKeysHandler"
},
The request went through and returned success.
>>> client = SessionAPI.fromURL(url="http://192.168.61.8:8080/",credentials=credentials, insecure=True)
>>> client.SSHKeys.add(keysource='gh:canozyurt')
[{'key': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDmtjegTY011FoyM5u1wQABWWg1bwEzQ8CoOG0DLcqATLt4wVK3+MaxzIVZElcQG9M4H7ghekqRaaV+vVt/OnM6p97qyQ40urqco+H5fBkVuygFXtZeQngL2QUSUhB8nm2pVHu4eI1P/ObcIejFSfmDcAKRgcKZLoLqY86CD7e4dBOOGBfMw5cWMsuB2derRt1gimAMcnGDh9DapaAX9Qu7oLwWwQc5qWYntyhRtLpAEXcWuptN+zbJGz2ydzCVqD9SqPhsTemdItUrSMngPYxThzvuxVCgr1PuTwtpYNF0FGOJ5JI0T1E3b3hTI+BB0ckyuSzJR5GSCYMWWAm8/vp6bzWsoFXgJUW8fvLbH6pIboSg5uQ1Toic9YgT1qWdt2u/0Uii+Y6FUQ5HqfK1BcmdqdjMPwkgmAiAKCD5y6hfb88ElF5JiZaxNvH/YgH5LMJzO6XAzShvayqvoXu+EUXGhfZRBvfTHzzlbw7+MjoH+he0nSNlVPp7gJrOsrhkWNE=', 'keysource': 'gh:canozyurt', 'id': 7, 'resource_uri': '/MAAS/api/2.0/account/prefs/sshkeys/7/'}]
>>>
All other import actions available in other handlers seem affected too.
I modified the API description json to export "import" action as "add" instead and published the json via 8080. I left the paths and URIs untouched so SessionAPI can still connect to the same MAAS instance.
The request went through and returned success.
All other import actions available in other handlers seem affected too.