I am developing a cloud portal using Softlayer java client Lib.
My userID is a Master account, just below Brand, and created accounts using createCustomerAccount(). After creating accounts, I can't retrieve the list of accounts using getAllOwnedAccounts(). Only my account can be shown after executing the code below. Other accounts have been created successfully, so that the accounts can be found on "agent.softlayer.com".
Here is my code..
@Test
public void testConnect() throws Exception {
ApiClient client = new RestApiClient().withCredentials(userId, apiKey);
Brand brand = Account.service(client).getBrand();
List<Account> accountList = Brand.service(client, brand.getId()).getAllOwnedAccounts();
for (Account account : accountList) {
System.out.println(account.getCompanyName() + ", state : "+ account.getState());
}
}
Here is another code..
Brand brand = Account.service(client).getBrand();
Brand.Service brdSrv = Brand.service(client, brand.getId());
brdSrv.withMask().allOwnedAccounts();
Brand brd = brdSrv.getObject();
List<Account> accountList = brd.getAllOwnedAccounts();
This code doesn't work either..
looking forward to your feedback. Thank you
Mike
try this code is in Python:
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'])
I think the issue is that you are not using the correct brand id.