<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import six . moves . urllib <EOL> from . import client <EOL> import six <EOL> USER_STATUS_ACTIVE = '<STR_LIT>' <EOL> USER_STATUS_BYPASS = '<STR_LIT>' <EOL> USER_STATUS_DISABLED = '<STR_LIT>' <EOL> USER_STATUS_LOCKED_OUT = '<STR_LIT>' <EOL> TOKEN_HOTP_6 = '<STR_LIT>' <EOL> TOKEN_HOTP_8 = '<STR_LIT>' <EOL> TOKEN_YUBIKEY = '<STR_LIT>' <EOL> class Admin ( client . Client ) : <EOL> account_id = None <EOL> def api_call ( self , method , path , params ) : <EOL> if self . account_id is not None : <EOL> params [ '<STR_LIT>' ] = self . account_id <EOL> return super ( Admin , self ) . api_call ( method , path , params ) <EOL> @ classmethod <EOL> def _canonicalize_ip_whitelist ( klass , ip_whitelist ) : <EOL> if isinstance ( ip_whitelist , six . string_types ) : <EOL> return ip_whitelist <EOL> else : <EOL> return '<STR_LIT:U+002C>' . join ( ip_whitelist ) <EOL> pass <EOL> @ staticmethod <EOL> def _canonicalize_bypass_codes ( codes ) : <EOL> if isinstance ( codes , six . string_types ) : <EOL> return codes <EOL> else : <EOL> return '<STR_LIT:U+002C>' . join ( [ str ( int ( code ) ) for code in codes ] ) <EOL> def get_administrator_log ( self , <EOL> mintime = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> mintime = str ( int ( mintime ) ) <EOL> params = { <EOL> '<STR_LIT>' : mintime , <EOL> } <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params , <EOL> ) <EOL> for row in response : <EOL> row [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> row [ '<STR_LIT:host>' ] = self . host <EOL> return response <EOL> def get_authentication_log ( self , <EOL> mintime = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> mintime = str ( int ( mintime ) ) <EOL> params = { <EOL> '<STR_LIT>' : mintime , <EOL> } <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params , <EOL> ) <EOL> for row in response : <EOL> row [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> row [ '<STR_LIT:host>' ] = self . host <EOL> return response <EOL> def get_telephony_log ( self , <EOL> mintime = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> mintime = str ( int ( mintime ) ) <EOL> params = { <EOL> '<STR_LIT>' : mintime , <EOL> } <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params , <EOL> ) <EOL> for row in response : <EOL> row [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> row [ '<STR_LIT:host>' ] = self . host <EOL> return response <EOL> def get_users ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> return response <EOL> def get_user_by_id ( self , user_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , path , { } ) <EOL> return response <EOL> def get_users_by_name ( self , username ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT:username>' : username , <EOL> } <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params ) <EOL> return response <EOL> def add_user ( self , username , realname = None , status = None , <EOL> notes = None , email = None ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT:username>' : username , <EOL> } <EOL> if realname is not None : <EOL> params [ '<STR_LIT>' ] = realname <EOL> if status is not None : <EOL> params [ '<STR_LIT:status>' ] = status <EOL> if notes is not None : <EOL> params [ '<STR_LIT>' ] = notes <EOL> if email is not None : <EOL> params [ '<STR_LIT:email>' ] = email <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , <EOL> '<STR_LIT>' , <EOL> params ) <EOL> return response <EOL> def update_user ( self , user_id , username = None , realname = None , <EOL> status = None , notes = None , email = None ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id <EOL> params = { } <EOL> if username is not None : <EOL> params [ '<STR_LIT:username>' ] = username <EOL> if realname is not None : <EOL> params [ '<STR_LIT>' ] = realname <EOL> if status is not None : <EOL> params [ '<STR_LIT:status>' ] = status <EOL> if notes is not None : <EOL> params [ '<STR_LIT>' ] = notes <EOL> if email is not None : <EOL> params [ '<STR_LIT:email>' ] = email <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> return response <EOL> def delete_user ( self , user_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id <EOL> return self . json_api_call ( '<STR_LIT>' , path , { } ) <EOL> def enroll_user ( self , username , email , valid_secs = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { <EOL> '<STR_LIT:username>' : username , <EOL> '<STR_LIT:email>' : email , <EOL> } <EOL> if valid_secs is not None : <EOL> params [ '<STR_LIT>' ] = str ( valid_secs ) <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def get_user_bypass_codes ( self , user_id , count = None , valid_secs = None , remaining_uses = None , codes = None ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' <EOL> params = { } <EOL> if count is not None : <EOL> params [ '<STR_LIT:count>' ] = str ( int ( count ) ) <EOL> if valid_secs is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( valid_secs ) ) <EOL> if remaining_uses is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( remaining_uses ) ) <EOL> if codes is not None : <EOL> params [ '<STR_LIT>' ] = self . _canonicalize_bypass_codes ( codes ) <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def get_user_phones ( self , user_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' <EOL> return self . json_api_call ( '<STR_LIT:GET>' , path , { } ) <EOL> def add_user_phone ( self , user_id , phone_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' <EOL> params = { <EOL> '<STR_LIT>' : phone_id , <EOL> } <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def delete_user_phone ( self , user_id , phone_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' + phone_id <EOL> params = { } <EOL> return self . json_api_call ( '<STR_LIT>' , path , <EOL> params ) <EOL> def get_user_tokens ( self , user_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' <EOL> params = { } <EOL> return self . json_api_call ( '<STR_LIT:GET>' , path , <EOL> params ) <EOL> def add_user_token ( self , user_id , token_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' <EOL> params = { <EOL> '<STR_LIT>' : token_id , <EOL> } <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def delete_user_token ( self , user_id , token_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> token_id = six . moves . urllib . parse . quote_plus ( str ( token_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' + token_id <EOL> return self . json_api_call ( '<STR_LIT>' , path , { } ) <EOL> def get_user_groups ( self , user_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' <EOL> return self . json_api_call ( '<STR_LIT:GET>' , path , { } ) <EOL> def add_user_group ( self , user_id , group_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' <EOL> params = { '<STR_LIT>' : group_id } <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def delete_user_group ( self , user_id , group_id ) : <EOL> """<STR_LIT>""" <EOL> user_id = six . moves . urllib . parse . quote_plus ( str ( user_id ) ) <EOL> path = '<STR_LIT>' + user_id + '<STR_LIT>' + group_id <EOL> params = { } <EOL> return self . json_api_call ( '<STR_LIT>' , path , params ) <EOL> def get_phones ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> return response <EOL> def get_phone_by_id ( self , phone_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' + phone_id <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , path , { } ) <EOL> return response <EOL> def get_phones_by_number ( self , number , extension = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { '<STR_LIT>' : number } <EOL> if extension is not None : <EOL> params [ '<STR_LIT>' ] = extension <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , path , <EOL> params ) <EOL> return response <EOL> def add_phone ( self , <EOL> number = None , <EOL> extension = None , <EOL> name = None , <EOL> type = None , <EOL> platform = None , <EOL> predelay = None , <EOL> postdelay = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { } <EOL> if number is not None : <EOL> params [ '<STR_LIT>' ] = number <EOL> if extension is not None : <EOL> params [ '<STR_LIT>' ] = extension <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> if type is not None : <EOL> params [ '<STR_LIT:type>' ] = type <EOL> if platform is not None : <EOL> params [ '<STR_LIT>' ] = platform <EOL> if predelay is not None : <EOL> params [ '<STR_LIT>' ] = predelay <EOL> if postdelay is not None : <EOL> params [ '<STR_LIT>' ] = postdelay <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def update_phone ( self , phone_id , <EOL> number = None , <EOL> extension = None , <EOL> name = None , <EOL> type = None , <EOL> platform = None , <EOL> predelay = None , <EOL> postdelay = None ) : <EOL> """<STR_LIT>""" <EOL> phone_id = six . moves . urllib . parse . quote_plus ( str ( phone_id ) ) <EOL> path = '<STR_LIT>' + phone_id <EOL> params = { } <EOL> if number is not None : <EOL> params [ '<STR_LIT>' ] = number <EOL> if extension is not None : <EOL> params [ '<STR_LIT>' ] = extension <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> if type is not None : <EOL> params [ '<STR_LIT:type>' ] = type <EOL> if platform is not None : <EOL> params [ '<STR_LIT>' ] = platform <EOL> if predelay is not None : <EOL> params [ '<STR_LIT>' ] = predelay <EOL> if postdelay is not None : <EOL> params [ '<STR_LIT>' ] = postdelay <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def delete_phone ( self , phone_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' + phone_id <EOL> params = { } <EOL> return self . json_api_call ( '<STR_LIT>' , path , params ) <EOL> def send_sms_activation_to_phone ( self , phone_id , <EOL> valid_secs = None , <EOL> install = None , <EOL> installation_msg = None , <EOL> activation_msg = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' + phone_id + '<STR_LIT>' <EOL> params = { } <EOL> if valid_secs is not None : <EOL> params [ '<STR_LIT>' ] = str ( valid_secs ) <EOL> if install is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( bool ( install ) ) ) <EOL> if installation_msg is not None : <EOL> params [ '<STR_LIT>' ] = installation_msg <EOL> if activation_msg is not None : <EOL> params [ '<STR_LIT>' ] = activation_msg <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> def create_activation_url ( self , phone_id , <EOL> valid_secs = None , <EOL> install = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' + phone_id + '<STR_LIT>' <EOL> params = { } <EOL> if valid_secs is not None : <EOL> params [ '<STR_LIT>' ] = str ( valid_secs ) <EOL> if install is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( bool ( install ) ) ) <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def send_sms_installation ( self , phone_id , <EOL> installation_msg = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' + phone_id + '<STR_LIT>' <EOL> params = { } <EOL> if installation_msg is not None : <EOL> params [ '<STR_LIT>' ] = installation_msg <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def get_desktoptokens ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> return response <EOL> def get_desktoptoken_by_id ( self , desktoptoken_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' + desktoptoken_id <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , path , { } ) <EOL> return response <EOL> def add_desktoptoken ( self , <EOL> platform , <EOL> name = None ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : platform , <EOL> } <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , <EOL> '<STR_LIT>' , <EOL> params ) <EOL> return response <EOL> def delete_desktoptoken ( self , desktoptoken_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' + six . moves . urllib . parse . quote_plus ( desktoptoken_id ) <EOL> params = { } <EOL> return self . json_api_call ( '<STR_LIT>' , path , params ) <EOL> def update_desktoptoken ( self , <EOL> desktoptoken_id , <EOL> platform = None , <EOL> name = None ) : <EOL> """<STR_LIT>""" <EOL> desktoptoken_id = six . moves . urllib . parse . quote_plus ( str ( desktoptoken_id ) ) <EOL> path = '<STR_LIT>' + desktoptoken_id <EOL> params = { } <EOL> if platform is not None : <EOL> params [ '<STR_LIT>' ] = platform <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , <EOL> path , <EOL> params ) <EOL> return response <EOL> def activate_desktoptoken ( self , desktoptoken_id , valid_secs = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if valid_secs : <EOL> params [ '<STR_LIT>' ] = str ( valid_secs ) <EOL> quoted_id = six . moves . urllib . parse . quote_plus ( desktoptoken_id ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , <EOL> '<STR_LIT>' % quoted_id , <EOL> params ) <EOL> return response <EOL> def get_tokens ( self ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , '<STR_LIT>' , <EOL> params <EOL> ) <EOL> return response <EOL> def get_token_by_id ( self , token_id ) : <EOL> """<STR_LIT>""" <EOL> token_id = six . moves . urllib . parse . quote_plus ( str ( token_id ) ) <EOL> path = '<STR_LIT>' + token_id <EOL> params = { } <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , path , <EOL> params ) <EOL> return response <EOL> def get_tokens_by_serial ( self , type , serial ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT:type>' : type , <EOL> '<STR_LIT>' : serial , <EOL> } <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , '<STR_LIT>' , params ) <EOL> return response <EOL> def delete_token ( self , token_id ) : <EOL> """<STR_LIT>""" <EOL> token_id = six . moves . urllib . parse . quote_plus ( str ( token_id ) ) <EOL> path = '<STR_LIT>' + token_id <EOL> return self . json_api_call ( '<STR_LIT>' , path , { } ) <EOL> def add_hotp6_token ( self , serial , secret , counter = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : serial , '<STR_LIT>' : secret } <EOL> if counter is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( counter ) ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def add_hotp8_token ( self , serial , secret , counter = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : serial , '<STR_LIT>' : secret } <EOL> if counter is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( counter ) ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def add_totp6_token ( self , serial , secret , totp_step = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : serial , '<STR_LIT>' : secret } <EOL> if totp_step is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( totp_step ) ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def add_totp8_token ( self , serial , secret , totp_step = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : serial , '<STR_LIT>' : secret } <EOL> if totp_step is not None : <EOL> params [ '<STR_LIT>' ] = str ( int ( totp_step ) ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def update_token ( self , token_id , totp_step = None ) : <EOL> """<STR_LIT>""" <EOL> token_id = six . moves . urllib . parse . quote_plus ( str ( token_id ) ) <EOL> path = '<STR_LIT>' + token_id <EOL> params = { } <EOL> if totp_step is not None : <EOL> params [ '<STR_LIT>' ] = totp_step <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def add_yubikey_token ( self , serial , private_id , aes_key ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> params = { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT>' : serial , '<STR_LIT>' : private_id , <EOL> '<STR_LIT>' : aes_key } <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , <EOL> params ) <EOL> return response <EOL> def resync_hotp_token ( self , token_id , code1 , code2 , code3 ) : <EOL> """<STR_LIT>""" <EOL> token_id = six . moves . urllib . parse . quote_plus ( str ( token_id ) ) <EOL> path = '<STR_LIT>' + token_id + '<STR_LIT>' <EOL> params = { '<STR_LIT>' : code1 , '<STR_LIT>' : code2 , '<STR_LIT>' : code3 } <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> def get_settings ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . json_api_call ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> def update_settings ( self , <EOL> lockout_threshold = None , <EOL> lockout_expire_duration = None , <EOL> inactive_user_expiration = None , <EOL> log_retention_days = None , <EOL> sms_batch = None , <EOL> sms_expiration = None , <EOL> sms_refresh = None , <EOL> sms_message = None , <EOL> fraud_email = None , <EOL> fraud_email_enabled = None , <EOL> keypress_confirm = None , <EOL> keypress_fraud = None , <EOL> timezone = None , <EOL> telephony_warning_min = None , <EOL> caller_id = None , <EOL> push_enabled = None , <EOL> voice_enabled = None , <EOL> sms_enabled = None , <EOL> mobile_otp_enabled = None , <EOL> u2f_enabled = None , <EOL> user_telephony_cost_max = None , <EOL> minimum_password_length = None , <EOL> password_requires_upper_alpha = None , <EOL> password_requires_lower_alpha = None , <EOL> password_requires_numeric = None , <EOL> password_requires_special = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if lockout_threshold is not None : <EOL> params [ '<STR_LIT>' ] = str ( lockout_threshold ) <EOL> if lockout_expire_duration is not None : <EOL> params [ '<STR_LIT>' ] = str ( lockout_expire_duration ) <EOL> if inactive_user_expiration is not None : <EOL> params [ '<STR_LIT>' ] = str ( inactive_user_expiration ) <EOL> if log_retention_days is not None : <EOL> params [ '<STR_LIT>' ] = str ( log_retention_days ) <EOL> if sms_batch is not None : <EOL> params [ '<STR_LIT>' ] = str ( sms_batch ) <EOL> if sms_expiration is not None : <EOL> params [ '<STR_LIT>' ] = str ( sms_expiration ) <EOL> if sms_refresh is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if sms_refresh else '<STR_LIT:0>' <EOL> if sms_message is not None : <EOL> params [ '<STR_LIT>' ] = sms_message <EOL> if fraud_email is not None : <EOL> params [ '<STR_LIT>' ] = fraud_email <EOL> if fraud_email_enabled is not None : <EOL> params [ '<STR_LIT>' ] = fraud_email_enabled <EOL> if keypress_confirm is not None : <EOL> params [ '<STR_LIT>' ] = keypress_confirm <EOL> if keypress_fraud is not None : <EOL> params [ '<STR_LIT>' ] = keypress_fraud <EOL> if timezone is not None : <EOL> params [ '<STR_LIT>' ] = timezone <EOL> if telephony_warning_min is not None : <EOL> params [ '<STR_LIT>' ] = str ( telephony_warning_min ) <EOL> if caller_id is not None : <EOL> params [ '<STR_LIT>' ] = caller_id <EOL> if push_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if push_enabled else '<STR_LIT:0>' <EOL> if sms_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if sms_enabled else '<STR_LIT:0>' <EOL> if voice_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if voice_enabled else '<STR_LIT:0>' <EOL> if mobile_otp_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if mobile_otp_enabled else '<STR_LIT:0>' <EOL> if u2f_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if u2f_enabled else '<STR_LIT:0>' <EOL> if user_telephony_cost_max is not None : <EOL> params [ '<STR_LIT>' ] = str ( user_telephony_cost_max ) <EOL> if minimum_password_length is not None : <EOL> params [ '<STR_LIT>' ] = str ( minimum_password_length ) <EOL> if password_requires_upper_alpha is not None : <EOL> params [ '<STR_LIT>' ] = ( '<STR_LIT:1>' if <EOL> password_requires_upper_alpha else '<STR_LIT:0>' ) <EOL> if password_requires_lower_alpha is not None : <EOL> params [ '<STR_LIT>' ] = ( '<STR_LIT:1>' if <EOL> password_requires_lower_alpha else '<STR_LIT:0>' ) <EOL> if password_requires_numeric is not None : <EOL> params [ '<STR_LIT>' ] = ( '<STR_LIT:1>' if <EOL> password_requires_numeric else '<STR_LIT:0>' ) <EOL> if password_requires_special is not None : <EOL> params [ '<STR_LIT>' ] = ( '<STR_LIT:1>' if <EOL> password_requires_special else '<STR_LIT:0>' ) <EOL> if not params : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , <EOL> '<STR_LIT>' , <EOL> params ) <EOL> return response <EOL> def get_info_summary ( self ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params <EOL> ) <EOL> return response <EOL> def get_info_telephony_credits_used ( self , <EOL> mintime = None , <EOL> maxtime = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if mintime is not None : <EOL> params [ '<STR_LIT>' ] = mintime <EOL> if maxtime is not None : <EOL> params [ '<STR_LIT>' ] = maxtime <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params <EOL> ) <EOL> return response <EOL> def get_authentication_attempts ( self , <EOL> mintime = None , <EOL> maxtime = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if mintime is not None : <EOL> params [ '<STR_LIT>' ] = mintime <EOL> if maxtime is not None : <EOL> params [ '<STR_LIT>' ] = maxtime <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params <EOL> ) <EOL> return response <EOL> def get_user_authentication_attempts ( self , <EOL> mintime = None , <EOL> maxtime = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if mintime is not None : <EOL> params [ '<STR_LIT>' ] = mintime <EOL> if maxtime is not None : <EOL> params [ '<STR_LIT>' ] = maxtime <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params <EOL> ) <EOL> return response <EOL> def get_groups ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> { } <EOL> ) <EOL> def get_group ( self , gkey ) : <EOL> """<STR_LIT>""" <EOL> return self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' + gkey , <EOL> { } <EOL> ) <EOL> def create_group ( self , name , <EOL> desc = None , <EOL> status = None , <EOL> push_enabled = None , <EOL> sms_enabled = None , <EOL> voice_enabled = None , <EOL> mobile_otp_enabled = None , <EOL> u2f_enabled = None , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT:name>' : name , <EOL> } <EOL> if desc is not None : <EOL> params [ '<STR_LIT>' ] = desc <EOL> if status is not None : <EOL> params [ '<STR_LIT:status>' ] = status <EOL> if push_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if push_enabled else '<STR_LIT:0>' <EOL> if sms_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if sms_enabled else '<STR_LIT:0>' <EOL> if voice_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if voice_enabled else '<STR_LIT:0>' <EOL> if mobile_otp_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if mobile_otp_enabled else '<STR_LIT:0>' <EOL> if u2f_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if u2f_enabled else '<STR_LIT:0>' <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:POST>' , <EOL> '<STR_LIT>' , <EOL> params <EOL> ) <EOL> return response <EOL> def delete_group ( self , gkey ) : <EOL> """<STR_LIT>""" <EOL> return self . json_api_call ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' + gkey , <EOL> { } <EOL> ) <EOL> def modify_group ( self , <EOL> gkey , <EOL> name = None , <EOL> desc = None , <EOL> status = None , <EOL> push_enabled = None , <EOL> sms_enabled = None , <EOL> voice_enabled = None , <EOL> mobile_otp_enabled = None , <EOL> u2f_enabled = None , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> if desc is not None : <EOL> params [ '<STR_LIT>' ] = desc <EOL> if status is not None : <EOL> params [ '<STR_LIT:status>' ] = status <EOL> if push_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if push_enabled else '<STR_LIT:0>' <EOL> if sms_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if sms_enabled else '<STR_LIT:0>' <EOL> if voice_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if voice_enabled else '<STR_LIT:0>' <EOL> if mobile_otp_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if mobile_otp_enabled else '<STR_LIT:0>' <EOL> if u2f_enabled is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if u2f_enabled else '<STR_LIT:0>' <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:POST>' , <EOL> '<STR_LIT>' + gkey , <EOL> params <EOL> ) <EOL> return response <EOL> def get_integrations ( self ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params <EOL> ) <EOL> return response <EOL> def get_integration ( self , integration_key ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> response = self . json_api_call ( <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' + integration_key , <EOL> params <EOL> ) <EOL> return response <EOL> def create_integration ( self , <EOL> name , <EOL> integration_type , <EOL> visual_style = None , <EOL> greeting = None , <EOL> notes = None , <EOL> enroll_policy = None , <EOL> username_normalization_policy = None , <EOL> adminapi_admins = None , <EOL> adminapi_info = None , <EOL> adminapi_integrations = None , <EOL> adminapi_read_log = None , <EOL> adminapi_read_resource = None , <EOL> adminapi_settings = None , <EOL> adminapi_write_resource = None , <EOL> trusted_device_days = None , <EOL> ip_whitelist = None , <EOL> ip_whitelist_enroll_policy = None , <EOL> groups_allowed = None , <EOL> self_service_allowed = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> if integration_type is not None : <EOL> params [ '<STR_LIT:type>' ] = integration_type <EOL> if visual_style is not None : <EOL> params [ '<STR_LIT>' ] = visual_style <EOL> if greeting is not None : <EOL> params [ '<STR_LIT>' ] = greeting <EOL> if notes is not None : <EOL> params [ '<STR_LIT>' ] = notes <EOL> if username_normalization_policy is not None : <EOL> params [ '<STR_LIT>' ] = username_normalization_policy <EOL> if enroll_policy is not None : <EOL> params [ '<STR_LIT>' ] = enroll_policy <EOL> if trusted_device_days is not None : <EOL> params [ '<STR_LIT>' ] = str ( trusted_device_days ) <EOL> if ip_whitelist is not None : <EOL> params [ '<STR_LIT>' ] = self . _canonicalize_ip_whitelist ( ip_whitelist ) <EOL> if ip_whitelist_enroll_policy is not None : <EOL> params [ '<STR_LIT>' ] = ip_whitelist_enroll_policy <EOL> if adminapi_admins is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_admins else '<STR_LIT:0>' <EOL> if adminapi_info is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_info else '<STR_LIT:0>' <EOL> if adminapi_integrations is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_integrations else '<STR_LIT:0>' <EOL> if adminapi_read_log is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_read_log else '<STR_LIT:0>' <EOL> if adminapi_read_resource is not None : <EOL> params [ '<STR_LIT>' ] = ( <EOL> '<STR_LIT:1>' if adminapi_read_resource else '<STR_LIT:0>' ) <EOL> if adminapi_settings is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_settings else '<STR_LIT:0>' <EOL> if adminapi_write_resource is not None : <EOL> params [ '<STR_LIT>' ] = ( <EOL> '<STR_LIT:1>' if adminapi_write_resource else '<STR_LIT:0>' ) <EOL> if groups_allowed is not None : <EOL> params [ '<STR_LIT>' ] = groups_allowed <EOL> if self_service_allowed is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if self_service_allowed else '<STR_LIT:0>' <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , <EOL> '<STR_LIT>' , <EOL> params ) <EOL> return response <EOL> def delete_integration ( self , integration_key ) : <EOL> """<STR_LIT>""" <EOL> integration_key = six . moves . urllib . parse . quote_plus ( str ( integration_key ) ) <EOL> path = '<STR_LIT>' % integration_key <EOL> return self . json_api_call ( '<STR_LIT>' , path , { } ) <EOL> def update_integration ( self , <EOL> integration_key , <EOL> name = None , <EOL> visual_style = None , <EOL> greeting = None , <EOL> notes = None , <EOL> enroll_policy = None , <EOL> username_normalization_policy = None , <EOL> adminapi_admins = None , <EOL> adminapi_info = None , <EOL> adminapi_integrations = None , <EOL> adminapi_read_log = None , <EOL> adminapi_read_resource = None , <EOL> adminapi_settings = None , <EOL> adminapi_write_resource = None , <EOL> reset_secret_key = None , <EOL> trusted_device_days = None , <EOL> ip_whitelist = None , <EOL> ip_whitelist_enroll_policy = None , <EOL> groups_allowed = None , <EOL> self_service_allowed = None ) : <EOL> """<STR_LIT>""" <EOL> integration_key = six . moves . urllib . parse . quote_plus ( str ( integration_key ) ) <EOL> path = '<STR_LIT>' % integration_key <EOL> params = { } <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> if visual_style is not None : <EOL> params [ '<STR_LIT>' ] = visual_style <EOL> if greeting is not None : <EOL> params [ '<STR_LIT>' ] = greeting <EOL> if notes is not None : <EOL> params [ '<STR_LIT>' ] = notes <EOL> if enroll_policy is not None : <EOL> params [ '<STR_LIT>' ] = enroll_policy <EOL> if username_normalization_policy is not None : <EOL> params [ '<STR_LIT>' ] = username_normalization_policy <EOL> if trusted_device_days is not None : <EOL> params [ '<STR_LIT>' ] = str ( trusted_device_days ) <EOL> if ip_whitelist is not None : <EOL> params [ '<STR_LIT>' ] = self . _canonicalize_ip_whitelist ( ip_whitelist ) <EOL> if ip_whitelist_enroll_policy is not None : <EOL> params [ '<STR_LIT>' ] = ip_whitelist_enroll_policy <EOL> if adminapi_admins is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_admins else '<STR_LIT:0>' <EOL> if adminapi_info is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_info else '<STR_LIT:0>' <EOL> if adminapi_integrations is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_integrations else '<STR_LIT:0>' <EOL> if adminapi_read_log is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_read_log else '<STR_LIT:0>' <EOL> if adminapi_read_resource is not None : <EOL> params [ '<STR_LIT>' ] = ( <EOL> '<STR_LIT:1>' if adminapi_read_resource else '<STR_LIT:0>' ) <EOL> if adminapi_settings is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if adminapi_settings else '<STR_LIT:0>' <EOL> if adminapi_write_resource is not None : <EOL> params [ '<STR_LIT>' ] = ( <EOL> '<STR_LIT:1>' if adminapi_write_resource else '<STR_LIT:0>' ) <EOL> if reset_secret_key is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' <EOL> if groups_allowed is not None : <EOL> params [ '<STR_LIT>' ] = groups_allowed <EOL> if self_service_allowed is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if self_service_allowed else '<STR_LIT:0>' <EOL> if not params : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> return response <EOL> def get_admins ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> return response <EOL> def get_admin ( self , admin_id ) : <EOL> """<STR_LIT>""" <EOL> admin_id = six . moves . urllib . parse . quote_plus ( str ( admin_id ) ) <EOL> path = '<STR_LIT>' % admin_id <EOL> response = self . json_api_call ( '<STR_LIT:GET>' , path , { } ) <EOL> return response <EOL> def add_admin ( self , name , email , phone , password , role = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> if email is not None : <EOL> params [ '<STR_LIT:email>' ] = email <EOL> if phone is not None : <EOL> params [ '<STR_LIT>' ] = phone <EOL> if password is not None : <EOL> params [ '<STR_LIT:password>' ] = password <EOL> if role is not None : <EOL> params [ '<STR_LIT>' ] = role <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , '<STR_LIT>' , params ) <EOL> return response <EOL> def update_admin ( self , admin_id , <EOL> name = None , <EOL> phone = None , <EOL> password = None ) : <EOL> """<STR_LIT>""" <EOL> admin_id = six . moves . urllib . parse . quote_plus ( str ( admin_id ) ) <EOL> path = '<STR_LIT>' % admin_id <EOL> params = { } <EOL> if name is not None : <EOL> params [ '<STR_LIT:name>' ] = name <EOL> if phone is not None : <EOL> params [ '<STR_LIT>' ] = phone <EOL> if password is not None : <EOL> params [ '<STR_LIT:password>' ] = password <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , path , params ) <EOL> return response <EOL> def delete_admin ( self , admin_id ) : <EOL> """<STR_LIT>""" <EOL> admin_id = six . moves . urllib . parse . quote_plus ( str ( admin_id ) ) <EOL> path = '<STR_LIT>' % admin_id <EOL> return self . json_api_call ( '<STR_LIT>' , path , { } ) <EOL> def reset_admin ( self , admin_id ) : <EOL> """<STR_LIT>""" <EOL> admin_id = six . moves . urllib . parse . quote_plus ( str ( admin_id ) ) <EOL> path = '<STR_LIT>' % admin_id <EOL> return self . json_api_call ( '<STR_LIT:POST>' , path , { } ) <EOL> def activate_admin ( self , email , <EOL> send_email = False , <EOL> valid_days = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if email is not None : <EOL> params [ '<STR_LIT:email>' ] = email <EOL> if send_email is not None : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:1>' if send_email else '<STR_LIT:0>' <EOL> if valid_days is not None : <EOL> params [ '<STR_LIT>' ] = str ( valid_days ) <EOL> response = self . json_api_call ( '<STR_LIT:POST>' , <EOL> '<STR_LIT>' , <EOL> params ) <EOL> return response <EOL> def get_logo ( self ) : <EOL> """<STR_LIT>""" <EOL> response , data = self . api_call ( '<STR_LIT:GET>' , <EOL> '<STR_LIT>' , <EOL> params = { } ) <EOL> content_type = response . getheader ( '<STR_LIT:Content-Type>' ) <EOL> if content_type and content_type . startswith ( '<STR_LIT>' ) : <EOL> return data <EOL> else : <EOL> return self . parse_json_response ( response , data ) <EOL> def update_logo ( self , logo ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : logo . encode ( '<STR_LIT>' ) , <EOL> } <EOL> return self . json_api_call ( '<STR_LIT:POST>' , '<STR_LIT>' , params ) <EOL> def delete_logo ( self ) : <EOL> return self . json_api_call ( '<STR_LIT>' , '<STR_LIT>' , params = { } ) </s>
