'Write data to InfluxDB.
:param data: the data to be written
:type data: (if protocol is \'json\') dict
(if protocol is \'line\') sequence of line protocol strings
:param params: additional parameters for the request, defaults to None
:type params: dict
:param expected_response_code: the expected response code of the write
operation, defaults to 204
:type expected_response_code: int
:param protocol: protocol of input data, either \'json\' or \'line\'
:type protocol: str
:returns: True, if the write operation is successful
:rtype: bool'

def write(self, data, params=None, expected_response_code=204, protocol=u'json'):

    headers = self._headers
    headers[u'Content-type'] = u'application/octet-stream'
    if params:
        precision = params.get(u'precision')
    else:
        precision = None
    if (protocol == u'json'):
        data = make_lines(data, precision).encode(u'utf-8')
    elif (protocol == u'line'):
        data = (u'\n'.join(data) + u'\n').encode(u'utf-8')
    self.request(url=u'write', method=u'POST', params=params, data=data, expected_response_code=expected_response_code, headers=headers)
    return True
