mirror of https://github.com/jumpserver/jumpserver
perf: asset add automation_enabled_info (#9154)
Co-authored-by: feng <1304903146@qq.com>pull/9155/head
parent
669ccb502f
commit
8a7ecda4f6
|
@ -53,7 +53,7 @@ class AssetAccountSerializer(AccountSerializer):
|
||||||
'version', 'secret_type',
|
'version', 'secret_type',
|
||||||
]
|
]
|
||||||
fields_write_only = [
|
fields_write_only = [
|
||||||
'secret', 'push_now'
|
'secret', 'push_now'
|
||||||
]
|
]
|
||||||
fields = fields_mini + fields_write_only
|
fields = fields_mini + fields_write_only
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ class AssetSerializer(OrgResourceSerializerMixin, WritableNestedModelSerializer)
|
||||||
labels = AssetLabelSerializer(many=True, required=False, label=_('Labels'))
|
labels = AssetLabelSerializer(many=True, required=False, label=_('Labels'))
|
||||||
protocols = AssetProtocolsSerializer(many=True, required=False, label=_('Protocols'))
|
protocols = AssetProtocolsSerializer(many=True, required=False, label=_('Protocols'))
|
||||||
accounts = AssetAccountSerializer(many=True, required=False, label=_('Accounts'))
|
accounts = AssetAccountSerializer(many=True, required=False, label=_('Accounts'))
|
||||||
|
automation_enabled_info = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Asset
|
model = Asset
|
||||||
|
@ -78,8 +79,8 @@ class AssetSerializer(OrgResourceSerializerMixin, WritableNestedModelSerializer)
|
||||||
]
|
]
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'category', 'type', 'specific', 'info',
|
'category', 'type', 'specific', 'info',
|
||||||
'connectivity', 'date_verified',
|
'connectivity', 'date_verified', 'created_by',
|
||||||
'created_by', 'date_created',
|
'date_created', 'automation_enabled_info'
|
||||||
]
|
]
|
||||||
fields = fields_small + fields_fk + fields_m2m + read_only_fields
|
fields = fields_small + fields_fk + fields_m2m + read_only_fields
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
|
@ -93,6 +94,19 @@ class AssetSerializer(OrgResourceSerializerMixin, WritableNestedModelSerializer)
|
||||||
names.remove('specific')
|
names.remove('specific')
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_automation_enabled_info(obj):
|
||||||
|
automation = obj.platform.automation
|
||||||
|
return {
|
||||||
|
'ping_enabled': automation.ping_enabled,
|
||||||
|
'ansible_enabled': automation.ansible_enabled,
|
||||||
|
'gather_facts_enabled': automation.gather_facts_enabled,
|
||||||
|
'push_account_enabled': automation.push_account_enabled,
|
||||||
|
'change_secret_enabled': automation.change_secret_enabled,
|
||||||
|
'verify_account_enabled': automation.verify_account_enabled,
|
||||||
|
'gather_accounts_enabled': automation.gather_accounts_enabled,
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_eager_loading(cls, queryset):
|
def setup_eager_loading(cls, queryset):
|
||||||
""" Perform necessary eager loading of data. """
|
""" Perform necessary eager loading of data. """
|
||||||
|
|
|
@ -38,6 +38,7 @@ class ProtocolSettingSerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class PlatformAutomationSerializer(serializers.ModelSerializer):
|
class PlatformAutomationSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PlatformAutomation
|
model = PlatformAutomation
|
||||||
fields = [
|
fields = [
|
||||||
|
|
Loading…
Reference in New Issue