def get_as_equipment_by_search(search=dict()): """Return a list of ASEquipment's by dict.""" try: as_equipment = AsnEquipment.get_by_pk() as_map = build_query_to_datatable_v3(as_equipment, search) except FieldError as e: raise ValidationAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) else: return as_map
def delete_asn_equipment(as_ids): """Delete ASNEquipment.""" try: asn_equipment = AsnEquipment() obj = asn_equipment.get_by_pk(ids=as_ids) obj.delete_v4() except exceptions.AsnDoesNotExistException as e: raise ObjectDoesNotExistException(str(e)) except exceptions.AsnAssociatedToEquipmentError as e: raise ValidationAPIException(str(e)) except AsnError as e: raise NetworkAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e))
def delete_asn_equipment_by_asn(asn_id): """Delete ASNEquipment.""" try: asn_obj = AsnEquipment() asn_equipment = asn_obj.get_by_pk(asn=asn_id) for obj in asn_equipment: obj.delete_v4() except exceptions.AsnDoesNotExistException as e: raise ObjectDoesNotExistException(str(e)) except exceptions.AsnAssociatedToEquipmentError as e: raise ValidationAPIException(str(e)) except AsnError as e: raise NetworkAPIException(str(e)) except Exception as e: raise NetworkAPIException(str(e))
def get_as_equipment_by_equip(equipment_id=None): """Return an ASEquipment by equipment id. Args: equipment_id: Id of Equipment """ try: as_equipment = list() for equip in equipment_id: as_equipment += AsnEquipment.get_by_pk(equipment=equip) except AsnNotFoundError as e: raise exceptions.AsnDoesNotExistException(str(e)) return as_equipment
def get_as_equipment_by_asn(asn_id=None): """Return an ASEquipment by asn id. Args: asn_id: Id of ASN """ try: as_equipment = list() for asn in asn_id: as_equipment += AsnEquipment.get_by_pk(asn=asn) except AsnNotFoundError as e: raise exceptions.AsnDoesNotExistException(str(e)) return as_equipment
def get_as_equipment_by_id(as_equipment_id=None): """Return an ASEquipment by id. Args: as_equipment_id: Id of ASEquipment """ try: as_equipment_list = list() for asn in as_equipment_id: as_equipment = AsnEquipment.get_by_pk(ids=asn) as_equipment_list.append(as_equipment) except AsnNotFoundError as e: raise exceptions.AsnDoesNotExistException(str(e)) return as_equipment_list
def update_asn_equipment(as_): """Update ASNEquipment.""" try: as_obj = AsnEquipment() if not as_.get('id'): raise Exception("The object do not have the id.") asn_equipment = as_obj.get_by_pk(ids=as_.get('id')) asn_equipment.update_v4(as_) except AsnErrorV4 as e: raise ValidationAPIException(str(e)) except ValidationAPIException as e: raise ValidationAPIException(str(e)) except exceptions.AsnDoesNotExistException as e: raise ObjectDoesNotExistException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) return asn_equipment
def update_asn_equipment_by_asn(asn_id, as_): """ Update ASNEquipment. Return new asn_equipments new ids """ try: as_obj = AsnEquipment() asn_equipment = as_obj.get_by_pk(asn=asn_id) for obj in asn_equipment: obj.delete_v4() asn_equipment_obj = create_asn_equipment(as_) except AsnErrorV4 as e: raise ValidationAPIException(str(e)) except ValidationAPIException as e: raise ValidationAPIException(str(e)) except exceptions.AsnDoesNotExistException as e: raise ObjectDoesNotExistException(str(e)) except Exception as e: raise NetworkAPIException(str(e)) return asn_equipment_obj