def post(self): ci_ids = request.values.get('ci_ids') parents = request.values.get('parents') CIRelationManager.batch_update(ci_ids, parents) return self.jsonify(code=200)
def init_ci_relation(): init_ci_type_relation(1) ci_types = CIType.query.all() cis = init_ci_with_type(ci_types) manager = CIRelationManager() cir_id = manager.add(cis[0]['ci_id'], cis[1]['ci_id']) return cir_id
def get(self, second_ci_id): page = get_page(request.values.get("page", 1)) count = get_page_size(request.values.get("count")) manager = CIRelationManager() numfound, total, first_cis = manager.get_first_cis(second_ci_id, per_page=count, page=page) return self.jsonify(numfound=numfound, total=total, page=page, first_cis=first_cis)
def get(self, first_ci_id): page = get_page(request.values.get("page", 1)) count = get_page_size(request.values.get("count")) relation_type = request.values.get("relation_type", "contain") manager = CIRelationManager() numfound, total, second_cis = manager.get_second_cis( first_ci_id, page=page, per_page=count, relation_type=relation_type) return self.jsonify(numfound=numfound, total=total, page=page, second_cis=second_cis)
def get(self, first_ci_id): page = get_page(request.values.get("page", 1)) count = get_page_size(request.values.get("count")) relation_type = request.values.get("relation_type") try: relation_type_id = RelationTypeCache.get(relation_type).id if relation_type else None except AttributeError: return abort(400, "invalid relation type <{0}>".format(relation_type)) manager = CIRelationManager() numfound, total, second_cis = manager.get_second_cis( first_ci_id, page=page, per_page=count, relation_type_id=relation_type_id) return self.jsonify(numfound=numfound, total=total, page=page, second_cis=second_cis)
def delete(self, cr_id): manager = CIRelationManager() manager.delete(cr_id) return self.jsonify(message="CIType Relation is deleted")
def delete(self, first_ci_id, second_ci_id): manager = CIRelationManager() manager.delete_2(first_ci_id, second_ci_id) return self.jsonify(message="CIType Relation is deleted")
def post(self, first_ci_id, second_ci_id): manager = CIRelationManager() res = manager.add(first_ci_id, second_ci_id) return self.jsonify(cr_id=res)