'Sets class vars and remove unneeded parameters.'

def _api_validate(self, *args, **kwargs):

    if (not plexpy.CONFIG.API_ENABLED):
        self._api_msg = 'API    not    enabled'
    elif (not plexpy.CONFIG.API_KEY):
        self._api_msg = 'API    key    not    generated'
    elif (len(plexpy.CONFIG.API_KEY) != 32):
        self._api_msg = 'API    key    not    generated    correctly'
    elif ('apikey' not in kwargs):
        self._api_msg = 'Parameter    apikey    is    required'
    elif (kwargs.get('apikey', '') != plexpy.CONFIG.API_KEY):
        self._api_msg = 'Invalid    apikey'
    elif ('cmd' not in kwargs):
        self._api_msg = ('Parameter    cmd    is    required.    Possible    commands    are:    %s' % ',    '.join(self._api_valid_methods))
    elif (('cmd' in kwargs) and (kwargs.get('cmd') not in self._api_valid_methods)):
        self._api_msg = ('Unknown    command:    %s.    Possible    commands    are:    %s' % (kwargs.get('cmd', ''), ',    '.join(sorted(self._api_valid_methods))))
    self._api_callback = kwargs.pop('callback', None)
    self._api_apikey = kwargs.pop('apikey', None)
    self._api_cmd = kwargs.pop('cmd', None)
    self._api_debug = kwargs.pop('debug', False)
    self._api_profileme = kwargs.pop('profileme', None)
    self._api_out_type = kwargs.pop('out_type', 'json')
    if ((self._api_apikey == plexpy.CONFIG.API_KEY) and plexpy.CONFIG.API_ENABLED and (self._api_cmd in self._api_valid_methods)):
        self._api_authenticated = True
        self._api_msg = None
        self._api_kwargs = kwargs
    elif ((self._api_cmd in ('get_apikey', 'docs', 'docs_md')) and plexpy.CONFIG.API_ENABLED):
        self._api_authenticated = True
        self._api_msg = None
        self._api_kwargs = kwargs
    logger.debug((u'PlexPy    APIv2    ::    Cleaned    kwargs:    %s' % self._api_kwargs))
    return self._api_kwargs
