Skip to content

Commit 7c31af9

Browse files
committed
KAB-46 fix docblocks
1 parent 9cdaf7d commit 7c31af9

2 files changed

Lines changed: 31 additions & 35 deletions

File tree

kbcstorage/configurations_metadata.py

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"""
2-
Manages calls to the Storage API relating to configurations
2+
Manages calls to the Storage API relating to configurations metadata
33
4-
Full documentation https://keboola.docs.apiary.io/#reference/components-and-configurations
4+
Full documentation https://keboola.docs.apiary.io/#reference/metadata/components-configurations-metadata/
55
"""
66
import json
77
from kbcstorage.base import Endpoint
88

99

1010
class ConfigurationsMetadata(Endpoint):
1111
"""
12-
Configurations Endpoint
12+
Configurations metadata Endpoint
1313
"""
1414

1515
def __init__(self, root_url, token, branch_id):
1616
"""
17-
Create a Component endpoint.
17+
Create a Component metadata endpoint.
1818
1919
Args:
2020
root_url (:obj:`str`): The base url for the API.
@@ -23,37 +23,18 @@ def __init__(self, root_url, token, branch_id):
2323
"""
2424
super().__init__(root_url, f"branch/{branch_id}/components", token)
2525

26-
def detail(self, component_id, configuration_id):
27-
"""
28-
Retrieves information about a given configuration.
29-
30-
Args:
31-
component_id (str): The id of the component.
32-
configuration_id (str): The id of the configuration.
33-
34-
Returns:
35-
response_body: The parsed json from the HTTP response.
36-
37-
Raises:
38-
requests.HTTPError: If the API request fails.
39-
"""
40-
if not isinstance(component_id, str) or component_id == '':
41-
raise ValueError("Invalid component_id '{}'.".format(component_id))
42-
if not isinstance(configuration_id, str) or configuration_id == '':
43-
raise ValueError("Invalid component_id '{}'.".format(configuration_id))
44-
url = '{}/{}/configs/{}'.format(self.base_url, component_id, configuration_id)
45-
return self._get(url)
46-
4726
def delete(self, component_id, configuration_id, metadata_id):
4827
"""
49-
Deletes the configuration.
28+
Deletes the configuration metadata identified by ``metadata_id``.
5029
5130
Args:
5231
component_id (str): The id of the component.
5332
configuration_id (str): The id of the configuration.
33+
metadata_id (str): The id of the metadata (not key!).
5434
5535
Raises:
5636
requests.HTTPError: If the API request fails.
37+
ValueError: If the component_id/configuration_id/metadata_id is not a string or is empty.
5738
"""
5839
if not isinstance(component_id, str) or component_id == '':
5940
raise ValueError("Invalid component_id '{}'.".format(component_id))
@@ -66,34 +47,41 @@ def delete(self, component_id, configuration_id, metadata_id):
6647

6748
def list(self, component_id, configuration_id):
6849
"""
69-
Lists configurations of the given component.
50+
Lists metadata for a given component configuration.
7051
7152
Args:
7253
component_id (str): The id of the component.
54+
configuration_id (str): The id of the configuration.
7355
7456
Raises:
7557
requests.HTTPError: If the API request fails.
58+
ValueError: If the component_id/configuration_id is not a string or is empty.
7659
"""
7760
if not isinstance(component_id, str) or component_id == '':
7861
raise ValueError("Invalid component_id '{}'.".format(component_id))
62+
if not isinstance(configuration_id, str) or configuration_id == '':
63+
raise ValueError("Invalid configuration_id '{}'.".format(configuration_id))
7964
url = '{}/{}/configs/{}/metadata'.format(self.base_url, component_id, configuration_id)
8065
return self._get(url)
8166

8267
def create(self, component_id, configuration_id, provider, metadata):
8368
"""
84-
Create a new configuration.
69+
Writes metadata for a given component configuration.
8570
8671
Args:
8772
component_id (str): The id of the component.
8873
configuration (str): The id of the configuration.
8974
provider (str): The provider of the configuration (currently ignored and "user" is sent).
90-
key (str): The key of the configuration.
91-
value (str): The value of the configuration.
75+
metadata (list): A list of metadata items. Item is a dictionary with 'key' and 'value' keys.
76+
9277
Returns:
9378
response_body: The parsed json from the HTTP response.
9479
9580
Raises:
9681
requests.HTTPError: If the API request fails.
82+
ValueError: If the component_id/configuration_id is not a string or is empty.
83+
ValueError: If the metadata is not a list.
84+
ValueError: If the metadata item is not a dictionary.
9785
"""
9886
if not isinstance(component_id, str) or component_id == '':
9987
raise ValueError("Invalid component_id '{}'.".format(component_id))

kbcstorage/tables_metadata.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TablesMetadata(Endpoint):
1616
"""
1717
def __init__(self, root_url, token):
1818
"""
19-
Create a Tables endpoint.
19+
Create a Tables metadata endpoint.
2020
2121
Args:
2222
root_url (:obj:`str`): The base url for the API.
@@ -28,6 +28,9 @@ def list(self, table_id):
2828
"""
2929
List all metadata for table
3030
31+
Args:
32+
table_id (str): Table id
33+
3134
Returns:
3235
response_body: The parsed json from the HTTP response.
3336
@@ -44,14 +47,15 @@ def list(self, table_id):
4447

4548
def delete(self, table_id, metadata_id):
4649
"""
47-
Delete a table referenced by ``table_id``.
50+
Delete a table metadata referenced by ``metadata_id``.
4851
4952
Args:
50-
table_id (str): The id of the table to be deleted.
53+
table_id (str): The id of the table.
54+
metadata_id (str): The id of the table metdata entry to be deleted.
5155
5256
Raises:
5357
requests.HTTPError: If the API request fails.
54-
ValueError: If the table_id is not a string or is empty.
58+
ValueError: If the table_id/metadata_id is not a string or is empty.
5559
"""
5660
if not isinstance(table_id, str) or table_id == '':
5761
raise ValueError("Invalid table_id '{}'.".format(table_id))
@@ -70,13 +74,17 @@ def create(self, table_id, provider, metadata, columns_metadata):
7074
table_id (str): Table id
7175
provider (str): Provider of the metadata
7276
metadata (list): List of metadata dictionaries with 'key' and 'value'
73-
columns_metadata (dict): Dictionary with column metadata
77+
columns_metadata (dict): Dictionary with lists of metadata dictionaries with 'key', 'value', 'columnName'.
7478
7579
Returns:
7680
response_body: The parsed json from the HTTP response.
7781
7882
Raises:
7983
requests.HTTPError: If the API request fails.
84+
ValueError: If the table_id is not a string or is empty.
85+
ValueError: If the provider is not a string or is empty.
86+
ValueError: If the metadata is not a list.
87+
ValueError: If the columns_metadata is not a list
8088
"""
8189
if not isinstance(table_id, str) or table_id == '':
8290
raise ValueError("Invalid table_id '{}'.".format(table_id))

0 commit comments

Comments
 (0)