UserManager

class SoftLayer.managers.UserManager(client)[source]

Manages Users.

See: https://softlayer.github.io/reference/datatypes/SoftLayer_User_Customer/

Example:

# Initialize the Manager.
import SoftLayer
client = SoftLayer.create_client_from_env()
mgr = SoftLayer.UserManager(client)
Parameters:

client (SoftLayer.API.BaseClient) – the client instance

__init__(client)[source]

Methods

__init__(client)

add_api_authentication_key(user_id)

Calls SoftLayer_User_Customer::addApiAuthenticationKey

add_permissions(user_id, permissions)

Enables a list of permissions for a user

create_user(user_object, password)

Blindly sends user_object to SoftLayer_User_Customer::createObject

disable_notifications(notifications_names)

Disable a list of notifications for the current a user profile.

edit_user(user_id, user_object)

Blindly sends user_object to SoftLayer_User_Customer::editObject

enable_notifications(notifications_names)

Enables a list of notifications for the current a user profile.

format_permission_object(permissions)

Formats a list of permission key names into something the SLAPI will respect.

gather_notifications(notifications_names)

Gets a list of notifications.

get_all_notifications()

Calls SoftLayer_Email_Subscription::getAllObjects

get_all_permissions()

Calls User_Permission_Action::getAllObjects

get_api_authentication_keys(user_id)

Calls SoftLayer_User_Customer::getApiAuthenticationKeys

get_current_user([objectmask])

Calls SoftLayer_Account::getCurrentUser

get_events(user_id[, start_date])

Gets the event log for a specific user, default start_date is 30 days ago

get_logins(user_id[, start_date])

Gets the login history for a user, default start_date is 30 days ago

get_overrides_list(user_id, subnet_ids)

Converts a list of subnets to a list of overrides.

get_permission_departments()

Calls SoftLayer_User_Permission_Department::getAllObjects

get_user(user_id[, objectmask])

Calls SoftLayer_User_Customer::getObject

get_user_dedicated_host(user_id)

User dedicate host list.

get_user_hardware(user_id)

User Hardware list.

get_user_permissions(user_id)

Returns a sorted list of a users permissions

get_user_virtuals(user_id)

User virtual guest list.

grant_dedicated_access(user_id, dedicated_id)

Grants the user access to a single dedicated host device.

grant_hardware_access(user_id, hardware_id)

Grants the user access to a single hardware device.

grant_virtual_access(user_id, virtual_id)

Grants the user access to a single VS device.

list_users([objectmask, objectfilter])

Lists all users on an account

permissions_from_user(user_id, from_user_id)

Sets user_id's permission to be the same as from_user_id's

remove_api_authentication_key(user_id)

Calls SoftLayer_User_Customer::getApiAuthenticationKeys and

remove_dedicated_access(user_id, dedicated_id)

Remove hardware from a portal user’s dedicated host access list.

remove_hardware_access(user_id, hardware_id)

Remove hardware from a portal user’s hardware access list.

remove_permissions(user_id, permissions)

Disables a list of permissions for a user

remove_virtual_access(user_id, virtual_id)

Remove hardware from a portal user’s virtual guests access list.

resolve_ids(identifier)

Takes a string and tries to resolve to a list of matching ids.

update_vpn_password(user_id, password)

Update a user's VPN password.

vpn_enable_or_disable(user_id, value)

Enable or Disable vpn for a user.

vpn_manual(user_id, value)

Enable or disable the manual config of subnets.

vpn_subnet_add(user_id, subnet_ids)

Add subnets for a user.

vpn_subnet_remove(user_id, subnet_ids)

Remove subnets for a user.

Attributes

resolvers

add_api_authentication_key(user_id)[source]

Calls SoftLayer_User_Customer::addApiAuthenticationKey

Parameters:

user_id (int) – User to add API key to

add_permissions(user_id, permissions)[source]

Enables a list of permissions for a user

Parameters:
  • id (int) – user id to set

  • permissions (list) – List of permissions keynames to enable

