pymensago/iscmds.py
def preregister(conn: ServerConnection, wid: utils.UUID=None, uid: utils.UserID=None,
				domain: utils.Domain=None) -> RetVal:
	'''Provisions a preregistered account on the server. Note that the uid, wid, and domain are 
	all optional. If none of them are specified, then the server generates a workspace with the 
	organization's default domain.'''
	request = { 'Action':'PREREG', 'Data':{} }

	if wid and not wid.is_empty():
		request['Data']['Workspace-ID'] = wid.as_string()
	
	if uid and not uid.is_empty():
			request['Data']['User-ID'] = uid.as_string()
	
	if domain and not domain.is_empty():
		request['Data']['Domain'] = domain.as_string()

	status = conn.send_message(request)
	if status.error():
		return status
	
	response = conn.read_response(server_response)
	if response.error():
		return response
	
	if response['Code'] != 200:
		return wrap_server_error(response)

	out = RetVal()
	
	# Validate response fields
	for field in [ 'Domain', 'Workspace-ID', 'Reg-Code']:
		if field not in response['Data']:
			return RetVal(ErrServerError, 'server did not return all required fields')

	out['domain'] = utils.Domain(response['Data']['Domain'])
	out['wid'] = utils.UUID(response['Data']['Workspace-ID'])
	out['regcode'] = response['Data']['Reg-Code']

	if 'User-ID' in response['Data']:
		out['uid'] = utils.UserID(response['Data']['User-ID'])
		if not out['uid'].is_valid():
			return RetVal(ErrServerError, 'server returned invalid user ID')
	
	if not (out['domain'].is_valid() and out['wid'].is_valid()):
		return RetVal(ErrServerError, 'server returned invalid data')

	return out
Provisions a preregistered account on the server. Note that the uid, wid, and domain are 
	all optional. If none of them are specified, then the server generates a workspace with the 
	organization's default domain.
Provisions a preregistered account on the server. Note that the uid, wid, and domain are
all optional. If none of them are specified, then the server generates a workspace with the
organization's default domain.
Provisions a preregistered account on the server . Note that the uid wid and domain are all optional . If none of them are specified then the server generates a workspace with the organization ' s default domain .
def preregister(conn: ServerConnection, wid: utils.UUID=None, uid: utils.UserID=None,
				domain: utils.Domain=None) -> RetVal:
	request = { 'Action':'PREREG', 'Data':{} }
	if wid and not wid.is_empty():
		request['Data']['Workspace-ID'] = wid.as_string()
	if uid and not uid.is_empty():
			request['Data']['User-ID'] = uid.as_string()
	if domain and not domain.is_empty():
		request['Data']['Domain'] = domain.as_string()
	status = conn.send_message(request)
	if status.error():
		return status
	response = conn.read_response(server_response)
	if response.error():
		return response
	if response['Code'] != 200:
		return wrap_server_error(response)
	out = RetVal()
	for field in [ 'Domain', 'Workspace-ID', 'Reg-Code']:
		if field not in response['Data']:
			return RetVal(ErrServerError, 'server did not return all required fields')
	out['domain'] = utils.Domain(response['Data']['Domain'])
	out['wid'] = utils.UUID(response['Data']['Workspace-ID'])
	out['regcode'] = response['Data']['Reg-Code']
	if 'User-ID' in response['Data']:
		out['uid'] = utils.UserID(response['Data']['User-ID'])
		if not out['uid'].is_valid():
			return RetVal(ErrServerError, 'server returned invalid user ID')
	if not (out['domain'].is_valid() and out['wid'].is_valid()):
		return RetVal(ErrServerError, 'server returned invalid data')
	return out
def preregister ( conn : ServerConnection , wid : utils . UUID = None , uid : utils . UserID = None , domain : utils . Domain = None ) -> RetVal : request = { 'Action' : 'PREREG' , 'Data' : { } } if wid and not wid . is_empty ( ) : request [ 'Data' ] [ 'Workspace-ID' ] = wid . as_string ( ) if uid and not uid . is_empty ( ) : request [ 'Data' ] [ 'User-ID' ] = uid . as_string ( ) if domain and not domain . is_empty ( ) : request [ 'Data' ] [ 'Domain' ] = domain . as_string ( ) status = conn . send_message ( request ) if status . error ( ) : return status response = conn . read_response ( server_response ) if response . error ( ) : return response if response [ 'Code' ] != 200 : return wrap_server_error ( response ) out = RetVal ( ) for field in [ 'Domain' , 'Workspace-ID' , 'Reg-Code' ] : if field not in response [ 'Data' ] : return RetVal ( ErrServerError , 'server did not return all required fields' ) out [ 'domain' ] = utils . Domain ( response [ 'Data' ] [ 'Domain' ] ) out [ 'wid' ] = utils . UUID ( response [ 'Data' ] [ 'Workspace-ID' ] ) out [ 'regcode' ] = response [ 'Data' ] [ 'Reg-Code' ] if 'User-ID' in response [ 'Data' ] : out [ 'uid' ] = utils . UserID ( response [ 'Data' ] [ 'User-ID' ] ) if not out [ 'uid' ] . is_valid ( ) : return RetVal ( ErrServerError , 'server returned invalid user ID' ) if not ( out [ 'domain' ] . is_valid ( ) and out [ 'wid' ] . is_valid ( ) ) : return RetVal ( ErrServerError , 'server returned invalid data' ) return out
Provisions a preregistered account on the server.
Provisions a preregistered account on the server .
'''Provisions a preregistered account on the server. Note that the uid, wid, and domain are 
	all optional. If none of them are specified, then the server generates a workspace with the 
	organization's default domain.''' # Validate response fields
conn
ServerConnection
wid
utils.UUID
uid
utils.UserID
domain
utils.Domain