2017-05-09 6 views
0

どのようにして、マスターブランドアカウントの顧客リストをPythonを使用して取得できますか?Softlayerマスターブランドアカウントから得意先リストを取得

私はこのように試してみました:

import Softlayer 
client = Sotlayer.Client(api_key='xxxxx',username='xxxxxxx') 
brand_id ='xxxxx' 
brand_users = client['Brand'].getUsers(id=brand_id) 

Iができないすべての顧客のリストを取得

+0

はあなたがマスターブランドであるかについて、それはもう少し明確にすることができますこことそれに対するソフト層関係。また、Sotlayer.Clinet(api_key = 'xxxxx'、username = 'xxxxxxx')にタイプミスがあると思います。それはSoftlayer.Client()でなければなりません。 –

+0

@ArjunSinghタイプのエラーは問題ありません。私はマスターブランドアカウントの下にすべての顧客が必要です – Robert

+0

@ロバーツはあなたのコードの入力ミスを修正します –

答えて

1

これを試してみてください。

''' 
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は正しいと投票 –

関連する問題