def on_get(self, req, resp, tenant_id, secret_id): #verify the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id, when_not_found=_tenant_not_found) #verify the secret exists secret = find_secret(self.db, id=secret_id, when_not_found=_secret_not_found) #verify the secret belongs to the tenant if not secret in tenant.secrets: _secret_not_found() resp.status = falcon.HTTP_200 resp.body = json.dumps(secret.format())
def on_delete(self, req, resp, tenant_id, secret_id): #verify the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id, when_not_found=_tenant_not_found) #verify the secret exists secret = find_secret(self.db, id=secret_id, when_not_found=_secret_not_found) #verify the secret belongs to the tenant if not secret in tenant.secrets: _secret_not_found() self.db.delete(secret) self.db.commit() resp.status = falcon.HTTP_200
def on_put(self, req, resp, tenant_id, secret_id): #verify the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id, when_not_found=_tenant_not_found) #verify the secret exists secret = find_secret(self.db, id=secret_id, when_not_found=_secret_not_found) #verify the secret belongs to the tenant if not secret in tenant.secrets: _secret_not_found() #load the message body = load_body(req) #if attributes are present in message, update the secret if 'name' in body.keys(): secret.name = body['name'] self.db.commit() resp.status = falcon.HTTP_200