pull/14345/head
ibuler 2 months ago
parent dac26a7416
commit c2218a5bca

@ -0,0 +1,18 @@
# Generated by Django 4.1.13 on 2024-10-12 03:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("accounts", "0004_alter_changesecretrecord_account_and_more"),
]
operations = [
migrations.AddField(
model_name="account",
name="secret_reset",
field=models.BooleanField(default=True, verbose_name="Secret reset"),
),
]

@ -53,6 +53,7 @@ class Account(AbsConnectivity, LabeledMixin, BaseAccount):
on_delete=models.SET_NULL, verbose_name=_("Su from")
)
version = models.IntegerField(default=0, verbose_name=_('Version'))
secret_reset = models.BooleanField(default=True, verbose_name=_('Secret reset'))
history = AccountHistoricalRecords(included_fields=['id', '_secret', 'secret_type', 'version'])
source = models.CharField(max_length=30, default=Source.LOCAL, verbose_name=_('Source'))
source_id = models.CharField(max_length=128, null=True, blank=True, verbose_name=_('Source ID'))

@ -202,7 +202,7 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
class AccountAssetSerializer(serializers.ModelSerializer):
platform = ObjectRelatedField(read_only=True)
platform = ObjectRelatedField(read_only=True, attrs=('id', 'name', 'type'))
category = LabeledChoiceField(choices=Category.choices, read_only=True, label=_('Category'))
type = LabeledChoiceField(choices=AllTypes.choices(), read_only=True, label=_('Type'))
@ -238,6 +238,7 @@ class AccountSerializer(AccountCreateUpdateSerializerMixin, BaseAccountSerialize
fields = BaseAccountSerializer.Meta.fields + [
'su_from', 'asset', 'version',
'source', 'source_id', 'connectivity',
'secret_reset',
] + AccountCreateUpdateSerializerMixin.Meta.fields
read_only_fields = BaseAccountSerializer.Meta.read_only_fields + [
'connectivity'

@ -4,6 +4,11 @@ from .base import BaseType
class DeviceTypes(BaseType):
CISCO = 'cisco', _("Cisco")
HUAWEI = 'huawei', _("Huawei")
H3C = 'h3c', _("H3C")
JUNIPER = 'juniper', _("Juniper")
TP_LINK = 'tp_link', _("TP-Link")
GENERAL = 'general', _("General")
SWITCH = 'switch', _("Switch")
ROUTER = 'router', _("Router")

@ -8,6 +8,7 @@ GATEWAY_NAME = 'Gateway'
class HostTypes(BaseType):
LINUX = 'linux', 'Linux'
WINDOWS = 'windows', 'Windows'
MacOS = 'macos', 'macOS'
UNIX = 'unix', 'Unix'
OTHER_HOST = 'other', _("Other")

@ -14,7 +14,7 @@ from common.serializers import (
CommonModelSerializer, MethodSerializer, ResourceLabelsMixin
)
from common.serializers.common import DictSerializer
from common.serializers.fields import LabeledChoiceField
from common.serializers.fields import LabeledChoiceField, ObjectRelatedField
from labels.models import Label
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from ...const import Category, AllTypes
@ -147,6 +147,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer, ResourceLabelsMixin, Writa
protocols = AssetProtocolsSerializer(many=True, required=False, label=_('Protocols'), default=())
accounts = AssetAccountSerializer(many=True, required=False, allow_null=True, write_only=True, label=_('Accounts'))
nodes_display = NodeDisplaySerializer(read_only=False, required=False, label=_("Node path"))
platform = ObjectRelatedField(queryset=Platform.objects, required=True, label=_('Platform'), attrs=('id', 'name', 'type'))
_accounts = None
class Meta:

Loading…
Cancel
Save