Add DELETE repository API call

Partially-implements blueprint murano-repository-api-v2
Implements blueprint app-delete

Change-Id: I3c81615a679e733fb084cd3918ca9a4560475d30
This commit is contained in:
Ekaterina Fedorova 2014-04-02 16:16:05 +04:00
parent 6892ff379c
commit b2dee880b6
4 changed files with 25 additions and 6 deletions

View File

@ -184,6 +184,9 @@ class Controller(object):
package = db_api.package_get(package_id, req.context)
return package.archive
def delete(self, req, package_id):
db_api.package_delete(package_id)
def show_categories(self, req):
categories = db_api.categories_list()
return {"categories": [category.to_dict() for category in categories]}

View File

@ -129,6 +129,10 @@ class API(wsgi.Router):
controller=catalog_resource,
action='get',
conditions={'method': ['GET']})
mapper.connect('/catalog/packages/{package_id}',
controller=catalog_resource,
action='delete',
conditions={'method': ['DELETE']})
mapper.connect('/catalog/packages/{package_id}',
controller=catalog_resource,
action='update',

View File

@ -343,6 +343,18 @@ def package_upload(values, tenant_id):
return package
def package_delete(package_id):
"""
Delete package information from the system ID of a package, string
parameters to update
"""
session = db_session.get_session()
with session.begin():
package = session.query(models.Package).get(package_id)
session.delete(package)
def categories_list():
session = db_session.get_session()
return session.query(models.Category).all()

View File

@ -209,8 +209,8 @@ package_to_category = sa.Table('package_to_category',
sa.ForeignKey('package.id')),
sa.Column('category_id',
sa.String(32),
sa.ForeignKey('category.id'))
)
sa.ForeignKey('category.id',
ondelete="RESTRICT")))
package_to_tag = sa.Table('package_to_tag',
BASE.metadata,
@ -219,8 +219,8 @@ package_to_tag = sa.Table('package_to_tag',
sa.ForeignKey('package.id')),
sa.Column('tag_id',
sa.String(32),
sa.ForeignKey('tag.id'))
)
sa.ForeignKey('tag.id',
ondelete="CASCADE")))
class Package(BASE, ModelBase):
@ -246,14 +246,14 @@ class Package(BASE, ModelBase):
is_public = sa.Column(sa.Boolean, default=True)
tags = sa_orm.relationship("Tag",
secondary=package_to_tag,
cascade='save-update, merge, delete',
cascade='save-update, merge',
lazy='joined')
logo = sa.Column(sa.BLOB, nullable=True)
owner_id = sa.Column(sa.String(36), nullable=False)
ui_definition = sa.Column(sa.Text)
categories = sa_orm.relationship("Category",
secondary=package_to_category,
cascade='save-update, merge, delete',
cascade='save-update, merge',
lazy='joined')
class_definition = sa_orm.relationship("Class")