|
7 | 7 | http://docs.keboola.apiary.io/#reference/metadata/table-metadata |
8 | 8 | """ |
9 | 9 | import json |
10 | | -import tempfile |
11 | | -import os |
12 | 10 | from kbcstorage.base import Endpoint |
13 | | -from kbcstorage.files import Files |
14 | | -from kbcstorage.jobs import Jobs |
15 | 11 |
|
16 | 12 |
|
17 | 13 | class TablesMetadata(Endpoint): |
@@ -67,32 +63,32 @@ def delete(self, table_id, metadata_id): |
67 | 63 | self._delete(url) |
68 | 64 |
|
69 | 65 | def create(self, table_id, provider, metadata, columns_metadata): |
70 | | - """ |
71 | | - Post metadata to a table. |
72 | | -
|
73 | | - Args: |
74 | | - table_id (str): Table id |
75 | | - provider (str): Provider of the metadata |
76 | | - metadata (list): List of metadata dictionaries with 'key' and 'value' |
77 | | - columns_metadata (dict): Dictionary with column metadata |
78 | | -
|
79 | | - Returns: |
80 | | - response_body: The parsed json from the HTTP response. |
81 | | -
|
82 | | - Raises: |
83 | | - requests.HTTPError: If the API request fails. |
84 | | - """ |
85 | | - if not isinstance(table_id, str) or table_id == '': |
86 | | - raise ValueError("Invalid table_id '{}'.".format(table_id)) |
87 | | - |
88 | | - url = '{}/{}/metadata'.format(self.base_url, table_id) |
89 | | - headers = { |
90 | | - 'Content-Type': 'application/json', |
91 | | - 'X-StorageApi-Token': self.token |
92 | | - } |
93 | | - data = { |
94 | | - "provider": provider, |
95 | | - "metadata": metadata, |
96 | | - "columnsMetadata": columns_metadata |
97 | | - } |
98 | | - return self._post(url, data=json.dumps(data), headers=headers) |
| 66 | + """ |
| 67 | + Post metadata to a table. |
| 68 | +
|
| 69 | + Args: |
| 70 | + table_id (str): Table id |
| 71 | + provider (str): Provider of the metadata |
| 72 | + metadata (list): List of metadata dictionaries with 'key' and 'value' |
| 73 | + columns_metadata (dict): Dictionary with column metadata |
| 74 | +
|
| 75 | + Returns: |
| 76 | + response_body: The parsed json from the HTTP response. |
| 77 | +
|
| 78 | + Raises: |
| 79 | + requests.HTTPError: If the API request fails. |
| 80 | + """ |
| 81 | + if not isinstance(table_id, str) or table_id == '': |
| 82 | + raise ValueError("Invalid table_id '{}'.".format(table_id)) |
| 83 | + |
| 84 | + url = '{}/{}/metadata'.format(self.base_url, table_id) |
| 85 | + headers = { |
| 86 | + 'Content-Type': 'application/json', |
| 87 | + 'X-StorageApi-Token': self.token |
| 88 | + } |
| 89 | + data = { |
| 90 | + "provider": provider, |
| 91 | + "metadata": metadata, |
| 92 | + "columnsMetadata": columns_metadata |
| 93 | + } |
| 94 | + return self._post(url, data=json.dumps(data), headers=headers) |
0 commit comments