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 object

Parameters:
  • 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
add_forbid_rule(permission, zone=None)[source]

Adds the forbid rule to the User’s permission group

Parameters:
  • permission – the permission to forbid from this User
  • zone – A list of zones where the forbid rule applies
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 to

subzones.
address

This User’s street address

address_2

This User’s street address, line 2

block()[source]

Blocks this User from logging in

city

This User’s city, part of the user’s address

country

This User’s country, part of the user’s address

delete()[source]

Delete this User from the system

delete_forbid_rule(permission, zone=None)[source]

Removes a forbid permissions rule from the User’s permission group

Parameters:
  • 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
email

This User’s Email address

fax

This User’s fax number

first_name

This User’s first name

forbid

A list of forbidden permissions for this User

group_name

A list of permission groups this User belongs to

last_name

This User’s last name

nickname

The nickname for the Contact associated with this User

notify_email

Email address where this User should receive notifications

organization

This User’s organization

pager_email

Email address where this User should receive messages destined for a pager

permission

A list of permissions assigned to this User

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.

post_code

This User’s postal code, part of the user’s address

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, the User’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.

status

A User’s status is a read-only property. To change you must use the block()/unblock() methods

unblock()[source]

Restores this User to an active status and re-enables their log-in

user_name

A User’s user_name is a read-only property

website

This User’s website

zone

A list of zones where this User’s permissions apply

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'