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"""
66import json
77from kbcstorage .base import Endpoint
88
99
1010class 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 ))
0 commit comments