mirror of
https://github.com/veops/cmdb.git
synced 2025-09-18 02:26:53 +08:00
feat(api): Add API to view raw data of auto-discovered instances
This commit is contained in:
@@ -308,6 +308,8 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
if new_last_update_at < __last_update_at:
|
||||
new_last_update_at = __last_update_at
|
||||
|
||||
new_last_update_at = new_last_update_at or ad_rules_updated_at
|
||||
|
||||
write_ad_rule_sync_history.apply_async(args=(result, oneagent_id, oneagent_name, datetime.datetime.now()),
|
||||
queue=CMDB_QUEUE)
|
||||
if not last_update_at or new_last_update_at > last_update_at:
|
||||
@@ -693,6 +695,11 @@ class AutoDiscoveryCICRUD(DBMixin):
|
||||
stdout="delete resource: {}".format(unique_value))
|
||||
# TODO: delete ci
|
||||
|
||||
@classmethod
|
||||
def get_instance_by_id(cls, adc_id):
|
||||
adc = cls.cls.get_by_id(adc_id) or abort(404, ErrFormat.adc_not_found)
|
||||
return adc.instance
|
||||
|
||||
@classmethod
|
||||
def accept(cls, adc, adc_id=None, nickname=None):
|
||||
if adc_id is not None:
|
||||
|
@@ -205,12 +205,14 @@ class AutoDiscoveryCITypeRelationView(APIView):
|
||||
class AutoDiscoveryCIView(APIView):
|
||||
url_prefix = ("/adc", "/adc/<int:adc_id>", "/adc/ci_types/<int:type_id>/attributes", "/adc/ci_types")
|
||||
|
||||
def get(self, type_id=None):
|
||||
def get(self, type_id=None, adc_id=None):
|
||||
if "attributes" in request.url:
|
||||
return self.jsonify(AutoDiscoveryCICRUD.get_attributes_by_type_id(type_id))
|
||||
elif "ci_types" in request.url:
|
||||
if "ci_types" in request.url:
|
||||
need_other = request.values.get("need_other")
|
||||
return self.jsonify(AutoDiscoveryCICRUD.get_ci_types(need_other))
|
||||
if adc_id is not None:
|
||||
return self.jsonify(AutoDiscoveryCICRUD.get_instance_by_id(adc_id))
|
||||
|
||||
page = get_page(request.values.pop('page', 1))
|
||||
page_size = get_page_size(request.values.pop('page_size', None))
|
||||
|
Reference in New Issue
Block a user