Giter Site home page Giter Site logo

cruddy's People

Contributors

garnaat avatar jedberg avatar pas256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cruddy's Issues

How can I do a consistent read?

In boto3, I can do a consistent read with the following

table.get_item(
    Key={
        'id': self._my_id
    },
    ConsistentRead=True
)

Given the current _get() function, I am not sure how I could do that, resulting in all reads being eventually consistent.

Generate empty item JSON

It would be nice to have a CLI command that would generate a JSON object with the required attribute already present. That would allow me to then edit the file and give it to create.

Kinda like the CLI skeleton from the AWS CLI.

Get of id that doesn't exist raises KeyError

Not the best experience:

line 49, in load_xyz response = self._xyz_crud.get(self.id) 
File "/var/task/cruddy/__init__.py", 
line 210, in get item = response.raw_response['Item'] KeyError: 'Item'

I think returning a response would be better

Must create before increment_counter. Discuss

Currently, if you call increment_counter on an id that doesn't existing in the table yet, the response is:

{
  "status": "error",
  "error_message": "The provided expression refers to an attribute that does not exist in the item",
  "error_code": "ValidationException",
  "error_type": null,
  "raw_response": null,
  "data": null,
  "metadata": null
}

That means you must first call create and give the item a starting number before you can subsequently call increment_counter.

I am thinking it would be nice to handle that inside cruddy. When the above happens, make a subsequent call to create and set the counter_name to whatever the increment is as the initial number.

Thoughts?

Fail gracefully when the Lambda func doesn't have the right permissions

I just did a

./cruddy search my_id=72538

and received the following stacktrace:

error
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/Current/bin/cruddy", line 9, in <module>
    load_entry_point('cruddy==0.9.0', 'console_scripts', 'cruddy')()
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/cruddy/scripts/cli.py", line 159, in search
    handler.invoke(data)
  File "/usr/local/lib/python2.7/site-packages/cruddy/scripts/cli.py", line 70, in invoke
    self._invoke_lambda(payload)
  File "/usr/local/lib/python2.7/site-packages/cruddy/scripts/cli.py", line 56, in _invoke_lambda
    click.echo(click.style(crud_response['error_type'], fg='red'))
  File "/usr/local/lib/python2.7/site-packages/click/termui.py", line 393, in style
    return ''.join(bits)
TypeError: sequence item 1: expected string, NoneType found

Update without encrypting fields

Sometimes, it is useful to get an item from a cruddy handler, make some modifications and then update it. Same with list: iterate through and update specific items.

If there are any encrypted fields, the data from those methods above is not suitable to pass to update as it would result in the encrypted fields being double-encrypted. A get must be called with decrypt=True, and list has no such option.

One idea is to make it possible to update an item without encrypting fields. Perhaps

update(item, encrypt=False)

where this stores all fields in item verbatim in DynamoDB.

CLI increment returns null

It would be nice if when calling increment using the cruddy CLI that it returned the new number. Currently it just returns null

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.