softlayer api user password update

巧了我就是萌 提交于 2019-12-06 04:35:47

The password policy regarding the complexity is Ok. The problem is that SoftLayer uses this kind of body in the requests:

{
  "parameters": [] 
}

Sometimes the request requires an object or an integer or a string such in this case, so the correct REST request would be:

{
    "parameters": ["P@s$w0rd!?"]
}

Here a python example using SoftLayer python client:

"""
Update VPN password.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/updateVpnPassword
https://sldn.softlayer.com/article/Python

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer
import pprint

"""
Your SoftLayer API username and key
"""
USERNAME = 'set me'
API_KEY = 'set me'

# Create a SoftLayer API client object
client = SoftLayer.Client(username=USERNAME,
                          api_key=API_KEY)
userService = client['SoftLayer_User_Customer']

user_id = 205571
updated_password = 'P@s$w0rd!?'

try:
    result = userService.updateVpnPassword(updated_password, id=user_id)
    pprint.pprint(result)
except SoftLayer.SoftLayerAPIError as e:
    print(('Unable to update password faultCode=%s, faultString=%s'
    % (e.faultCode, e.faultString)))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!