Returns:

True on success, Exception otherwise

Example:

add_permissions(123, ['BANDWIDTH_MANAGE'])
create_user(user_object, password)[source]

Blindly sends user_object to SoftLayer_User_Customer::createObject

Parameters:

user_object (dictionary) – https://softlayer.github.io/reference/datatypes/SoftLayer_User_Customer/

disable_notifications(notifications_names)[source]

Disable a list of notifications for the current a user profile.

Parameters:

notifications_names (list) – List of notifications names to disable

Returns:

True on success

Example:

disable_notifications(['Order Approved','Reload Complete'])
edit_user(user_id, user_object)[source]

Blindly sends user_object to SoftLayer_User_Customer::editObject

Parameters:
enable_notifications(notifications_names)[source]

Enables a list of notifications for the current a user profile.

Parameters:

notifications_names (list) – List of notifications names to enable

Returns:

True on success

Example:

enable_notifications(['Order Approved','Reload Complete'])
format_permission_object(permissions)[source]

Formats a list of permission key names into something the SLAPI will respect.

Parameters:

permissions (list) – A list of SLAPI permissions keyNames. keyName of ALL will return all permissions.

Returns:

list of dictionaries that can be sent to the api to add or remove permissions

Throws SoftLayerError:

If any permission is invalid this exception will be thrown.

gather_notifications(notifications_names)[source]

Gets a list of notifications.

Parameters:

notifications_names (list) – A list of notifications names.

Returns:

list of notifications.

get_all_notifications()[source]

Calls SoftLayer_Email_Subscription::getAllObjects

Stores the result in self.all_permissions :returns: A list of dictionaries that contains all valid permissions

get_all_permissions()[source]

Calls User_Permission_Action::getAllObjects

Stores the result in self.all_permissions :returns: A list of dictionaries that contains all valid permissions

get_api_authentication_keys(user_id)[source]

Calls SoftLayer_User_Customer::getApiAuthenticationKeys

Parameters:

user_id (int) – User to add API key to

get_current_user(objectmask=None)[source]

Calls SoftLayer_Account::getCurrentUser

get_events(user_id, start_date=None)[source]

Gets the event log for a specific user, default start_date is 30 days ago

Parameters:
  • id (int) – User id to view

  • start_date (string) – “%Y-%m-%dT%H:%M:%s.0000-06:00” is the full formatted string. The Timezone part has to be HH:MM, notice the : there.

Returns:

https://softlayer.github.io/reference/datatypes/SoftLayer_Event_Log/

get_logins(user_id, start_date=None)[source]

Gets the login history for a user, default start_date is 30 days ago

Parameters:
  • id (int) – User id to get

  • start_date (string) – “%m/%d/%Y %H:%M:%s” formatted string.

Returns:

list https://softlayer.github.io/reference/datatypes/SoftLayer_User_Customer_Access_Authentication/

Example:

get_logins(123, '04/08/2018 0:0:0')
get_overrides_list(user_id, subnet_ids)[source]

Converts a list of subnets to a list of overrides.

Parameters:
  • user_id (int) – The ID of the user.

  • subnet_ids (list) – A list of subnets.

Returns:

A list of overrides associated with the given subnets.

get_permission_departments()[source]

Calls SoftLayer_User_Permission_Department::getAllObjects

Stores the result in self.all_permissions :returns: A list of dictionaries that contains all valid permissions

get_user(user_id, objectmask=None)[source]

Calls SoftLayer_User_Customer::getObject

Parameters:
  • user_id (int) – Id of the user

  • objectmask (string) – default is ‘mask[userStatus[name], parent[id, username]]’

Returns:

A user object.

get_user_dedicated_host(user_id)[source]

User dedicate host list.

Parameters:

user_id (int) – User Id

Returns:

List dedicated host relate to user

get_user_hardware(user_id)[source]

User Hardware list.

Parameters:

user_id (int) – User Id

Returns:

List hardware relate to user

