-1

I'm trying to get list of users who has access to softlayer portal.

but i'm getting below error

users = client.getUsers()
AttributeError: 'BaseClient' object has no attribute 'getUsers'

this is my python code

#!/usr/bin/python

import SoftLayer.API
import sys
import os

api_username = 'user'
api_key = 'key'

client = SoftLayer.create_client_from_env(username=api_username
api_key=api_key )

users = client.getUsers()

for user in users:
    print ("id: " + str(user['id']) + " userName: " + user['username'])

How do i retrieve user id's (like active users)

ldz
  • 2,217
  • 16
  • 21
kushan.kjk
  • 3
  • 1
  • 3

1 Answers1

0

As I see, you need to define the "service" in this case SoftLayer_Account, also, if you would like to get only active users, it's necessary to use a filter objectFilter. Can you try the below script?

import SoftLayer.API
import sys
import os

api_username = 'set me' 
api_key = 'set me'

client = SoftLayer.create_client_from_env(username=api_username, api_key=api_key)

# Using an object filter to get users active (1001)
objectFilter = {'users': {'statusId': {'operation': 1001}}}

users = client['SoftLayer_Account'].getUsers(filter=objectFilter)

for user in users: 
    print ("id: " + str(user['id']) + " userName: " + user['username'])

Let me know if you have any doubt or need further assistance

References: