Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samedhi/gaend
Convert GAE Models into endpoints
https://github.com/samedhi/gaend
bigquery elasticsearch google-app-engine restful taskqueue
Last synced: about 1 month ago
JSON representation
Convert GAE Models into endpoints
- Host: GitHub
- URL: https://github.com/samedhi/gaend
- Owner: samedhi
- License: mit
- Created: 2016-12-15T17:47:11.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-10T07:51:30.000Z (almost 8 years ago)
- Last Synced: 2024-10-09T09:34:30.655Z (2 months ago)
- Topics: bigquery, elasticsearch, google-app-engine, restful, taskqueue
- Language: Python
- Size: 87.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gaend - **G**oogle **A**pp **E**ngine **End**points
## Synopsis
This project converts a `google.appengine.ext.ndb.Model` into a HTTP endpoints. It provides validation, routing, documentation, and CRUD server endpoints. Its purpose is to act as a "DSL" for Google App Engine, allowing you to quickly write CRUD servers with just a `Model`.## Full Code Example
```yaml
# app.yaml
runtime: python27
api_version: 1
threadsafe: truehandlers:
- url: /.*
script: gaend.main.APP
``````python
# main.py
from google.appengine.ext import ndb
from gaend.models import GaendFullMixinclass Alien(ndb.Model, GaendFullMixin):
proboscis_count = ndb.IntegerProperty(default=1)
kind = ndb.StringProperty(required=True, choices=["Grey", "Martian", "Hutt"])
name = ndb.StringProperty(lambda s: len(s) >= 1 and len(s) <= 20)
full_name = ndb.ComputedProperty(lambda self: self.name + " the " + self.kind)
``````bash
> gcloud deploy app.yaml
...
Deployed service [modeling-agency] to [https://aliens-are-real.appspot.com]
...
> curl -H "Content-Type: application/json" \
-d '{"kind": "Martian", "name": "Bob"}' \
https://aliens-are-real.appspot.com/alien{"key": "fsdafsdaf",
"kind": "Martian",
"proboscis_count": 1,
"name": "Bob",
"full_name": "Bob the Martian"}
```## Motivation
Sometimes your data is actually pretty simple.
* You want to Create, Read, Update, and Destroy entities using REST endpoints.
* You want to do validation every time an entity is written.
* You want to have up to date documentation of your endpoints.Sometimes, the `ndb.Model` class (`Alien` in the example) contains enough information to do all of the above bullet points. Why spend time writing boilerplate code that can be inferred? Are we programmers or are we programmers? Automate all the things.
## Installation
```bash
> pip install gaend
```## Documentation
[Gaend Read the Docs](http://gaend.readthedocs.io/en/latest/)
## Test
`brew install entr`
`find ./gaend ./tests -name "*.py" -print | entr -drc python runner.py $GOOGLE_CLOUD_SDK`