Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote update_mode and add delete_item #43

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,19 @@ def test_put_items(self):
}

response = self._client.put_items(container=self._container,
path=self._path, items=items)
path=self._path,
items=items)

self.assertTrue(response.success)

self._verify_items(self._path, items)

# delete an item
self._client.delete_item(container=self._container, path=self._path + '/linda')
del(items['linda'])

self._verify_items(self._path, items)

def test_put_items_with_error(self):
items = {
'bob': {'age': 42, 'feature': 'mustache'},
Expand Down
23 changes: 19 additions & 4 deletions v3io/dataplane/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ def put_item(self,
access_key=None,
raise_for_status=None,
transport_actions=None,
condition=None,
update_mode=None):
condition=None):
"""Creates an item with the provided attributes. If an item with the same name (primary key) already exists in
the specified table, the existing item is completely overwritten (replaced with a new item). If the item or
table do not exist, the operation creates them.
Expand All @@ -318,8 +317,6 @@ def put_item(self,
The access key with which to authenticate. Defaults to the V3IO_ACCESS_KEY env.
condition (Optional) : str
A Boolean condition expression that defines a conditional logic for executing the put-item operation.
update_mode (Optional) : str
CreateOrReplaceAttributes (default): Creates or replaces attributes

Return Value
----------
Expand Down Expand Up @@ -551,6 +548,24 @@ def get_items(self,
locals(),
v3io.dataplane.output.GetItemsOutput)

def delete_item(self, container, path, access_key=None, raise_for_status=None, transport_actions=None):
"""Deletes an item.

Parameters
----------
container (Required) : str
The container on which to operate.
path (Required) : str
The path of the item
access_key (Optional) : str
The access key with which to authenticate. Defaults to the V3IO_ACCESS_KEY env.

Return Value
----------
A `Response` object.
"""
return self.delete_object(container, path, access_key, raise_for_status, transport_actions)

#
# Stream
#
Expand Down
3 changes: 0 additions & 3 deletions v3io/dataplane/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ def encode_put_item(container_name, access_key, kwargs):
if kwargs['condition'] is not None:
body['ConditionExpression'] = kwargs['condition']

if kwargs['update_mode'] is not None:
body['UpdateMode'] = kwargs['update_mode']

return _encode('PUT',
container_name,
access_key,
Expand Down