<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tables_insert(self, table_name, schema=None, query=None, friendly_name=None, description=None):
 """Issues a request to create a table or view in the specified dataset with the specified id. A schema must be provided to create a Table, or a query must be provided to create a View. Args: table_name: the name of the table as a tuple of components. schema: the schema, if this is a Table creation. query: the query, if this is a View creation. friendly_name: an optional friendly name. description: an optional description. Returns: A parsed result object. Raises: Exception if there is an error performing the operation. """

    url = Api._ENDPOINT + \
        (Api._TABLES_PATH % (table_name.project_id, table_name.dataset_id, '', ''))

    data = {
        'kind': 'bigquery#table',
        'tableReference': {
            'projectId': table_name.project_id,
            'datasetId': table_name.dataset_id,
            'tableId': table_name.table_id
        }
    }
    if schema:
      data['schema'] = {'fields': schema}
    if query:
      data['view'] = {'query': query}
    if friendly_name:
      data['friendlyName'] = friendly_name
    if description:
      data['description'] = description

    return datalab.utils.Http.request(url, data=data, credentials=self._credentials)