a method to add or update an authorized user to the bucket
            
        :param uid: string with id to assign to user
        :param user_password: string with password to assign to user
        :param user_email: [optional] string with email of user for future lookup
        :param user_channels: [optional] list of strings with channels to subscribe to user
        :param user_roles: [optional] list of strings with roles to assign to user
        :param user_views: [optional] list of query criteria to create as views for user
        :param disable_account: boolean to disable access to records by user
        :return: integer with status code of user account creation

def save_user(self, uid, user_password, user_email='', user_channels=None, user_roles=None, user_views=None, disable_account=False):

        '''
            a method to add or update an authorized user to the bucket
            
        :param uid: string with id to assign to user
        :param user_password: string with password to assign to user
        :param user_email: [optional] string with email of user for future lookup
        :param user_channels: [optional] list of strings with channels to subscribe to user
        :param user_roles: [optional] list of strings with roles to assign to user
        :param user_views: [optional] list of query criteria to create as views for user
        :param disable_account: boolean to disable access to records by user
        :return: integer with status code of user account creation
        '''

    # https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/user/put__db___user__name_
    # https://developer.couchbase.com/documentation/mobile/1.5/guides/sync-gateway/authorizing-users/index.html
    
        title = '%s.save_user' % self.__class__.__name__
        
    # validate inputs
        input_fields = {
            'uid': uid,
            'user_password': user_password,
            'user_email': user_email,
            'user_channels': user_channels,
            'user_roles': user_roles
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
    
    # construct url
        url = self.bucket_url + '/_user/%s' % uid

    # create default settings
        json_data = {
            'admin_channels': [ uid ],
            'admin_roles': [ uid ],
            'name': uid,
            'password': user_password,
            'disabled': disable_account
        }
    
    # add optional additional channels and roles
        if user_email:
            json_data['email'] = user_email
        if user_channels:
            json_data['admin_channels'].extend(user_channels)
        if user_roles:
            json_data['admin_roles'].extend(user_roles)

    # send request
        response = requests.put(url, json=json_data)

    # create indices
        if response.status_code in (200, 201) and not self.public:
            self.create_view(uid=uid)
            if user_views:
                for criteria in user_views:
                    self.create_view(query_criteria=criteria, uid=uid)

    # report outcome
        self.printer('User "%s" updated in bucket "%s"' % (uid, self.bucket_name))
        
        return response.status_code