<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def request(self, method, api_url, params={}, **kwargs):
 """Generate the API call to the device."""


        LOG.debug("axapi_http: full url = %s", self.url_base + api_url)
        LOG.debug("axapi_http: %s url = %s", method, api_url)
        LOG.debug("axapi_http: params = %s", json.dumps(logutils.clean(params), indent=4))

        # Set "data" variable for the request
        if params:
            extra_params = kwargs.get('axapi_args', {})
            params_copy = merge_dicts(params, extra_params)
            LOG.debug("axapi_http: params_all = %s", logutils.clean(params_copy))

            payload = json.dumps(params_copy)
        else:
            try:
                payload = kwargs.pop('payload', None)
                self.headers = dict(self.HEADERS, **kwargs.pop('headers', {}))
                LOG.debug("axapi_http: headers_all = %s", logutils.clean(self.headers))
            except KeyError:
                payload = None

        max_retries = kwargs.get('max_retries', self.max_retries)
        timeout = kwargs.get('timeout', self.timeout)

        # Create session to set HTTPAdapter or SSLAdapter
        session = Session()
        if self.port == 443:
            # Add adapter for any https session to force TLS1_0 connection for v21 of AXAPI
            session.mount('https://', SSLAdapter(max_retries=max_retries))
        else:
            session.mount('http://', HTTPAdapter(max_retries=max_retries))
        session_request = getattr(session, method.lower())

        # Make actual request and handle any errors
        try:
            device_response = session_request(
                self.url_base + api_url, verify=False, data=payload, headers=self.HEADERS, timeout=timeout
            )
        except (Exception) as e:
            LOG.error("acos_client failing with error %s after %s retries", e.__class__.__name__, max_retries)
            raise e
        finally:
            session.close()

        # Log if the reponse is one of the known broken response
        if device_response in broken_replies:
            device_response = broken_replies[device_response]
            LOG.debug("axapi_http: broken reply, new response: %s", logutils.clean(device_response))

        # Validate json response
        try:
            json_response = device_response.json()
            LOG.debug("axapi_http: data = %s", json.dumps(logutils.clean(json_response), indent=4))
        except ValueError as e:
            # The response is not JSON but it still succeeded.
            LOG.debug("axapi_http: json = %s", e)
            return device_response

        # Handle "fail" responses returned by AXAPI
        if 'response' in json_response and 'status' in json_response['response']:
            if json_response['response']['status'] == 'fail':
                    acos_responses.raise_axapi_ex(json_response, action=extract_method(api_url))

        # Return json portion of response
        return json_response