Softlayer从主品牌账户获取客户名单
问题描述:
我如何使用python获得主品牌账户的客户名单。Softlayer从主品牌账户获取客户名单
我想是这样的:
import Softlayer
client = Sotlayer.Client(api_key='xxxxx',username='xxxxxxx')
brand_id ='xxxxx'
brand_users = client['Brand'].getUsers(id=brand_id)
我没能得到所有客户名单
答
试试这个:
'''
Get owned account
The script retrieves all the owned accounts for an arbitrary brand,
the script makes a call to getOwnedBrands() method to retrieve
the brands where the account belongs, then it calls the getAllOwnedAccounts()
method to get the owned accounts for every brand.
Important manual pages
http://sldn.softlayer.com/reference/services/SoftLayer_Account
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getOwnedBrands
http://sldn.softlayer.com/reference/services/SoftLayer_Account/getAllOwnedAccounts
http://sldn.softlayer.com/reference/services/SoftLayer_Brand
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Brand
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
'''
import SoftLayer.API
USERNAME = 'set me'
API_KEY = 'set me'
client = SoftLayer.create_client_from_env(username=USERNAME, api_key=API_KEY)
accountService = client['SoftLayer_Account']
brandService = client['SoftLayer_Brand']
# Getting the brands
brands = accountService.getOwnedBrands()
for brand in brands:
brandId = brand['id']
# Getting the owned Accounts
accounts = brandService.getAllOwnedAccounts(id=brandId)
for account in accounts:
print(account['companyName'])
+0
非常感谢工作很好 – Robert
+0
plz标记答案为正确的和投票 –
你可以把它更加清楚一点上什么是主品牌这里和它的软层关系。另外,我认为Sotlayer.Clinet中存在拼写错误(api_key ='xxxxx',用户名='xxxxxxx')。它应该是Softlayer.Client()。 –
@ArjunSingh类型错误没有问题。我需要主品牌帐户下的所有客户 – Robert
@Robert修复您的代码中的错字 –