4.3.2.2. User¶
-
class
dyn.tm.accounts.
User
(user_name, *args, **kwargs)[source]¶ DynECT System User object
-
__init__
(user_name, *args, **kwargs)[source]¶ Create a new
User
objectParameters: - user_name – This
User
‘s system username; used for logging into the system - password – Password for this
User
account - email – This
User
‘s Email address - first_name – This
User
‘s first name - last_name – This
User
‘s last name - nickname – The nickname for the Contact associated with this
User
- organization – This
User
‘s organization - phone – This
User
‘s phone number. Can be of the form: (0) ( country-code ) ( local number ) ( extension ) Only the country-code (1-3 digits) and local number (at least 7 digits) are required. The extension can be up to 4 digits. Any non-digits are ignored. - address – This
User
‘s street address - address2 – This
User
‘s street address, line 2 - city – This
User
‘s city, part of the user’s address - country – This
User
‘s country, part of the user’s address - fax – This
User
‘s fax number - notify_email – Email address where this
User
should receive notifications - pager_email – Email address where this
User
should receive messages destined for a pager - post_code – Zip code or Postal code
- group_name – A list of permission groups this
User
belongs to - permission – A list of permissions assigned to this
User
- zone – A list of zones where this
User
‘s permissions apply - forbid – A list of forbidden permissions for this
User
- status – Current status of this
User
- website – This
User
‘s website
- user_name – This
-
add_forbid_rule
(permission, zone=None)[source]¶ Adds the forbid rule to the
User
‘s permission groupParameters: - permission – the permission to forbid from this
User
- zone – A list of zones where the forbid rule applies
- permission – the permission to forbid from this
-
add_permission
(permission)[source]¶ Add individual permissions to this
User
Parameters: permission – the permission to add
-
add_permissions_group
(group)[source]¶ Assigns the permissions group to this
User
Parameters: group – the permissions group to add to this User
-
add_zone
(zone, recurse='Y')[source]¶ Add individual zones to this
User
:param zone: the zone to add :param recurse: determine if permissions should be extended tosubzones.
-
delete_forbid_rule
(permission, zone=None)[source]¶ Removes a forbid permissions rule from the
User
‘s permission groupParameters: - permission – permission
- zone – A list of zones where the forbid rule applies
-
delete_permission
(permission)[source]¶ Remove this specific permission from the
User
Parameters: permission – the permission to remove
-
delete_permissions_group
(group)[source]¶ Removes the permissions group from the
User
Parameters: group – the permissions group to remove from this User
-
delete_zone
(zone)[source]¶ Remove this specific zones from the
User
Parameters: zone – the zone to remove
-
phone
¶ This
User
‘s phone number. Can be of the form: (0) ( country-code ) ( local number ) ( extension ) Only the country-code (1-3 digits) and local number (at least 7 digits) are required. The extension can be up to 4 digits. Any non-digits are ignored.
-
replace_forbid_rules
(forbid=None)[source]¶ Replaces the list of forbidden permissions in the
User
‘s permissions group with a new list.Parameters: forbid – A list of rules to replace the forbidden rules on the User
‘s permission group. If empty or not passed in, theUser
‘s forbid list will be cleared
-
replace_permission
(permission=None)[source]¶ Replaces the list of permissions for this
User
Parameters: permissions – A list of permissions. Pass an empty list or omit the argument to clear the list of permissions of the User
-
replace_permissions_group
(groups=None)[source]¶ Replaces the list of permissions for this
User
Parameters: groups – A list of permissions groups. Pass an empty list or omit the argument to clear the list of permissions groups of the User
-
replace_zones
(zones)[source]¶ Remove this specific zones from the
User
:param zones: array of the zones to be updated format must be [{‘zone_name’:[yourzone], recurse: ‘Y’},{ ...}] recurse is optional.
-
4.3.2.2.1. User Examples¶
The following examples highlight how to use the User
class to
get/create User
‘s on the dyn.tm System and how to edit these objects
from within a Python script.
4.3.2.2.1.1. Creating a new User¶
The following example shows how to create a new User
on the dyn.tm
System and how to edit some of the fields using the returned User
object.
>>> from dyn.tm.accounts import User
>>> # Create a dyn.tmSession
>>> new_user = User('newuser', 'passw0rd', 'contact@email.com', 'first',
... 'last', 'nickname', 'MyOrganization', '(123)456-7890')
>>> new_user.status
u'active'
>>> new_user.city
None
>>> new_user.city = 'Manchester'
>>> new_user.permission
['ZoneGet', 'ZoneUpdate']
>>> new_user.add_permission('ZoneCreate')
>>> new_user.permission
['ZoneGet', 'ZoneUpdate', 'ZoneCreate']
4.3.2.2.1.2. Getting an Existing User¶
The following example shows how to get an existing User
from the
dyn.tm System and how to edit some of the same fields mentioned above.
>>> from dyn.tm.accounts import User
>>> # Create a dyn.tmSession
>>> my_user = User('myusername')
>>> my_user.status
u'blocked'
>>> my_user.unblock()
>>> my_user.status
u'active'