Adding data source editing to library and CLI
Adding the ability to edit data sources into the client library as well as the CLI. Change-Id: I6fba265e60bef6bba4c9a8dfea62603c09b28acb Partial-Implements: bp edp-edit-data-sources
This commit is contained in:
@@ -46,3 +46,7 @@ class DataSourceManager(base.ResourceManager):
|
||||
|
||||
def delete(self, data_source_id):
|
||||
self._delete('/data-sources/%s' % data_source_id)
|
||||
|
||||
def update(self, data_source_id, update_data):
|
||||
return self._update('/data-sources/%s' % data_source_id,
|
||||
update_data)
|
||||
|
||||
@@ -604,6 +604,24 @@ def do_data_source_delete(cs, args):
|
||||
# TODO(mattf): No indication of result
|
||||
|
||||
|
||||
@utils.arg('--name',
|
||||
help="Name of the data source to update.")
|
||||
@utils.arg('--id',
|
||||
help="ID of the data source to update.")
|
||||
@utils.arg('--json',
|
||||
default=sys.stdin,
|
||||
type=argparse.FileType('r'),
|
||||
help='JSON containing the data source fields to update.')
|
||||
def do_data_source_update(cs, args):
|
||||
"""Update a data source."""
|
||||
update_data = json.loads(args.json.read())
|
||||
result = cs.data_sources.update(
|
||||
args.id or _get_by_id_or_name(cs.data_sources, name=args.name).id,
|
||||
update_data
|
||||
)
|
||||
_show_data_source(result)
|
||||
|
||||
|
||||
#
|
||||
# Job Binary Internals
|
||||
# ~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -39,6 +39,11 @@ class DataSourceTest(base.BaseTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
update_json = {
|
||||
'name': 'UpdatedName',
|
||||
'url': 'hdfs://myfakeserver/fakepath'
|
||||
}
|
||||
|
||||
def test_create_data_sources(self):
|
||||
url = self.URL + '/data-sources'
|
||||
self.responses.post(url, status_code=202,
|
||||
@@ -79,3 +84,11 @@ class DataSourceTest(base.BaseTestCase):
|
||||
self.client.data_sources.delete('id')
|
||||
|
||||
self.assertEqual(url, self.responses.last_request.url)
|
||||
|
||||
def test_update_data_sources(self):
|
||||
update_url = self.URL + '/data-sources/id'
|
||||
self.responses.put(update_url, status_code=202,
|
||||
json=self.update_json)
|
||||
updated = self.client.data_sources.update("id", self.update_json)
|
||||
self.assertEqual(self.update_json["name"], updated.name)
|
||||
self.assertEqual(self.update_json["url"], updated.url)
|
||||
|
||||
Reference in New Issue
Block a user