get_user_permissions(user_id)[source]

Returns a sorted list of a users permissions

get_user_virtuals(user_id)[source]

User virtual guest list.

Parameters:

user_id (int) – User Id

Returns:

List virtual guest relate to user

grant_dedicated_access(user_id, dedicated_id)[source]

Grants the user access to a single dedicated host device.

Parameters:
  • user_id (int) – User Id

  • dedicated_id (int) – Dedicatd Host Id

Returns:

true

grant_hardware_access(user_id, hardware_id)[source]

Grants the user access to a single hardware device.

Parameters:
  • user_id (int) – User Id

  • hardware_id (int) – Hardware Id

Returns:

true

grant_virtual_access(user_id, virtual_id)[source]

Grants the user access to a single VS device.

Parameters:
  • user_id (int) – User Id

  • virtual_id (int) – Hardware Id

Returns:

true

list_users(objectmask=None, objectfilter=None)[source]

Lists all users on an account

Parameters:
  • objectmask (string) – Used to overwrite the default objectmask.

  • objectfilter (dictionary) – If you want to use an objectfilter.

Returns:

A list of dictionaries that describe each user

Example::

result = mgr.list_users()

permissions_from_user(user_id, from_user_id)[source]

Sets user_id’s permission to be the same as from_user_id’s

Any permissions from_user_id has will be added to user_id. Any permissions from_user_id doesn’t have will be removed from user_id.

Parameters:
  • user_id (int) – The user to change permissions.

  • from_user_id (int) – The use to base permissions from.

Returns:

True on success, Exception otherwise.

remove_api_authentication_key(user_id)[source]

Calls SoftLayer_User_Customer::getApiAuthenticationKeys and

SoftLayer_User_Customer::removeApiAuthenticationKey

Parameters:

user_id (int) – User to remove API key

remove_dedicated_access(user_id, dedicated_id)[source]

Remove hardware from a portal user’s dedicated host access list.

Parameters:
  • user_id (int) – User Id

  • dedicated_id (int) – Dedicated Host Id

Returns:

true

remove_hardware_access(user_id, hardware_id)[source]

Remove hardware from a portal user’s hardware access list.

Parameters:
  • user_id (int) – User Id

  • hardware_id (int) – Hardware Id

Returns:

true

remove_permissions(user_id, permissions)[source]

Disables a list of permissions for a user

Parameters:
  • id (int) – user id to set

  • permissions (list) – List of permissions keynames to disable

Returns:

True on success, Exception otherwise

Example:

remove_permissions(123, ['BANDWIDTH_MANAGE'])
remove_virtual_access(user_id, virtual_id)[source]

Remove hardware from a portal user’s virtual guests access list.

Parameters:
  • user_id (int) – User Id

  • hardware_id (int) – Hardware Id

Returns:

true

resolve_ids(identifier)

Takes a string and tries to resolve to a list of matching ids.

What exactly ‘identifier’ can be depends on the resolvers

Parameters:

identifier (string) – identifying string

Returns list:

update_vpn_password(user_id, password)[source]

Update a user’s VPN password.

Parameters:
  • user_id (int) – User Id

  • password (string) – Password

Returns:

true

vpn_enable_or_disable(user_id, value)[source]

Enable or Disable vpn for a user.

Parameters:
  • user_id (int) – User to edit.

  • value (bool) – Value for vpn enable flag.

  • value – Value for vpn disable flag.

vpn_manual(user_id, value)[source]

Enable or disable the manual config of subnets.

Parameters:
  • user_id (int) – User to edit.

  • value (bool) – Value for vpnManualConfig flag.

vpn_subnet_add(user_id, subnet_ids)[source]

Add subnets for a user.

Parameters:
  • user_id (int) – User to edit.

  • subnet_ids (list) – list of subnet Ids.

vpn_subnet_remove(user_id, subnet_ids)[source]

Remove subnets for a user.

Parameters:
  • user_id (int) – User to edit.

  • subnet_ids (list) – list of subnet Ids.