I have two models in my flask / restless app: Blueprint and Workload The Blueprint should have a collection of Workloads.
Here are the models:
class Blueprint(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(120), unique=True)
description = db.Column(db.String(250), unique=True)
class Workload(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(120), unique=True)
description = db.Column(db.String(250), unique=True)
image = db.Column(db.String(120), unique=True)
flavor = db.Column(db.String(120), unique=True)
blueprint_id = db.Column(db.Integer, db.ForeignKey('blueprint.id'))
blueprint = db.relationship(Blueprint, backref='workloads')
db.create_all()
# Create the Flask-Restless API manager.
manager = flask.ext.restless.APIManager(app, flask_sqlalchemy_db=db)
# Create API endpoints, which will be available at /api/<tablename> by
# default. Allowed HTTP methods can be specified as well.
manager.create_api(Blueprint, methods=['GET', 'PUT', 'POST', 'DELETE'])
manager.create_api(Workload, methods=['GET', 'PUT', 'POST', 'DELETE'])
What is the right syntax, either with curl or with python, to add a Workload instance to Blueprint's 'workloads' collection?