diff --git a/backend/alembic/versions/2024_07_09_2121-aedfbb298f93_init_db.py b/backend/alembic/versions/2024_07_09_2121-aedfbb298f93_init_db.py deleted file mode 100644 index e49302e..0000000 --- a/backend/alembic/versions/2024_07_09_2121-aedfbb298f93_init_db.py +++ /dev/null @@ -1,1373 +0,0 @@ -"""init db - -Revision ID: aedfbb298f93 -Revises: -Create Date: 2024-07-09 21:21:30.777580 - -""" - -from collections.abc import Sequence - -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -import src -from alembic import op - -# revision identifiers, used by Alembic. -revision: str = "aedfbb298f93" -down_revision: str | None = None -branch_labels: str | Sequence[str] | None = None -depends_on: str | Sequence[str] | None = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.execute("CREATE EXTENSION IF NOT EXISTS pgcrypto;") - op.execute("CREATE EXTENSION IF NOT EXISTS hstore;") - op.create_table( - "alert", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("slug", sa.String(), nullable=False), - sa.Column("description", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("possible_impacts", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("remediation_suggestion", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("references", sa.String(), nullable=True), - sa.Column("severity", sa.String(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - sa.UniqueConstraint("slug"), - ) - op.create_index(op.f("ix_alert_created_at"), "alert", ["created_at"], unique=False) - op.create_index(op.f("ix_alert_id"), "alert", ["id"], unique=False) - op.create_table( - "asn", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("asn", sa.Integer(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("asn"), - ) - op.create_index(op.f("ix_asn_created_at"), "asn", ["created_at"], unique=False) - op.create_index(op.f("ix_asn_id"), "asn", ["id"], unique=False) - op.create_table( - "block", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("block", src.core.database.types.ipaddress.PgCIDR(), nullable=False), - sa.Column("size", sa.Integer(), nullable=False), - sa.Column("range", sa.String(), nullable=False), - sa.Column("is_private", sa.Boolean(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("block"), - ) - op.create_index(op.f("ix_block_created_at"), "block", ["created_at"], unique=False) - op.create_index(op.f("ix_block_id"), "block", ["id"], unique=False) - op.create_table( - "circuit_type", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("slug", sa.String(), nullable=False), - sa.Column("connection_type", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("slug"), - ) - op.create_index(op.f("ix_circuit_type_created_at"), "circuit_type", ["created_at"], unique=False) - op.create_index(op.f("ix_circuit_type_id"), "circuit_type", ["id"], unique=False) - op.create_table( - "correlation", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("order", sa.Integer(), nullable=False), - sa.Column("source_match", postgresql.JSON(astext_type=sa.Text()), nullable=False), - sa.Column("target_match", postgresql.JSON(astext_type=sa.Text()), nullable=False), - sa.Column("equal_value", postgresql.JSON(astext_type=sa.Text()), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_correlation_created_at"), "correlation", ["created_at"], unique=False) - op.create_index(op.f("ix_correlation_id"), "correlation", ["id"], unique=False) - op.create_table( - "device_role", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("slug", sa.String(), nullable=False), - sa.Column("priority", sa.Integer(), nullable=False), - sa.Column("abbreviation", sa.String(), nullable=True), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("slug"), - ) - op.create_index(op.f("ix_device_role_created_at"), "device_role", ["created_at"], unique=False) - op.create_index(op.f("ix_device_role_id"), "device_role", ["id"], unique=False) - op.create_table( - "inhibitor", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("started_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("ended_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("rules", postgresql.JSON(astext_type=sa.Text()), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_inhibitor_created_at"), "inhibitor", ["created_at"], unique=False) - op.create_index(op.f("ix_inhibitor_id"), "inhibitor", ["id"], unique=False) - op.create_table( - "ip_role", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("slug", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("slug"), - ) - op.create_index(op.f("ix_ip_role_created_at"), "ip_role", ["created_at"], unique=False) - op.create_index(op.f("ix_ip_role_id"), "ip_role", ["id"], unique=False) - op.create_table( - "isp", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("portal", sa.String(), nullable=True), - sa.Column("noc_contact", postgresql.ARRAY(sa.String()), nullable=True), - sa.Column("admin_contact", postgresql.ARRAY(sa.String()), nullable=True), - sa.Column("comments", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_isp_created_at"), "isp", ["created_at"], unique=False) - op.create_index(op.f("ix_isp_id"), "isp", ["id"], unique=False) - op.create_table( - "manufacturer", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", postgresql.HSTORE(text_type=sa.Text()), nullable=False), - sa.Column("slug", sa.String(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("slug"), - ) - op.create_index(op.f("ix_manufacturer_created_at"), "manufacturer", ["created_at"], unique=False) - op.create_index(op.f("ix_manufacturer_id"), "manufacturer", ["id"], unique=False) - op.create_table( - "menu", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False, comment="the unique name of route"), - sa.Column("hidden", sa.Boolean(), server_default=sa.text("false"), nullable=False), - sa.Column("redirect", sa.String(), nullable=False, comment="redirect url for the route"), - sa.Column( - "hideChildrenInMenu", - sa.Boolean(), - server_default=sa.text("false"), - nullable=False, - comment="hide children in menu force or not", - ), - sa.Column("order", sa.Integer(), nullable=False), - sa.Column("title", sa.String(), nullable=False, comment="the title of the route, 面包屑"), - sa.Column("icon", sa.String(), nullable=True), - sa.Column( - "keepAlive", - sa.Boolean(), - server_default=sa.text("false"), - nullable=False, - comment="cache route, 开启multi-tab时为true", - ), - sa.Column( - "hiddenHeaderContent", - sa.Boolean(), - server_default=sa.text("false"), - nullable=False, - comment="隐藏pageheader页面带的面包屑和标题栏", - ), - sa.Column("permission", postgresql.ARRAY(sa.Integer(), dimensions=1), nullable=True), - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["menu.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - ) - op.create_table( - "permission", - sa.Column("id", src.core.database.types.guid.GUID(length=16), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("url", sa.String(), nullable=False), - sa.Column("method", sa.String(), nullable=False), - sa.Column("tag", sa.String(), nullable=False), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_permission_id"), "permission", ["id"], unique=False) - op.create_table( - "platform", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("slug", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("netmiko_driver", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - sa.UniqueConstraint("slug"), - ) - op.create_index(op.f("ix_platform_created_at"), "platform", ["created_at"], unique=False) - op.create_index(op.f("ix_platform_id"), "platform", ["id"], unique=False) - op.create_table( - "role", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("slug", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_role_created_at"), "role", ["created_at"], unique=False) - op.create_index(op.f("ix_role_id"), "role", ["id"], unique=False) - op.create_table( - "route_target", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - ) - op.create_index(op.f("ix_route_target_created_at"), "route_target", ["created_at"], unique=False) - op.create_index(op.f("ix_route_target_id"), "route_target", ["id"], unique=False) - op.create_table( - "site_group", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - ) - op.create_index(op.f("ix_site_group_created_at"), "site_group", ["created_at"], unique=False) - op.create_table( - "subscription", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("enable", sa.Boolean(), server_default=sa.text("true"), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("enable_time_range", sa.Boolean(), server_default=sa.text("false"), nullable=False), - sa.Column("time_range", postgresql.JSON(astext_type=sa.Text()), nullable=True), - sa.Column("group_delay", sa.Integer(), nullable=False), - sa.Column("send_repeat", sa.Boolean(), server_default=sa.text("false"), nullable=False), - sa.Column("repeat_interval", sa.Integer(), nullable=False), - sa.Column("max_repeat", sa.Integer(), nullable=False), - sa.Column("send_resolved", sa.Boolean(), server_default=sa.text("false"), nullable=False), - sa.Column("channel_type", sa.String(), nullable=False), - sa.Column("channel_config", postgresql.JSON(astext_type=sa.Text()), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_subscription_created_at"), "subscription", ["created_at"], unique=False) - op.create_index(op.f("ix_subscription_id"), "subscription", ["id"], unique=False) - op.create_table( - "template", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("template_id", sa.Integer(), nullable=False), - sa.Column("discovery_ospf_id", sa.Integer(), nullable=True), - sa.Column("discovery_bgp_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_template_created_at"), "template", ["created_at"], unique=False) - op.create_index(op.f("ix_template_id"), "template", ["id"], unique=False) - op.create_table( - "vrf", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("rd", sa.String(), nullable=False), - sa.Column( - "enforce_unique", - sa.Boolean(), - server_default=sa.text("true"), - nullable=False, - comment="Enforce unique space, prevent duplicate IP/prefix", - ), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - sa.UniqueConstraint("rd"), - ) - op.create_index(op.f("ix_vrf_created_at"), "vrf", ["created_at"], unique=False) - op.create_index(op.f("ix_vrf_id"), "vrf", ["id"], unique=False) - op.create_table( - "device_type", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("snmp_sysobjectid", sa.String(), nullable=False), - sa.Column("u_height", sa.Float(), server_default="1.0", nullable=False), - sa.Column("front_image", sa.String(), nullable=True), - sa.Column("rear_image", sa.String(), nullable=True), - sa.Column("manufacturer_id", sa.Integer(), nullable=False), - sa.Column("platform_id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["manufacturer_id"], ["manufacturer.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["platform_id"], ["platform.id"], ondelete="RESTRICT"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("manufacturer_id", "name"), - sa.UniqueConstraint("name"), - ) - op.create_index(op.f("ix_device_type_created_at"), "device_type", ["created_at"], unique=False) - op.create_index(op.f("ix_device_type_id"), "device_type", ["id"], unique=False) - op.create_table( - "group", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("role_id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.ForeignKeyConstraint(["role_id"], ["role.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_group_created_at"), "group", ["created_at"], unique=False) - op.create_index(op.f("ix_group_id"), "group", ["id"], unique=False) - op.create_table( - "ip_range", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("start_address", src.core.database.types.ipaddress.PgIpInterface(), nullable=False), - sa.Column("end_address", src.core.database.types.ipaddress.PgIpInterface(), nullable=False), - sa.Column("status", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("vrf_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["vrf_id"], ["vrf.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_ip_range_created_at"), "ip_range", ["created_at"], unique=False) - op.create_index(op.f("ix_ip_range_id"), "ip_range", ["id"], unique=False) - op.create_table( - "isp_asn", - sa.Column("isp_id", sa.Integer(), nullable=False), - sa.Column("asn_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["asn_id"], ["asn.id"]), - sa.ForeignKeyConstraint(["isp_id"], ["isp.id"]), - sa.PrimaryKeyConstraint("isp_id", "asn_id"), - ) - op.create_table( - "jinja_template", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("template", sa.String(), nullable=False), - sa.Column("platform_id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["platform_id"], ["platform.id"], ondelete="RESTRICT"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_jinja_template_created_at"), "jinja_template", ["created_at"], unique=False) - op.create_index(op.f("ix_jinja_template_id"), "jinja_template", ["id"], unique=False) - op.create_table( - "role_menu", - sa.Column("role_id", sa.Integer(), nullable=False), - sa.Column("menu_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["menu_id"], ["menu.id"]), - sa.ForeignKeyConstraint(["role_id"], ["role.id"]), - sa.PrimaryKeyConstraint("role_id", "menu_id"), - ) - op.create_table( - "role_permission", - sa.Column("role_id", sa.Integer(), nullable=False), - sa.Column("permission_id", src.core.database.types.guid.GUID(length=16), nullable=False), - sa.ForeignKeyConstraint(["permission_id"], ["permission.id"]), - sa.ForeignKeyConstraint(["role_id"], ["role.id"]), - sa.PrimaryKeyConstraint("role_id", "permission_id"), - ) - op.create_table( - "textfsm_template", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("template", sa.String(), nullable=False), - sa.Column("platform_id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["platform_id"], ["platform.id"], ondelete="RESTRICT"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_textfsm_template_created_at"), "textfsm_template", ["created_at"], unique=False) - op.create_index(op.f("ix_textfsm_template_id"), "textfsm_template", ["id"], unique=False) - op.create_table( - "vrf_route_target", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("vrf_id", sa.Integer(), nullable=False), - sa.Column("route_target_id", sa.Integer(), nullable=False), - sa.Column("target", sa.String(), nullable=False), - sa.ForeignKeyConstraint(["route_target_id"], ["route_target.id"]), - sa.ForeignKeyConstraint(["vrf_id"], ["vrf.id"]), - sa.PrimaryKeyConstraint("id", "vrf_id", "route_target_id"), - ) - op.create_index(op.f("ix_vrf_route_target_id"), "vrf_route_target", ["id"], unique=False) - op.create_table( - "user", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("email", sa.String(), nullable=True), - sa.Column("phone", sa.String(), nullable=True), - sa.Column("password", sa.String(), nullable=False), - sa.Column("avatar", sa.String(), nullable=True), - sa.Column("last_login", sa.DateTime(timezone=True), nullable=True), - sa.Column("is_active", sa.Boolean(), server_default=sa.text("true"), nullable=False), - sa.Column("group_id", sa.Integer(), nullable=False), - sa.Column("role_id", sa.Integer(), nullable=False), - sa.Column("auth_info", postgresql.JSON(astext_type=sa.Text()), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.ForeignKeyConstraint(["group_id"], ["group.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["role_id"], ["role.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("email"), - sa.UniqueConstraint("phone"), - ) - op.create_index(op.f("ix_user_created_at"), "user", ["created_at"], unique=False) - op.create_index(op.f("ix_user_id"), "user", ["id"], unique=False) - op.create_table( - "alert_user", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("user_id", sa.Integer(), nullable=False), - sa.Column("online_date", postgresql.JSON(astext_type=sa.Text()), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["user_id"], ["user.id"]), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_alert_user_created_at"), "alert_user", ["created_at"], unique=False) - op.create_index(op.f("ix_alert_user_id"), "alert_user", ["id"], unique=False) - op.create_table( - "asn_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["asn.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_asn_audit_log_id"), "asn_audit_log", ["id"], unique=False) - op.create_table( - "block_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["block.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_block_audit_log_id"), "block_audit_log", ["id"], unique=False) - op.create_table( - "ip_range_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["ip_range.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_ip_range_audit_log_id"), "ip_range_audit_log", ["id"], unique=False) - op.create_table( - "isp_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["isp.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_isp_audit_log_id"), "isp_audit_log", ["id"], unique=False) - op.create_table( - "route_target_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["route_target.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_route_target_audit_log_id"), "route_target_audit_log", ["id"], unique=False) - op.create_table( - "site", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("site_code", sa.String(), nullable=False), - sa.Column("status", sa.String(), nullable=False), - sa.Column("facility_code", sa.String(), nullable=True), - sa.Column("time_zone", sa.Integer(), nullable=True), - sa.Column("country", sa.String(), nullable=True), - sa.Column("city", sa.String(), nullable=True), - sa.Column("address", sa.String(), nullable=False), - sa.Column("latitude", sa.Float(), nullable=False), - sa.Column("longitude", sa.Float(), nullable=False), - sa.Column("classification", sa.String(), nullable=True), - sa.Column("comments", sa.String(), nullable=True), - sa.Column("site_group_id", sa.Integer(), nullable=True), - sa.Column("network_contact_id", sa.Integer(), nullable=True), - sa.Column("it_contact_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["it_contact_id"], ["user.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["network_contact_id"], ["user.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["site_group_id"], ["site_group.id"], ondelete="RESTRICT"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - ) - op.create_index(op.f("ix_site_created_at"), "site", ["created_at"], unique=False) - op.create_index(op.f("ix_site_id"), "site", ["id"], unique=False) - op.create_index(op.f("ix_site_site_code"), "site", ["site_code"], unique=True) - op.create_table( - "vrf_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["vrf.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_vrf_audit_log_id"), "vrf_audit_log", ["id"], unique=False) - op.create_table( - "event_group", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("group_key", sa.String(), nullable=True), - sa.Column("content_hash", sa.String(), nullable=True), - sa.Column("description", sa.String(), nullable=True), - sa.Column("status", sa.String(), nullable=False), - sa.Column("started_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("resolved_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.Column("acknowledged_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.Column("acknowledged_by", sa.Integer(), nullable=True), - sa.Column("closed_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.Column("closed_by", sa.Integer(), nullable=True), - sa.Column("severity", sa.String(), nullable=False), - sa.ForeignKeyConstraint(["acknowledged_by"], ["alert_user.id"]), - sa.ForeignKeyConstraint(["closed_by"], ["alert_user.id"]), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_event_group_id"), "event_group", ["id"], unique=False) - op.create_table( - "event_operation", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("operation_type", sa.String(), nullable=False), - sa.Column("comment", sa.String(), nullable=True), - sa.Column("inhibitor_id", sa.Integer(), nullable=True), - sa.Column("assignee_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["assignee_id"], ["alert_user.id"]), - sa.ForeignKeyConstraint(["created_by"], ["user.id"]), - sa.ForeignKeyConstraint(["inhibitor_id"], ["inhibitor.id"]), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_event_operation_id"), "event_operation", ["id"], unique=False) - op.create_table( - "location", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("location_type", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("status", sa.String(), nullable=False), - sa.Column("site_id", sa.Integer(), nullable=False), - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["location.id"]), - sa.ForeignKeyConstraint(["site_id"], ["site.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("site_id", "name"), - ) - op.create_index(op.f("ix_location_created_at"), "location", ["created_at"], unique=False) - op.create_table( - "site_asn", - sa.Column("site_id", sa.Integer(), nullable=False), - sa.Column("asn_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["asn_id"], ["asn.id"]), - sa.ForeignKeyConstraint(["site_id"], ["site.id"]), - sa.PrimaryKeyConstraint("site_id", "asn_id"), - ) - op.create_table( - "site_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["site.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_site_audit_log_id"), "site_audit_log", ["id"], unique=False) - op.create_table( - "vlan", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("vid", sa.Integer(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("status", sa.String(), nullable=False), - sa.Column("ip_address", sa.String(), nullable=False), - sa.Column("associated_interfaces", postgresql.ARRAY(sa.String(), dimensions=1), nullable=True), - sa.Column("site_id", sa.Integer(), nullable=False), - sa.Column("role_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["role_id"], ["ip_role.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["site_id"], ["site.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("site_id", "vid"), - ) - op.create_index(op.f("ix_vlan_created_at"), "vlan", ["created_at"], unique=False) - op.create_index(op.f("ix_vlan_id"), "vlan", ["id"], unique=False) - op.create_table( - "device", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("management_ip", src.core.database.types.ipaddress.PgIpAddress(), nullable=False), - sa.Column("oob_ip", src.core.database.types.ipaddress.PgIpAddress(), nullable=True), - sa.Column("status", sa.String(), nullable=False), - sa.Column("software_version", sa.String(), nullable=True), - sa.Column("software_patch", sa.String(), nullable=True), - sa.Column("comments", sa.String(), nullable=True), - sa.Column("serial_number", sa.String(), nullable=True), - sa.Column("asset_tag", sa.String(), nullable=True), - sa.Column("device_type_id", sa.Integer(), nullable=False), - sa.Column("device_role_id", sa.Integer(), nullable=False), - sa.Column("platform_id", sa.Integer(), nullable=False, comment="redundant platform.id for query performance"), - sa.Column( - "manufacturer_id", sa.Integer(), nullable=False, comment="redundant manufacturer.id for query performance" - ), - sa.Column("site_id", sa.Integer(), nullable=False), - sa.Column("location_id", sa.Integer(), nullable=True), - sa.Column("associated_wac_ip", src.core.database.types.ipaddress.PgIpAddress(), nullable=True), - sa.Column("ap_group", sa.String(), nullable=True), - sa.Column("ap_mode", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["device_role_id"], ["device_role.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["device_type_id"], ["device_type.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["location_id"], ["location.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["manufacturer_id"], ["manufacturer.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["platform_id"], ["platform.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["site_id"], ["site.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("serial_number"), - ) - op.create_index(op.f("ix_device_created_at"), "device", ["created_at"], unique=False) - op.create_index(op.f("ix_device_id"), "device", ["id"], unique=False) - op.create_index(op.f("ix_device_management_ip"), "device", ["management_ip"], unique=False) - op.create_index(op.f("ix_device_name"), "device", ["name"], unique=False) - op.create_table( - "event_operation_event_group", - sa.Column("event_group_id", sa.Integer(), nullable=False), - sa.Column("operation_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["event_group_id"], ["event_group.id"]), - sa.ForeignKeyConstraint(["operation_id"], ["event_operation.id"]), - sa.PrimaryKeyConstraint("event_group_id", "operation_id"), - ) - op.create_table( - "location_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["location.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_location_audit_log_id"), "location_audit_log", ["id"], unique=False) - op.create_table( - "prefix", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("prefix", src.core.database.types.ipaddress.PgCIDR(), nullable=False), - sa.Column("status", sa.String(), nullable=False), - sa.Column("is_dhcp_pool", sa.Boolean(), server_default=sa.text("true"), nullable=False), - sa.Column("is_full", sa.Boolean(), server_default=sa.text("false"), nullable=False), - sa.Column("vlan_id", sa.Integer(), nullable=True), - sa.Column("site_id", sa.Integer(), nullable=True), - sa.Column("role_id", sa.Integer(), nullable=True), - sa.Column("vrf_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["role_id"], ["ip_role.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["site_id"], ["site.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["vlan_id"], ["vlan.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["vrf_id"], ["vrf.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_prefix_created_at"), "prefix", ["created_at"], unique=False) - op.create_index(op.f("ix_prefix_id"), "prefix", ["id"], unique=False) - op.create_index(op.f("ix_prefix_prefix"), "prefix", ["prefix"], unique=True) - op.create_table( - "vlan_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["vlan.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_vlan_audit_log_id"), "vlan_audit_log", ["id"], unique=False) - op.create_table( - "auth_credential", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("cli", src.core.database.types.encrypted_string.EncryptedString(), nullable=True), - sa.Column("snmpv2_community", src.core.database.types.encrypted_string.EncryptedString(), nullable=True), - sa.Column("snmpv3", src.core.database.types.encrypted_string.EncryptedString(), nullable=True), - sa.Column("site_group_id", sa.Integer(), nullable=True), - sa.Column("site_id", sa.Integer(), nullable=True), - sa.Column("device_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["site_group_id"], ["site_group.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["site_id"], ["site.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_auth_credential_created_at"), "auth_credential", ["created_at"], unique=False) - op.create_index(op.f("ix_auth_credential_id"), "auth_credential", ["id"], unique=False) - op.create_table( - "baseline_config", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("aaa_server", postgresql.ARRAY(sa.String(), dimensions=1), nullable=True), - sa.Column("dhcp_server", postgresql.ARRAY(sa.String(), dimensions=1), nullable=True), - sa.Column("dns_server", postgresql.ARRAY(sa.String(), dimensions=1), nullable=True), - sa.Column("ntp_server", postgresql.ARRAY(sa.String(), dimensions=1), nullable=True), - sa.Column("syslog_server", postgresql.ARRAY(sa.String(), dimensions=1), nullable=True), - sa.Column("netflow_server", postgresql.ARRAY(sa.String(), dimensions=1), nullable=True), - sa.Column("site_group_id", sa.Integer(), nullable=True), - sa.Column("site_id", sa.Integer(), nullable=True), - sa.Column("device_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["site_group_id"], ["site_group.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["site_id"], ["site.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_baseline_config_created_at"), "baseline_config", ["created_at"], unique=False) - op.create_index(op.f("ix_baseline_config_id"), "baseline_config", ["id"], unique=False) - op.create_table( - "device_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["device.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_device_audit_log_id"), "device_audit_log", ["id"], unique=False) - op.create_table( - "device_config", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("configuration", sa.TEXT(), nullable=False), - sa.Column("total_lines", sa.Integer(), server_default="0", nullable=False), - sa.Column("lines_added", sa.Integer(), server_default="0", nullable=False), - sa.Column("lines_deleted", sa.Integer(), server_default="0", nullable=False), - sa.Column("lines_updated", sa.Integer(), server_default="0", nullable=False), - sa.Column("md5_checksum", sa.String(), nullable=True), - sa.Column("created_by", sa.String(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("change_event", postgresql.JSON(astext_type=sa.Text()), nullable=True), - sa.Column("device_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_device_config_id"), "device_config", ["id"], unique=False) - op.create_table( - "equipment", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("eq_type", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("device_type", sa.String(), nullable=True), - sa.Column("serial_number", sa.String(), nullable=True), - sa.Column("device_id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_equipment_created_at"), "equipment", ["created_at"], unique=False) - op.create_index(op.f("ix_equipment_id"), "equipment", ["id"], unique=False) - op.create_table( - "interface", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("if_index", sa.Integer(), nullable=True), - sa.Column("speed", sa.Integer(), nullable=True), - sa.Column("mode", sa.String(), nullable=False), - sa.Column("interface_type", sa.String(), nullable=True), - sa.Column("mtu", sa.Integer(), nullable=True), - sa.Column("admin_status", sa.String(), nullable=False), - sa.Column("device_id", sa.Integer(), nullable=False), - sa.Column("vlan_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["vlan_id"], ["vlan.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("device_id", "name"), - ) - op.create_index(op.f("ix_interface_created_at"), "interface", ["created_at"], unique=False) - op.create_table( - "module", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("description", sa.String(), nullable=True), - sa.Column("serial_number", sa.String(), nullable=True), - sa.Column("part_number", sa.String(), nullable=True), - sa.Column("hardware_version", sa.String(), nullable=True), - sa.Column("physical_index", sa.Integer(), nullable=True), - sa.Column("replaceable", sa.Boolean(), nullable=True), - sa.Column("device_id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("serial_number"), - ) - op.create_index(op.f("ix_module_created_at"), "module", ["created_at"], unique=False) - op.create_index(op.f("ix_module_id"), "module", ["id"], unique=False) - op.create_table( - "monitor", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("device_id", sa.Integer(), nullable=False), - sa.Column("template_id", sa.Integer(), nullable=False), - sa.Column("enable_monitor", sa.Boolean(), server_default=sa.text("true"), nullable=False), - sa.Column("enable_ospf", sa.Boolean(), server_default=sa.text("false"), nullable=False), - sa.Column("enable_bgp", sa.Boolean(), server_default=sa.text("false"), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["template_id"], ["template.id"], ondelete="RESTRICT"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_monitor_created_at"), "monitor", ["created_at"], unique=False) - op.create_index(op.f("ix_monitor_id"), "monitor", ["id"], unique=False) - op.create_table( - "prefix_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["prefix.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_prefix_audit_log_id"), "prefix_audit_log", ["id"], unique=False) - op.create_table( - "stack", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("role", sa.String(), nullable=False), - sa.Column("mac_address", sa.String(), nullable=False), - sa.Column("priority", sa.Integer(), nullable=True), - sa.Column("device_type", sa.String(), nullable=False), - sa.Column("device_id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_stack_created_at"), "stack", ["created_at"], unique=False) - op.create_index(op.f("ix_stack_id"), "stack", ["id"], unique=False) - op.create_table( - "auth_credential_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["auth_credential.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_auth_credential_audit_log_id"), "auth_credential_audit_log", ["id"], unique=False) - op.create_table( - "baseline_config_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["baseline_config.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_baseline_config_audit_log_id"), "baseline_config_audit_log", ["id"], unique=False) - op.create_table( - "circuit", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("cid", sa.String(), nullable=True), - sa.Column("status", sa.String(), nullable=False), - sa.Column("install_date", sa.Date(), nullable=True), - sa.Column("purchase_term", sa.String(), nullable=True), - sa.Column("bandwidth", sa.Integer(), nullable=False, comment="Mbps"), - sa.Column("comments", sa.String(), nullable=True), - sa.Column( - "manufacturer_available_ip", - postgresql.ARRAY(src.core.database.types.ipaddress.PgIpInterface()), - nullable=True, - ), - sa.Column( - "manufacturer_available_gateway", - postgresql.ARRAY(src.core.database.types.ipaddress.PgIpAddress()), - nullable=True, - ), - sa.Column("isp_id", sa.Integer(), nullable=False), - sa.Column("circuit_type_id", sa.Integer(), nullable=False), - sa.Column("site_a_id", sa.Integer(), nullable=False), - sa.Column("device_a_id", sa.Integer(), nullable=False), - sa.Column("interface_a_id", sa.Integer(), nullable=False), - sa.Column("site_z_id", sa.Integer(), nullable=True), - sa.Column("device_z_id", sa.Integer(), nullable=True), - sa.Column("interface_z_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["circuit_type_id"], ["circuit_type.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["device_a_id"], ["device.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["device_z_id"], ["device.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["interface_a_id"], ["interface.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["interface_z_id"], ["interface.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["isp_id"], ["isp.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["site_a_id"], ["site.id"], ondelete="RESTRICT"), - sa.ForeignKeyConstraint(["site_z_id"], ["site.id"], ondelete="RESTRICT"), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("cid"), - sa.UniqueConstraint("name"), - ) - op.create_index(op.f("ix_circuit_created_at"), "circuit", ["created_at"], unique=False) - op.create_index(op.f("ix_circuit_id"), "circuit", ["id"], unique=False) - op.create_table( - "event", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("alert_id", sa.Integer(), nullable=False), - sa.Column("event_group_id", sa.Integer(), nullable=True), - sa.Column("site_id", sa.Integer(), nullable=False), - sa.Column("device_id", sa.Integer(), nullable=False), - sa.Column("device_role_id", sa.Integer(), nullable=False), - sa.Column("platform_id", sa.Integer(), nullable=False), - sa.Column("device_type_id", sa.Integer(), nullable=False), - sa.Column("interface_id", sa.Integer(), nullable=True), - sa.Column("inhibitor_id", sa.Integer(), nullable=True), - sa.Column("status", sa.String(), nullable=False), - sa.Column("started_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("resolved_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.Column("acknowledged_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.Column("acknowledged_by", sa.Integer(), nullable=True), - sa.Column("closed_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.Column("closed_by", sa.Integer(), nullable=True), - sa.Column("severity", sa.String(), nullable=False), - sa.ForeignKeyConstraint(["acknowledged_by"], ["alert_user.id"]), - sa.ForeignKeyConstraint(["alert_id"], ["alert.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["closed_by"], ["alert_user.id"]), - sa.ForeignKeyConstraint(["device_id"], ["device.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["event_group_id"], ["event_group.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["inhibitor_id"], ["inhibitor.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["interface_id"], ["interface.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["site_id"], ["site.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_event_id"), "event", ["id"], unique=False) - op.create_table( - "ip_address", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("address", src.core.database.types.ipaddress.PgIpInterface(), nullable=False), - sa.Column("vrf_id", sa.Integer(), nullable=True), - sa.Column("version", sa.Integer(), nullable=False), - sa.Column("status", sa.String(), nullable=False), - sa.Column("dns_name", sa.String(), nullable=True), - sa.Column("description", sa.String(), nullable=True), - sa.Column("interface_id", sa.Integer(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("created_by_fk", sa.Integer(), nullable=True), - sa.Column("updated_by_fk", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["interface_id"], ["interface.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["vrf_id"], ["vrf.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_ip_address_created_at"), "ip_address", ["created_at"], unique=False) - op.create_index(op.f("ix_ip_address_id"), "ip_address", ["id"], unique=False) - op.create_table( - "lldp_neighbor", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("source_interface_id", sa.Integer(), nullable=False), - sa.Column("source_device_id", sa.Integer(), nullable=False), - sa.Column("target_interface_id", sa.Integer(), nullable=False), - sa.Column("target_device_id", sa.Integer(), nullable=False), - sa.Column("link_status", sa.String(), nullable=True), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("updated_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=True), - sa.ForeignKeyConstraint(["source_device_id"], ["device.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["source_interface_id"], ["interface.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["target_device_id"], ["device.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint(["target_interface_id"], ["interface.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_lldp_neighbor_created_at"), "lldp_neighbor", ["created_at"], unique=False) - op.create_index(op.f("ix_lldp_neighbor_id"), "lldp_neighbor", ["id"], unique=False) - op.create_table( - "circuit_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["circuit.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_circuit_audit_log_id"), "circuit_audit_log", ["id"], unique=False) - op.create_table( - "event_operation_event", - sa.Column("event_id", sa.Integer(), nullable=False), - sa.Column("operation_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["event_id"], ["event.id"]), - sa.ForeignKeyConstraint(["operation_id"], ["event_operation.id"]), - sa.PrimaryKeyConstraint("event_id", "operation_id"), - ) - op.create_table( - "ip_address_audit_log", - sa.Column("parent_id", sa.Integer(), nullable=True), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("created_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("request_id", sa.String(), nullable=False), - sa.Column("action", sa.String(), nullable=False), - sa.Column("diff", sa.JSON(), nullable=True), - sa.Column("user_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(["parent_id"], ["ip_address.id"], ondelete="SET NULL"), - sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="SET NULL"), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_ip_address_audit_log_id"), "ip_address_audit_log", ["id"], unique=False) - op.create_table( - "ip_address_user", - sa.Column("ip_address_id", sa.Integer(), nullable=False), - sa.Column("user_id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["ip_address_id"], ["ip_address.id"]), - sa.ForeignKeyConstraint(["user_id"], ["user.id"]), - sa.PrimaryKeyConstraint("ip_address_id", "user_id"), - ) - op.create_table( - "notification_record", - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("subscription_id", sa.Integer(), nullable=False), - sa.Column("event_id", sa.Integer(), nullable=True), - sa.Column("event_group_id", sa.Integer(), nullable=True), - sa.Column("sent_at", src.core.database.types.datetime.DateTimeTZ(timezone=True), nullable=False), - sa.Column("result_code", sa.String(), nullable=False), - sa.Column("result_message", sa.String(), nullable=True), - sa.ForeignKeyConstraint(["event_group_id"], ["event_group.id"]), - sa.ForeignKeyConstraint(["event_id"], ["event.id"]), - sa.ForeignKeyConstraint(["subscription_id"], ["subscription.id"]), - sa.PrimaryKeyConstraint("id"), - ) - op.create_index(op.f("ix_notification_record_id"), "notification_record", ["id"], unique=False) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f("ix_notification_record_id"), table_name="notification_record") - op.drop_table("notification_record") - op.drop_table("ip_address_user") - op.drop_index(op.f("ix_ip_address_audit_log_id"), table_name="ip_address_audit_log") - op.drop_table("ip_address_audit_log") - op.drop_table("event_operation_event") - op.drop_index(op.f("ix_circuit_audit_log_id"), table_name="circuit_audit_log") - op.drop_table("circuit_audit_log") - op.drop_index(op.f("ix_lldp_neighbor_id"), table_name="lldp_neighbor") - op.drop_index(op.f("ix_lldp_neighbor_created_at"), table_name="lldp_neighbor") - op.drop_table("lldp_neighbor") - op.drop_index(op.f("ix_ip_address_id"), table_name="ip_address") - op.drop_index(op.f("ix_ip_address_created_at"), table_name="ip_address") - op.drop_table("ip_address") - op.drop_index(op.f("ix_event_id"), table_name="event") - op.drop_table("event") - op.drop_index(op.f("ix_circuit_id"), table_name="circuit") - op.drop_index(op.f("ix_circuit_created_at"), table_name="circuit") - op.drop_table("circuit") - op.drop_index(op.f("ix_baseline_config_audit_log_id"), table_name="baseline_config_audit_log") - op.drop_table("baseline_config_audit_log") - op.drop_index(op.f("ix_auth_credential_audit_log_id"), table_name="auth_credential_audit_log") - op.drop_table("auth_credential_audit_log") - op.drop_index(op.f("ix_stack_id"), table_name="stack") - op.drop_index(op.f("ix_stack_created_at"), table_name="stack") - op.drop_table("stack") - op.drop_index(op.f("ix_prefix_audit_log_id"), table_name="prefix_audit_log") - op.drop_table("prefix_audit_log") - op.drop_index(op.f("ix_monitor_id"), table_name="monitor") - op.drop_index(op.f("ix_monitor_created_at"), table_name="monitor") - op.drop_table("monitor") - op.drop_index(op.f("ix_module_id"), table_name="module") - op.drop_index(op.f("ix_module_created_at"), table_name="module") - op.drop_table("module") - op.drop_index(op.f("ix_interface_created_at"), table_name="interface") - op.drop_table("interface") - op.drop_index(op.f("ix_equipment_id"), table_name="equipment") - op.drop_index(op.f("ix_equipment_created_at"), table_name="equipment") - op.drop_table("equipment") - op.drop_index(op.f("ix_device_config_id"), table_name="device_config") - op.drop_table("device_config") - op.drop_index(op.f("ix_device_audit_log_id"), table_name="device_audit_log") - op.drop_table("device_audit_log") - op.drop_index(op.f("ix_baseline_config_id"), table_name="baseline_config") - op.drop_index(op.f("ix_baseline_config_created_at"), table_name="baseline_config") - op.drop_table("baseline_config") - op.drop_index(op.f("ix_auth_credential_id"), table_name="auth_credential") - op.drop_index(op.f("ix_auth_credential_created_at"), table_name="auth_credential") - op.drop_table("auth_credential") - op.drop_index(op.f("ix_vlan_audit_log_id"), table_name="vlan_audit_log") - op.drop_table("vlan_audit_log") - op.drop_index(op.f("ix_prefix_prefix"), table_name="prefix") - op.drop_index(op.f("ix_prefix_id"), table_name="prefix") - op.drop_index(op.f("ix_prefix_created_at"), table_name="prefix") - op.drop_table("prefix") - op.drop_index(op.f("ix_location_audit_log_id"), table_name="location_audit_log") - op.drop_table("location_audit_log") - op.drop_table("event_operation_event_group") - op.drop_index(op.f("ix_device_name"), table_name="device") - op.drop_index(op.f("ix_device_management_ip"), table_name="device") - op.drop_index(op.f("ix_device_id"), table_name="device") - op.drop_index(op.f("ix_device_created_at"), table_name="device") - op.drop_table("device") - op.drop_index(op.f("ix_vlan_id"), table_name="vlan") - op.drop_index(op.f("ix_vlan_created_at"), table_name="vlan") - op.drop_table("vlan") - op.drop_index(op.f("ix_site_audit_log_id"), table_name="site_audit_log") - op.drop_table("site_audit_log") - op.drop_table("site_asn") - op.drop_index(op.f("ix_location_created_at"), table_name="location") - op.drop_table("location") - op.drop_index(op.f("ix_event_operation_id"), table_name="event_operation") - op.drop_table("event_operation") - op.drop_index(op.f("ix_event_group_id"), table_name="event_group") - op.drop_table("event_group") - op.drop_index(op.f("ix_vrf_audit_log_id"), table_name="vrf_audit_log") - op.drop_table("vrf_audit_log") - op.drop_index(op.f("ix_site_site_code"), table_name="site") - op.drop_index(op.f("ix_site_id"), table_name="site") - op.drop_index(op.f("ix_site_created_at"), table_name="site") - op.drop_table("site") - op.drop_index(op.f("ix_route_target_audit_log_id"), table_name="route_target_audit_log") - op.drop_table("route_target_audit_log") - op.drop_index(op.f("ix_isp_audit_log_id"), table_name="isp_audit_log") - op.drop_table("isp_audit_log") - op.drop_index(op.f("ix_ip_range_audit_log_id"), table_name="ip_range_audit_log") - op.drop_table("ip_range_audit_log") - op.drop_index(op.f("ix_block_audit_log_id"), table_name="block_audit_log") - op.drop_table("block_audit_log") - op.drop_index(op.f("ix_asn_audit_log_id"), table_name="asn_audit_log") - op.drop_table("asn_audit_log") - op.drop_index(op.f("ix_alert_user_id"), table_name="alert_user") - op.drop_index(op.f("ix_alert_user_created_at"), table_name="alert_user") - op.drop_table("alert_user") - op.drop_index(op.f("ix_user_id"), table_name="user") - op.drop_index(op.f("ix_user_created_at"), table_name="user") - op.drop_table("user") - op.drop_index(op.f("ix_vrf_route_target_id"), table_name="vrf_route_target") - op.drop_table("vrf_route_target") - op.drop_index(op.f("ix_textfsm_template_id"), table_name="textfsm_template") - op.drop_index(op.f("ix_textfsm_template_created_at"), table_name="textfsm_template") - op.drop_table("textfsm_template") - op.drop_table("role_permission") - op.drop_table("role_menu") - op.drop_index(op.f("ix_jinja_template_id"), table_name="jinja_template") - op.drop_index(op.f("ix_jinja_template_created_at"), table_name="jinja_template") - op.drop_table("jinja_template") - op.drop_table("isp_asn") - op.drop_index(op.f("ix_ip_range_id"), table_name="ip_range") - op.drop_index(op.f("ix_ip_range_created_at"), table_name="ip_range") - op.drop_table("ip_range") - op.drop_index(op.f("ix_group_id"), table_name="group") - op.drop_index(op.f("ix_group_created_at"), table_name="group") - op.drop_table("group") - op.drop_index(op.f("ix_device_type_id"), table_name="device_type") - op.drop_index(op.f("ix_device_type_created_at"), table_name="device_type") - op.drop_table("device_type") - op.drop_index(op.f("ix_vrf_id"), table_name="vrf") - op.drop_index(op.f("ix_vrf_created_at"), table_name="vrf") - op.drop_table("vrf") - op.drop_index(op.f("ix_template_id"), table_name="template") - op.drop_index(op.f("ix_template_created_at"), table_name="template") - op.drop_table("template") - op.drop_index(op.f("ix_subscription_id"), table_name="subscription") - op.drop_index(op.f("ix_subscription_created_at"), table_name="subscription") - op.drop_table("subscription") - op.drop_index(op.f("ix_site_group_created_at"), table_name="site_group") - op.drop_table("site_group") - op.drop_index(op.f("ix_route_target_id"), table_name="route_target") - op.drop_index(op.f("ix_route_target_created_at"), table_name="route_target") - op.drop_table("route_target") - op.drop_index(op.f("ix_role_id"), table_name="role") - op.drop_index(op.f("ix_role_created_at"), table_name="role") - op.drop_table("role") - op.drop_index(op.f("ix_platform_id"), table_name="platform") - op.drop_index(op.f("ix_platform_created_at"), table_name="platform") - op.drop_table("platform") - op.drop_index(op.f("ix_permission_id"), table_name="permission") - op.drop_table("permission") - op.drop_table("menu") - op.drop_index(op.f("ix_manufacturer_id"), table_name="manufacturer") - op.drop_index(op.f("ix_manufacturer_created_at"), table_name="manufacturer") - op.drop_table("manufacturer") - op.drop_index(op.f("ix_isp_id"), table_name="isp") - op.drop_index(op.f("ix_isp_created_at"), table_name="isp") - op.drop_table("isp") - op.drop_index(op.f("ix_ip_role_id"), table_name="ip_role") - op.drop_index(op.f("ix_ip_role_created_at"), table_name="ip_role") - op.drop_table("ip_role") - op.drop_index(op.f("ix_inhibitor_id"), table_name="inhibitor") - op.drop_index(op.f("ix_inhibitor_created_at"), table_name="inhibitor") - op.drop_table("inhibitor") - op.drop_index(op.f("ix_device_role_id"), table_name="device_role") - op.drop_index(op.f("ix_device_role_created_at"), table_name="device_role") - op.drop_table("device_role") - op.drop_index(op.f("ix_correlation_id"), table_name="correlation") - op.drop_index(op.f("ix_correlation_created_at"), table_name="correlation") - op.drop_table("correlation") - op.drop_index(op.f("ix_circuit_type_id"), table_name="circuit_type") - op.drop_index(op.f("ix_circuit_type_created_at"), table_name="circuit_type") - op.drop_table("circuit_type") - op.drop_index(op.f("ix_block_id"), table_name="block") - op.drop_index(op.f("ix_block_created_at"), table_name="block") - op.drop_table("block") - op.drop_index(op.f("ix_asn_id"), table_name="asn") - op.drop_index(op.f("ix_asn_created_at"), table_name="asn") - op.drop_table("asn") - op.drop_index(op.f("ix_alert_id"), table_name="alert") - op.drop_index(op.f("ix_alert_created_at"), table_name="alert") - op.drop_table("alert") - # ### end Alembic commands ### diff --git a/backend/deploy/collections/metadata/circuit_type.json b/backend/deploy/collections/metadata/circuit_type.json index 861934e..6c8502c 100644 --- a/backend/deploy/collections/metadata/circuit_type.json +++ b/backend/deploy/collections/metadata/circuit_type.json @@ -1,35 +1,35 @@ [ { "id": 1, - "name": {"en_US": "Ponit-to-point", "zh_CN": "点对点专线"}, + "name": {"en": "Ponit-to-point", "zh": "点对点专线"}, "slug": "p2p", "description": "Point to point circuit/点对点专线", "connection_type": "LAN" }, { "id": 2, - "name": {"en_US": "Internet", "zh_CN": "互联网专线"}, + "name": {"en": "Internet", "zh": "互联网专线"}, "slug": "internet", "description": "Internet circuit with dedicated public IP addresses/互联网专线(带公网IP地址)", "connection_type": "WAN" }, { "id": 3, - "name": {"en_US": "MPLS", "zh_CN": "MPLS"}, + "name": {"en": "MPLS", "zh": "MPLS"}, "slug": "mpls", "description": "MPLS", "connection_type": "WAN" }, { "id": 4, - "name": {"en_US": "Dark Fiber", "zh_CN": "裸光专线"}, + "name": {"en": "Dark Fiber", "zh": "裸光专线"}, "slug": "dark-fiber", "description": "大带宽同城裸光专线(通常距离较短的大带宽同城裸光专线)", "connection_type": "WAN" }, { "id": 5, - "name": {"en_US": "ADSL", "zh_CN": "ADSL线路"}, + "name": {"en": "ADSL", "zh": "ADSL线路"}, "slug": "adsl", "description": "Intenet access with dynamic public IP addresses /ADSL互联网接入线路(无固定的公网地址)", "connection_type": "WAN" diff --git a/backend/deploy/collections/metadata/device_role.json b/backend/deploy/collections/metadata/device_role.json index f44c1ff..93b21ab 100644 --- a/backend/deploy/collections/metadata/device_role.json +++ b/backend/deploy/collections/metadata/device_role.json @@ -1,62 +1,62 @@ [ { - "name": {"en_US": "Core Switch", "zh_CN": "核心交换机"}, + "name": {"en": "Core Switch", "zh": "核心交换机"}, "slug": "core-switch", "description": "", "abbreviation": "CSW", "priority": 100 }, { - "name": {"en_US": "Distribution Switch", "zh_CN": "汇聚交换机"}, + "name": {"en": "Distribution Switch", "zh": "汇聚交换机"}, "slug": "distribution-switch", "description": "", "abbreviation": "DSW", "priority": 200 }, { - "name": {"en_US": "Access Switch", "zh_CN": "接入交换机"}, + "name": {"en": "Access Switch", "zh": "接入交换机"}, "slug": "access-switch", "description": "", "abbreviation": "ASW", "priority": 300 }, { - "name": {"en_US": "Leaf Switch", "zh_CN": "leaf交换机"}, + "name": {"en": "Leaf Switch", "zh": "leaf交换机"}, "slug": "leaf", "description": "", "abbreviation": "LEAF", "priority": 300 }, { - "name": {"en_US": "Spine Switch", "zh_CN": "Spine交换机"}, + "name": {"en": "Spine Switch", "zh": "Spine交换机"}, "slug": "spine", "description": "", "abbreviation": "SPINE", "priority": 100 }, { - "name": {"en_US": "Border Leaf Switch", "zh_CN": "边缘leaf交换机"}, + "name": {"en": "Border Leaf Switch", "zh": "边缘leaf交换机"}, "slug": "border-leaf", "description": "", "abbreviation": "BLEAF", "priority": 200 }, { - "name": {"en_US": "Firewall", "zh_CN": "防火墙"}, + "name": {"en": "Firewall", "zh": "防火墙"}, "slug": "firewall", "description": "", "abbreviation": "FW", "priority": 50 }, { - "name": {"en_US": "Gateway Router", "zh_CN": "网关路由器"}, + "name": {"en": "Gateway Router", "zh": "网关路由器"}, "slug": "gateway-router", "description": "", "abbreviation": "GR", "priority": 30 }, { - "name": {"en_US": "Access Point", "zh_CN": "无线AP"}, + "name": {"en": "Access Point", "zh": "无线AP"}, "slug": "access-point", "description": "", "abbreviation": "AP", @@ -64,7 +64,7 @@ }, { - "name": {"en_US": "WLAN Controller", "zh_CN": "无线控制器"}, + "name": {"en": "WLAN Controller", "zh": "无线控制器"}, "slug": "wlan-ac", "description": "", "abbreviation": "WLC", diff --git a/backend/deploy/collections/metadata/ip_role.json b/backend/deploy/collections/metadata/ip_role.json index 0c1ad2b..5280a0d 100644 --- a/backend/deploy/collections/metadata/ip_role.json +++ b/backend/deploy/collections/metadata/ip_role.json @@ -1,46 +1,46 @@ [ { - "name": {"en_US": "Wireless", "zh_CN": "无线"}, + "name": {"en": "Wireless", "zh": "无线"}, "slug": "wireless", "description": "wireless mixed access" }, { - "name": {"en_US": "Wireless Empolyee", "zh_CN": "员工无线"}, + "name": {"en": "Wireless Empolyee", "zh": "员工无线"}, "slug": "wireless-employee", "description": "wireless employee access" }, { - "name": {"en_US": "Wireless Guest", "zh_CN": "访客无线"}, + "name": {"en": "Wireless Guest", "zh": "访客无线"}, "slug": "wireless-guest", "description": "wireless guest access" }, { - "name": {"en_US": "Wireless Iot", "zh_CN": "物联网无线"}, + "name": {"en": "Wireless Iot", "zh": "物联网无线"}, "slug": "wireless-iot", "description": "wireless iot access" }, { - "name": {"en_US": "Wired User", "zh_CN": "有线用户"}, + "name": {"en": "Wired User", "zh": "有线用户"}, "slug": "wired-user", "description": "wired user access" }, { - "name": {"en_US": "Printer", "zh_CN": "打印机"}, + "name": {"en": "Printer", "zh": "打印机"}, "slug": "printer", "description": "printer access" }, { - "name": {"en_US": "Video Conference", "zh_CN": "视频会议"}, + "name": {"en": "Video Conference", "zh": "视频会议"}, "slug": "video-conference", "description": "video-conference" }, { - "name": {"en_US": "Server Farm", "zh_CN": "服务器"}, + "name": {"en": "Server Farm", "zh": "服务器"}, "slug": "server-farm", "description": "server farm access" }, { - "name": {"en_US": "Testing", "zh_CN": "测试"}, + "name": {"en": "Testing", "zh": "测试"}, "slug": "testing", "description": "tesings network access" } diff --git a/backend/deploy/collections/metadata/manufacturer.json b/backend/deploy/collections/metadata/manufacturer.json index 6a9971c..1c582d4 100644 --- a/backend/deploy/collections/metadata/manufacturer.json +++ b/backend/deploy/collections/metadata/manufacturer.json @@ -1,52 +1,52 @@ [ { "id": 1, - "name": {"en_US": "Cisco Systems", "zh_CN": "思科"}, + "name": {"en": "Cisco Systems", "zh": "思科"}, "slug": "cisco" }, { "id": 2, - "name": {"en_US": "Juniper Networks", "zh_CN": "瞻博网络"}, + "name": {"en": "Juniper Networks", "zh": "瞻博网络"}, "slug": "juniper" }, { "id": 3, - "name": {"en_US": "PlatAlto Networks", "zh_CN": "PlatAlto 网络"}, + "name": {"en": "PlatAlto Networks", "zh": "PlatAlto 网络"}, "slug": "platalto" }, { "id": 4, - "name": {"en_US": "Arista Networks", "zh_CN": "Arista 网络"}, + "name": {"en": "Arista Networks", "zh": "Arista 网络"}, "slug": "arista" }, { "id": 5, - "name": {"en_US": "HPE", "zh_CN": "HPE"}, + "name": {"en": "HPE", "zh": "HPE"}, "slug": "hpe" }, { "id": 6, - "name": {"en_US": "VMware", "zh_CN": "VMware"}, + "name": {"en": "VMware", "zh": "VMware"}, "slug": "vmware" }, { "id": 7, - "name": {"en_US": "H3C", "zh_CN": "新华三"}, + "name": {"en": "H3C", "zh": "新华三"}, "slug": "h3c" }, { "id": 8, - "name": {"en_US": "Huawei", "zh_CN": "华为"}, + "name": {"en": "Huawei", "zh": "华为"}, "slug": "huawei" }, { "id": 9, - "name": {"en_US": "Ruijie Networks", "zh_CN": "锐捷网络"}, + "name": {"en": "Ruijie Networks", "zh": "锐捷网络"}, "slug": "ruijie" }, { "id": 10, - "name": {"en_US": "FORTINET", "zh_CN": "飞塔"}, + "name": {"en": "FORTINET", "zh": "飞塔"}, "slug": "fortinet" } ] diff --git a/backend/deploy/collections/metadata/rack_role.json b/backend/deploy/collections/metadata/rack_role.json index 84a144a..945088a 100644 --- a/backend/deploy/collections/metadata/rack_role.json +++ b/backend/deploy/collections/metadata/rack_role.json @@ -1,49 +1,49 @@ [ { "id": 1, - "name": {"en_US": "Server Rack", "zh_CN": "服务器机柜"}, + "name": {"en": "Server Rack", "zh": "服务器机柜"}, "slug": "server", "description": "用于托管各种服务器,包括应用服务器、数据库服务器等,该机柜可能包括冗余电源单元、网络交换机等。\nUsed to host various servers, including application servers, database servers, etc. This cabinet may include redundant power units, network switches, etc." }, { "id": 2, - "name": {"en_US": "Network Equipment Rack", "zh_CN": "网络设备机柜"}, + "name": {"en": "Network Equipment Rack", "zh": "网络设备机柜"}, "slug": "network", "description": "专门用于存放网络设备,如交换机、路由器、防火墙等,集中管理和维护网络基础设施。\nSpecifically designed to house network devices such as switches, routers, firewalls, etc for centralize the management and maintenance of network infrastructure." }, { "id": 3, - "name": {"en_US": "Storage Rack", "zh_CN": "存储机柜"}, + "name": {"en": "Storage Rack", "zh": "存储机柜"}, "slug": "storage", "description": "用于托管各种存储设备,如磁盘阵列、存储服务器、网络附加存储等,支持高容量和高性能存储需求。\nUsed to host various storage devices, including disk arrays, storage servers, network-attached storage, etc. Designed to support high-capacity and high-performance storage requirements." }, { "id": 4, - "name": {"en_US": "Management and Monitoring Rack", "zh_CN": "管理监控机柜"}, + "name": {"en": "Management and Monitoring Rack", "zh": "管理监控机柜"}, "slug": "management", "description": "包含用于监控和管理数据中心设备的设备,如监控系统、远程管理设备等。实时监测和响应设备状态。\nAcommodates power units and air conditioning equipment, ensuring stable power supply and suitable environmental conditions for data center equipment." }, { "id": 5, - "name": {"en_US": "Auxiliary Equipment Rack", "zh_CN": "辅助设备机柜"}, + "name": {"en": "Auxiliary Equipment Rack", "zh": "辅助设备机柜"}, "slug": "auxiliary", "description": "包括备用设备、配线架、电缆管理等辅助设备。\nIncludes backup equipment, patch panels, cable management, etc. for auxiliary equipment." }, { "id": 6, - "name": {"en_US": "Security Equipment Rack", "zh_CN": "安全设备机柜"}, + "name": {"en": "Security Equipment Rack", "zh": "安全设备机柜"}, "slug": "security", "description": "存放安全设备,如防火墙、入侵检测,DDos系统等保护数据中心免受网络攻击和潜在威胁。\nHouses security devices such as firewalls, intrusion detection systems, DDoS systems, etc, to protect the data center from network attacks and potential threats." }, { "id": 7, - "name": {"en_US": "Application-Specific Rack", "zh_CN": "应用机柜"}, + "name": {"en": "Application-Specific Rack", "zh": "应用机柜"}, "slug": "application", "description": "GPU加速,高速网络,RDMA等特定计算任务机柜\n host equipment for specific applications or workloads, such as GPU-accelerated computing, high-speed networking, RDMA, etc." }, { "id": 8, - "name": {"en_US": "Testing Rack", "zh_CN": "测试机柜"}, + "name": {"en": "Testing Rack", "zh": "测试机柜"}, "slug": "testing", "description": "专门为测试和开发环境提供的机柜,用于容纳测试服务器、开发服务器等。\nSpecifically designed for testing and development environments, housing servers dedicated to testing and development purposes." } diff --git a/backend/pyproject.toml b/backend/pyproject.toml index ea12017..af4d90e 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -15,8 +15,6 @@ dependencies = [ "redis>=5.0.1", "sentry_sdk>=1.39.2", "httpx>=0.26.0", - "pydantic_extra_types>=2.4.1", - "phonenumbers>=8.13.27", "asyncpg>=0.29.0", "sqlalchemy-utils>=0.41.1", "python-multipart>=0.0.6", @@ -31,8 +29,6 @@ dependencies = [ "icmplib>=3.0.4", "tcppinglib>=2.0.3", "netmiko>=4.3.0", - "sqladmin>=0.18.0", - "itsdangerous>=2.2.0", ] readme = "README.md" requires-python = ">= 3.11" diff --git a/backend/requirements-dev.lock b/backend/requirements-dev.lock index 2c55482..1e642a4 100644 --- a/backend/requirements-dev.lock +++ b/backend/requirements-dev.lock @@ -97,11 +97,8 @@ idna==3.6 # via httpx iniconfig==2.0.0 # via pytest -itsdangerous==2.2.0 - # via netsight jinja2==3.1.4 # via fastapi - # via sqladmin kombu==5.3.7 # via celery mako==1.3.0 @@ -111,7 +108,6 @@ markdown-it-py==3.0.0 markupsafe==2.1.3 # via jinja2 # via mako - # via wtforms mdurl==0.1.2 # via markdown-it-py mypy==1.8.0 @@ -143,8 +139,6 @@ passlib==1.7.4 # via netsight pathspec==0.12.1 # via black -phonenumbers==8.13.27 - # via netsight platformdirs==4.1.0 # via black # via virtualenv @@ -158,12 +152,9 @@ pycparser==2.22 # via cffi pydantic==2.5.3 # via fastapi - # via pydantic-extra-types # via pydantic-settings pydantic-core==2.14.6 # via pydantic -pydantic-extra-types==2.4.1 - # via netsight pydantic-settings==2.1.0 # via netsight pygments==2.18.0 @@ -193,7 +184,6 @@ python-dotenv==1.0.0 python-multipart==0.0.9 # via fastapi # via netsight - # via sqladmin pytz==2024.1 # via pandas pyyaml==6.0.1 @@ -219,18 +209,14 @@ six==1.16.0 sniffio==1.3.0 # via anyio # via httpx -sqladmin==0.18.0 - # via netsight sqlalchemy==2.0.31 # via alembic # via netsight - # via sqladmin # via sqlalchemy-utils sqlalchemy-utils==0.41.1 # via netsight starlette==0.37.2 # via fastapi - # via sqladmin tcppinglib==2.0.3 # via netsight termcolor==2.4.0 @@ -273,5 +259,3 @@ wcwidth==0.2.13 # via prompt-toolkit websockets==12.0 # via uvicorn -wtforms==3.1.2 - # via sqladmin diff --git a/backend/requirements.lock b/backend/requirements.lock index 91e3af9..765c094 100644 --- a/backend/requirements.lock +++ b/backend/requirements.lock @@ -81,11 +81,8 @@ idna==3.6 # via anyio # via email-validator # via httpx -itsdangerous==2.2.0 - # via netsight jinja2==3.1.4 # via fastapi - # via sqladmin kombu==5.3.7 # via celery mako==1.3.0 @@ -95,7 +92,6 @@ markdown-it-py==3.0.0 markupsafe==2.1.3 # via jinja2 # via mako - # via wtforms mdurl==0.1.2 # via markdown-it-py netmiko==4.3.0 @@ -116,20 +112,15 @@ paramiko==3.4.0 # via scp passlib==1.7.4 # via netsight -phonenumbers==8.13.27 - # via netsight prompt-toolkit==3.0.47 # via click-repl pycparser==2.22 # via cffi pydantic==2.5.3 # via fastapi - # via pydantic-extra-types # via pydantic-settings pydantic-core==2.14.6 # via pydantic -pydantic-extra-types==2.4.1 - # via netsight pydantic-settings==2.1.0 # via netsight pygments==2.18.0 @@ -149,7 +140,6 @@ python-dotenv==1.0.0 python-multipart==0.0.9 # via fastapi # via netsight - # via sqladmin pytz==2024.1 # via pandas pyyaml==6.0.1 @@ -171,18 +161,14 @@ six==1.16.0 sniffio==1.3.0 # via anyio # via httpx -sqladmin==0.18.0 - # via netsight sqlalchemy==2.0.31 # via alembic # via netsight - # via sqladmin # via sqlalchemy-utils sqlalchemy-utils==0.41.1 # via netsight starlette==0.37.2 # via fastapi - # via sqladmin tcppinglib==2.0.3 # via netsight textfsm==1.1.3 @@ -219,5 +205,3 @@ wcwidth==0.2.13 # via prompt-toolkit websockets==12.0 # via uvicorn -wtforms==3.1.2 - # via sqladmin diff --git a/backend/src/app.py b/backend/src/app.py index 9a7edb2..7d319e7 100644 --- a/backend/src/app.py +++ b/backend/src/app.py @@ -5,14 +5,11 @@ import sentry_sdk from fastapi import FastAPI from fastapi.responses import HTMLResponse -from sqladmin import Admin from starlette.middleware.cors import CORSMiddleware from starlette.middleware.errors import ServerErrorMiddleware from src.core.config import _Env, settings -from src.core.database.session import async_engine from src.core.errors.exception_handlers import default_exception_handler, exception_handlers, sentry_ignore_errors -from src.features.admin.views import AdminAuth from src.libs.redis import session from src.register.middlewares import RequestMiddleware from src.register.openapi import get_open_api_intro, get_stoplight_elements_html @@ -72,56 +69,4 @@ def get_stoplight_elements() -> HTMLResponse: return app -def add_views(admin: Admin) -> None: - # remove the default admin views if I have time in future to build frontend by React - # it's only and POC for now and simplified for the demo to admin user. - # all views should be added to views.py without any migical implementation - from src.features.admin.views import GroupView, RoleView, UserView - from src.features.circuit.views import CircuitView - from src.features.dcim.views import DeviceView - from src.features.intend.views import ( - CircuitTypeView, - DeviceRoleView, - DeviceTypeView, - IPRoleView, - ManufacturerView, - PlatformView, - ) - from src.features.ipam.views import BlockView, PrefixView, VLANView - from src.features.netconfig.views import ( - AuthCredentialView, - BaseLineConfigView, - JinjaTemplateView, - TextFsmTemplateView, - ) - from src.features.org.views import LocationView, SiteGroupView, SiteView - - admin.add_view(DeviceTypeView) - admin.add_view(PlatformView) - admin.add_view(ManufacturerView) - admin.add_view(IPRoleView) - admin.add_view(CircuitTypeView) - admin.add_view(DeviceRoleView) - admin.add_view(BaseLineConfigView) - admin.add_view(AuthCredentialView) - admin.add_view(JinjaTemplateView) - admin.add_view(TextFsmTemplateView) - admin.add_view(SiteGroupView) - admin.add_view(SiteView) - admin.add_view(LocationView) - admin.add_view(DeviceView) - admin.add_view(BlockView) - admin.add_view(PrefixView) - admin.add_view(VLANView) - admin.add_view(CircuitView) - admin.add_view(GroupView) - admin.add_view(RoleView) - admin.add_view(UserView) - - -auth_backend = AdminAuth(secret_key=settings.SECRET_KEY) app = create_app() -admin = Admin( - app=app, engine=async_engine, authentication_backend=auth_backend, title=settings.PROJECT_NAME, debug=True -) -add_views(admin) diff --git a/backend/src/core/database/base.py b/backend/src/core/database/base.py index e9a2bd4..b9e608c 100644 --- a/backend/src/core/database/base.py +++ b/backend/src/core/database/base.py @@ -5,12 +5,12 @@ class VisibleName(TypedDict, total=True): - en_US: str - zh_CN: str + en: str + zh: str class Base(DeclarativeBase): - __visible_name__: ClassVar[VisibleName] = {"en_US": "base", "zh_CN": "base"} + __visible_name__: ClassVar[VisibleName] = {"en": "base", "zh": "base"} __search_fields__: ClassVar[set[str]] = set() __i18n_fields__: ClassVar[set[str]] = set() diff --git a/backend/src/core/errors/exception_handlers.py b/backend/src/core/errors/exception_handlers.py index 8b62467..34e89ca 100644 --- a/backend/src/core/errors/exception_handlers.py +++ b/backend/src/core/errors/exception_handlers.py @@ -17,7 +17,7 @@ def error_message_value_handler(value: Any) -> Any: - if isinstance(value, dict) and "en_US" in value: + if isinstance(value, dict) and "en" in value: return value[locale_ctx.get()] if isinstance(value, IPv4Address | IPv6Address | IPv4Network | IPv6Network | IPv4Interface | IPv6Interface | UUID): return str(value) diff --git a/backend/src/core/repositories/repository.py b/backend/src/core/repositories/repository.py index 8f883a2..ceab137 100644 --- a/backend/src/core/repositories/repository.py +++ b/backend/src/core/repositories/repository.py @@ -269,8 +269,8 @@ def _apply_filter(self, stmt: Select[tuple[ModelT]], filters: dict[str, Any]) -> if key in self.model.__i18n_fields__ and type(getattr(self.model, key).type) is types.JSON: stmt = stmt.where( or_( - getattr(self.model, key)["zh_CN"].in_(value), - getattr(self.model, key)["en_US"].in_(value), + getattr(self.model, key)["zh"].in_(value), + getattr(self.model, key)["en"].in_(value), ) ) else: diff --git a/backend/src/core/utils/context.py b/backend/src/core/utils/context.py index 1efe910..3c7573f 100644 --- a/backend/src/core/utils/context.py +++ b/backend/src/core/utils/context.py @@ -3,7 +3,7 @@ request_id_ctx: ContextVar[str] = ContextVar("x-request-id", default=str(uuid4())) user_ctx: ContextVar[int | None] = ContextVar("x-auth-user", default=None) -locale_ctx: ContextVar[str] = ContextVar("Accept-Language", default="en_US") +locale_ctx: ContextVar[str] = ContextVar("Accept-Language", default="en") orm_diff_ctx: ContextVar[dict | None] = ContextVar("x-orm-diff", default=None) celery_current_id: ContextVar[str | None] = ContextVar("x-celery-cid", default=None) celery_parent_id: ContextVar[str | None] = ContextVar("x-celery-pid", default=None) diff --git a/backend/src/core/utils/i18n.py b/backend/src/core/utils/i18n.py index 3f5e4f4..6a30afc 100644 --- a/backend/src/core/utils/i18n.py +++ b/backend/src/core/utils/i18n.py @@ -11,7 +11,7 @@ @singleton class I18n: - accepted_languages: ClassVar[set[str]] = {"en_US", "zh_CN"} + accepted_languages: ClassVar[set[str]] = {"en", "zh"} def __init__(self) -> None: self.translations = translations @@ -19,7 +19,7 @@ def __init__(self) -> None: def gettext(self, path: str, **kwargs: Any) -> dict | str: locale = locale_ctx.get() if not locale or locale not in self.accepted_languages: - locale = "en_US" + locale = "en" founded: dict | str = self._find(locale, path) if len(kwargs) > 0 and isinstance(founded, str): diff --git a/backend/src/core/utils/translations.py b/backend/src/core/utils/translations.py index 95266cb..7fbf35e 100644 --- a/backend/src/core/utils/translations.py +++ b/backend/src/core/utils/translations.py @@ -1,4 +1,4 @@ translations = { - "en_US": {}, - "zh_CN": {}, + "en": {}, + "zh": {}, } diff --git a/backend/src/features/_types.py b/backend/src/features/_types.py index 9cb6f6a..09d1c9a 100644 --- a/backend/src/features/_types.py +++ b/backend/src/features/_types.py @@ -108,8 +108,8 @@ class BatchUpdate(BaseModel): class I18nField(BaseModel): - en_US: str # noqa: N815 - zh_CN: str # noqa: N815 + en: str + zh: str class IdResponse(BaseModel): diff --git a/backend/src/features/admin/models.py b/backend/src/features/admin/models.py index fac88ea..59f5557 100644 --- a/backend/src/features/admin/models.py +++ b/backend/src/features/admin/models.py @@ -29,12 +29,11 @@ class RoleMenu(Base): class User(Base, AuditTimeMixin): __tablename__ = "user" - __search_fields__: ClassVar = {"email", "name", "phone"} - __visible_name__ = {"en_US": "User", "zh_CN": "用户"} + __search_fields__: ClassVar = {"email", "name"} + __visible_name__ = {"en": "User", "zh": "用户"} id: Mapped[int_pk] name: Mapped[str] - email: Mapped[str | None] = mapped_column(unique=True) - phone: Mapped[str | None] = mapped_column(unique=True) + email: Mapped[str] = mapped_column(unique=True) password: Mapped[str] avatar: Mapped[str | None] last_login: Mapped[datetime | None] = mapped_column(DateTime(timezone=True)) @@ -49,9 +48,9 @@ class User(Base, AuditTimeMixin): class Group(Base, AuditTimeMixin): __tablename__ = "group" __search_fields__: ClassVar = {"name"} - __visible_name__ = {"en_US": "Group", "zh_CN": "用户组"} + __visible_name__ = {"en": "Group", "zh": "用户组"} id: Mapped[int_pk] = mapped_column(nullable=False) - name: Mapped[str] + name: Mapped[str] = mapped_column(unique=True, nullable=False) description: Mapped[str | None] role_id: Mapped[int] = mapped_column(ForeignKey("role.id", ondelete="CASCADE")) role: Mapped["Role"] = relationship(backref="group", passive_deletes=True) @@ -64,7 +63,7 @@ class Group(Base, AuditTimeMixin): class Permission(Base): __tablename__ = "permission" - __visible_name__ = {"en_US": "Permission", "zh_CN": "权限"} + __visible_name__ = {"en": "Permission", "zh": "权限"} id: Mapped[uuid_pk] name: Mapped[str] url: Mapped[str] @@ -76,10 +75,10 @@ class Permission(Base): class Role(Base, AuditTimeMixin): __tablename__ = "role" __search_fields__: ClassVar = {"name"} - __visible_name__ = {"en_US": "Role", "zh_CN": "用户角色"} + __visible_name__ = {"en": "Role", "zh": "用户角色"} id: Mapped[int_pk] = mapped_column(nullable=False) - name: Mapped[str] - slug: Mapped[str] + name: Mapped[str] = mapped_column(unique=True, nullable=False) + slug: Mapped[str] = mapped_column(unique=True, nullable=False) description: Mapped[str | None] permission: Mapped[list["Permission"]] = relationship(secondary="role_permission", back_populates="role") menu: Mapped[list["Menu"]] = relationship(secondary="role_menu", back_populates="role") @@ -98,7 +97,7 @@ class Role(Base, AuditTimeMixin): class Menu(Base): __tablename__ = "menu" - __visible_name__ = {"en_US": "Menu", "zh_CN": "菜单"} + __visible_name__ = {"en": "Menu", "zh": "菜单"} id: Mapped[int] = mapped_column(Integer, primary_key=True) name: Mapped[str] = mapped_column(unique=True, comment="the unique name of route") hidden: Mapped[bool_false] diff --git a/backend/src/features/admin/schemas.py b/backend/src/features/admin/schemas.py index 10983a6..b9e2745 100644 --- a/backend/src/features/admin/schemas.py +++ b/backend/src/features/admin/schemas.py @@ -1,8 +1,6 @@ from datetime import datetime from uuid import UUID -from pydantic_extra_types.phone_numbers import PhoneNumber - from src.features._types import AuditTime, BaseModel, QueryParams @@ -36,7 +34,6 @@ class PermissionQuery(QueryParams): ... class UserBase(BaseModel): name: str email: str | None = None - phone: PhoneNumber | None = None avatar: str | None = None diff --git a/backend/src/features/admin/services.py b/backend/src/features/admin/services.py index d91505c..60ee191 100644 --- a/backend/src/features/admin/services.py +++ b/backend/src/features/admin/services.py @@ -23,7 +23,7 @@ class UserService(BaseRepository[User, schemas.UserCreate, schemas.UserUpdate, schemas.UserQuery]): async def verify_user(self, session: AsyncSession, user: OAuth2PasswordRequestForm) -> User: - stmt = self._get_base_stmt().where(or_(self.model.email == user.username, self.model.phone == user.username)) + stmt = self._get_base_stmt().where(or_(self.model.email == user.username)) db_user = await session.scalar(stmt) if not db_user: raise NotFoundError(self.model.__visible_name__[locale_ctx.get()], "username", user.username) diff --git a/backend/src/features/admin/views.py b/backend/src/features/admin/views.py deleted file mode 100644 index 1808e28..0000000 --- a/backend/src/features/admin/views.py +++ /dev/null @@ -1,104 +0,0 @@ -from fastapi.requests import Request -from fastapi.security import OAuth2PasswordRequestForm -from sqladmin import ModelView -from sqladmin.authentication import AuthenticationBackend - -from src.core.database.session import async_session -from src.core.utils.context import locale_ctx -from src.features.admin import models -from src.features.admin.security import generate_access_token_response -from src.features.admin.services import user_service -from src.features.deps import sqladmin_auth - - -class AdminAuth(AuthenticationBackend): - async def login(self, request: Request) -> bool: - form = await request.form() - user_form = OAuth2PasswordRequestForm(username=form["username"], password=form["password"]) - async with async_session() as session: - user = await user_service.verify_user(session, user_form) - token = generate_access_token_response(user.id) - request.session.update({"Authorization": f"Bearer {token.access_token}"}) - return True - - async def logout(self, request: Request) -> bool: - request.session.clear() - return True - - async def authenticate(self, request: Request) -> bool: - token = request.session.get("Authorization") - if not token or "Bearer " not in token: - return False - token = token.split("Bearer ")[1] - await sqladmin_auth(token) - return True - - -class UserView(ModelView, model=models.User): - name = models.User.__visible_name__[locale_ctx.get()] - category = "Administration" - column_list = [ - models.User.name, - models.User.email, - models.User.phone, - models.User.avatar, - models.User.last_login, - models.User.is_active, - models.User.group, - models.User.role, - models.User.last_login, - models.User.created_at, - models.User.updated_at, - ] - column_searchable_list = [models.User.email, models.User.phone] - column_filters = [models.User.email, models.User.phone] - - page_size = 20 - page_size_options = [20, 50, 100, 200] - - form_ajax_refs = {"group": {"fields": ("name",), "order_by": "id"}, "role": {"fields": ("name",), "order_by": "id"}} - - icon = "fa-solid fa-user" - - -class GroupView(ModelView, model=models.Group): - name = models.Group.__visible_name__[locale_ctx.get()] - category = "Administration" - - column_list = [ - models.Group.name, - models.Group.description, - models.Group.role, - models.Group.user_count, - models.Group.created_at, - models.Group.updated_at, - ] - column_searchable_list = [models.Group.name] - column_filters = [models.Group.name] - - page_size = 20 - page_size_options = [20, 50, 100, 200] - - form_ajax_refs = {"role": {"fields": ("name",), "order_by": "id"}} - icon = "fa-solid fa-user-group" - - -class RoleView(ModelView, model=models.Role): - name = models.Role.__visible_name__[locale_ctx.get()] - category = "Administration" - column_list = [ - models.Role.name, - models.Role.description, - models.Role.permission_count, - models.Role.user_count, - models.Role.created_at, - models.Role.updated_at, - ] - column_searchable_list = [models.Role.name] - column_filters = [models.Role.name] - - page_size = 20 - page_size_options = [20, 50, 100, 200] - - form_ajax_refs = {"group": {"fields": ("name",), "order_by": "id"}} - icon = "fa-sharp fa-solid fa-circle-user" diff --git a/backend/src/features/alert/models.py b/backend/src/features/alert/models.py index 1248350..41b990a 100644 --- a/backend/src/features/alert/models.py +++ b/backend/src/features/alert/models.py @@ -47,7 +47,7 @@ class AlertUser(Base, AuditUserMixin): class Alert(Base, AuditTimeMixin): __tablename__ = "alert" - __visible_name__ = {"en_US": "AlertMeta", "zh_CN": "告警定义"} + __visible_name__ = {"en": "AlertMeta", "zh": "告警定义"} id: Mapped[int_pk] name: Mapped[i18n_name] = mapped_column(unique=True) slug: Mapped[str] = mapped_column(unique=True) @@ -83,7 +83,7 @@ def duration(self) -> str: class Event(Base, EventMixin): __tablename__ = "event" - __visible_name__ = {"en_US": "AlertEvent", "zh_CN": "告警事件"} + __visible_name__ = {"en": "AlertEvent", "zh": "告警事件"} id: Mapped[int_pk] alert_id: Mapped[int] = mapped_column(ForeignKey("alert.id", ondelete="CASCADE")) alert: Mapped["Alert"] = relationship(backref="event") @@ -107,7 +107,7 @@ class Event(Base, EventMixin): class EventGroup(Base, EventMixin): __tablename__ = "event_group" - __visible_name__ = {"en_US": "AlertEventGroup", "zh_CN": "告警事件组"} + __visible_name__ = {"en": "AlertEventGroup", "zh": "告警事件组"} id: Mapped[int_pk] name: Mapped[str] group_key: Mapped[str | None] diff --git a/backend/src/features/circuit/api.py b/backend/src/features/circuit/api.py index 73c50e2..0897827 100644 --- a/backend/src/features/circuit/api.py +++ b/backend/src/features/circuit/api.py @@ -103,8 +103,8 @@ async def get_circuit(self, id: int) -> schemas.Circuit: selectinload(Circuit.site_z).load_only(Site.id, Site.name, Site.site_code), selectinload(Circuit.device_z).load_only(Device.id, Device.name, Device.management_ip), selectinload(Circuit.interface_z).load_only(Interface.id, Interface.name), - selectinload(Circuit.created_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(Circuit.updated_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(Circuit.created_by).load_only(User.id, User.name, User.email, User.avatar), + selectinload(Circuit.updated_by).load_only(User.id, User.name, User.email, User.avatar), ) return schemas.Circuit.model_validate(db_circuit) diff --git a/backend/src/features/circuit/models.py b/backend/src/features/circuit/models.py index 2fc0404..33327d2 100644 --- a/backend/src/features/circuit/models.py +++ b/backend/src/features/circuit/models.py @@ -28,7 +28,7 @@ class Circuit(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "circuit" - __visible_name__ = {"en_US": "Circuit", "zh_CN": "线路"} + __visible_name__ = {"en": "Circuit", "zh": "线路"} __search_fields__ = {"name", "slug", "cid"} id: Mapped[int_pk] name: Mapped[str] = mapped_column(unique=True) @@ -62,7 +62,7 @@ class Circuit(Base, AuditUserMixin, AuditLogMixin): class ISP(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "isp" - __visible_name__ = {"en_US": "ISP", "zh_CN": "营运商"} + __visible_name__ = {"en": "ISP", "zh": "营运商"} __i18n_fields__ = {"name"} __search_fields__ = {"name", "slug"} id: Mapped[int_pk] diff --git a/backend/src/features/circuit/views.py b/backend/src/features/circuit/views.py deleted file mode 100644 index e8e33e7..0000000 --- a/backend/src/features/circuit/views.py +++ /dev/null @@ -1,36 +0,0 @@ -from sqladmin import ModelView - -from src.features.circuit.models import ISP, Circuit - - -class CircuitView(ModelView, model=Circuit): - category = "Circuit" - name = "Circuit" - name_plural = "Circuits" - - icon = "fa-solid fa-arrow-down-up-across-line" - - column_list = [ - Circuit.name, - Circuit.cid, - Circuit.circuit_type, - Circuit.isp, - Circuit.site_a, - Circuit.device_a, - Circuit.interface_a, - Circuit.site_z, - Circuit.device_z, - Circuit.interface_z, - Circuit.created_at, - Circuit.updated_at, - ] - - -class ISPView(ModelView, model=ISP): - category = "Circuit" - name = "ISP" - name_plural = "ISPs" - - icon = "fa-solid fa-industry" - - column_list = [ISP.name, ISP.noc_contact, ISP.admin_contact, ISP.created_at, ISP.updated_at] diff --git a/backend/src/features/dcim/api.py b/backend/src/features/dcim/api.py index 1ee31f5..d814342 100644 --- a/backend/src/features/dcim/api.py +++ b/backend/src/features/dcim/api.py @@ -42,8 +42,8 @@ async def get_device(self, id: int) -> schemas.Device: selectinload(Device.device_role).load_only(DeviceRole.id, DeviceRole.name), selectinload(Device.location).load_only(Location.id, Location.name), selectinload(Device.site).load_only(Site.id, Site.name), - selectinload(Device.created_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(Device.updated_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(Device.created_by).load_only(User.id, User.name, User.email, User.avatar), + selectinload(Device.updated_by).load_only(User.id, User.name, User.email, User.avatar), undefer_load=True, ) return schemas.Device.model_validate(db_device) diff --git a/backend/src/features/dcim/models.py b/backend/src/features/dcim/models.py index 5a40fec..356dcb3 100644 --- a/backend/src/features/dcim/models.py +++ b/backend/src/features/dcim/models.py @@ -24,7 +24,7 @@ class Device(Base, AuditUserMixin, AuditLogMixin): # make sure device is management by logic in dcim.views. if device is stacked # members should be added and treated as stacked for this master device __tablename__ = "device" - __visible_name__ = {"en_US": "Device", "zh_CN": "设备"} + __visible_name__ = {"en": "Device", "zh": "设备"} __search_fields__ = {"name", "management_ipv4", "management_ipv6", "serial_num", "oob_ip"} id: Mapped[int_pk] name: Mapped[str] = mapped_column(index=True) @@ -34,7 +34,7 @@ class Device(Base, AuditUserMixin, AuditLogMixin): software_version: Mapped[str | None] software_patch: Mapped[str | None] comments: Mapped[str | None] - serial_number: Mapped[str | None] = mapped_column(unique=True) # master + serial_number: Mapped[str | None] asset_tag: Mapped[str | None] device_type_id: Mapped[int] = mapped_column(ForeignKey("device_type.id", ondelete="RESTRICT")) device_type: Mapped["DeviceType"] = relationship(backref="device", passive_deletes=True) @@ -65,6 +65,7 @@ class Device(Base, AuditUserMixin, AuditLogMixin): class DeviceModule(Base, AuditTimeMixin): __tablename__ = "module" + __search_fields__ = {"name", "serial_number"} id: Mapped[int_pk] name: Mapped[str] # huawei: module description: Mapped[str | None] # huawei board info @@ -78,6 +79,8 @@ class DeviceModule(Base, AuditTimeMixin): class DeviceStack(Base, AuditTimeMixin): __tablename__ = "stack" + __visible_name__ = {"en": "Stack", "zh": "stack"} + __search_fields__ = {"mac_address"} id: Mapped[int_pk] role: Mapped[str] mac_address: Mapped[str] @@ -89,7 +92,8 @@ class DeviceStack(Base, AuditTimeMixin): class DeviceEquipment(Base, AuditTimeMixin): # device FAN/Power/SFP Module __tablename__ = "equipment" - __visible_name__ = {"en_US": "Equipment", "zh_CN": "Equipment"} + __visible_name__ = {"en": "Equipment", "zh": "Equipment"} + __search_fields__ = {"name", "serial_number"} id: Mapped[int_pk] name: Mapped[str] eq_type: Mapped[DeviceEquipmentType] = mapped_column(ChoiceType(DeviceEquipmentType, impl=String())) @@ -101,7 +105,7 @@ class DeviceEquipment(Base, AuditTimeMixin): class DeviceConfig(Base): __tablename__ = "device_config" - __visible_name__ = {"en_US": "Device Config", "zh_CN": "设备配置"} + __visible_name__ = {"en": "Device Config", "zh": "设备配置"} id: Mapped[int_pk] # if you want to save many history configuration versions, db is not recommended. # store content in Object Storage @@ -121,7 +125,7 @@ class DeviceConfig(Base): class Interface(Base, AuditTimeMixin): __tablename__ = "interface" __table_args__ = (UniqueConstraint("device_id", "name"),) - __visible_name__ = {"en_US": "Interface", "zh_CN": "interface"} + __visible_name__ = {"en": "Interface", "zh": "interface"} id: Mapped[int] = mapped_column(primary_key=True) name: Mapped[str] description: Mapped[str | None] @@ -140,7 +144,7 @@ class Interface(Base, AuditTimeMixin): class LldpNeighbor(Base, AuditTimeMixin): __tablename__ = "lldp_neighbor" - __visible_name__ = {"en_US": "LLDP Neighbor", "zh_CN": "LLDP邻居"} + __visible_name__ = {"en": "LLDP Neighbor", "zh": "LLDP邻居"} id: Mapped[int_pk] source_interface_id: Mapped[int] = mapped_column(ForeignKey("interface.id", ondelete="CASCADE")) source_interface: Mapped["Interface"] = relationship(backref="source_interface", foreign_keys=[source_interface_id]) diff --git a/backend/src/features/dcim/views.py b/backend/src/features/dcim/views.py deleted file mode 100644 index a5d6dd6..0000000 --- a/backend/src/features/dcim/views.py +++ /dev/null @@ -1,26 +0,0 @@ -from sqladmin import ModelView - -from src.features.dcim import models - - -class DeviceView(ModelView, model=models.Device): - category = "DCIM" - - name = "Device" - name_plural = "Devices" - icon = "fa-solid fa-router" - column_list = [ - models.Device.name, - models.Device.management_ip, - models.Device.status, - models.Device.site, - models.Device.location, - models.Device.device_type, - models.Device.device_role, - models.Device.platform, - models.Device.manufacturer, - models.Device.created_at, - models.Device.updated_at, - ] - column_searchable_list = [models.Device.name] - column_filters = [models.Device.device_type, models.Device.device_role, models.Device.site, models.Device.location] diff --git a/backend/src/features/intend/models.py b/backend/src/features/intend/models.py index e14c120..5b5e557 100644 --- a/backend/src/features/intend/models.py +++ b/backend/src/features/intend/models.py @@ -17,7 +17,7 @@ class DeviceRole(Base, AuditUserMixin): __tablename__ = "device_role" - __visible_name__ = {"en_US": "Device Role", "zh_CN": "设备角色"} + __visible_name__ = {"en": "Device Role", "zh": "设备角色"} id: Mapped[int_pk] = mapped_column(nullable=False) name: Mapped[i18n_name] slug: Mapped[str] = mapped_column(unique=True) @@ -41,7 +41,7 @@ def __declare_last__(cls) -> None: class IPRole(Base, AuditUserMixin): __tablename__ = "ip_role" - __visible_name__ = {"en_US": "IP Role", "zh_CN": "IP角色"} + __visible_name__ = {"en": "IP Role", "zh": "IP角色"} id: Mapped[int_pk] name: Mapped[i18n_name] slug: Mapped[str] = mapped_column(unique=True) @@ -52,7 +52,7 @@ class IPRole(Base, AuditUserMixin): class CircuitType(Base, AuditUserMixin): __tablename__ = "circuit_type" - __visible_name__ = {"en_US": "Circuit Type", "zh_CN": "线路类型"} + __visible_name__ = {"en": "Circuit Type", "zh": "线路类型"} id: Mapped[int_pk] = mapped_column(nullable=False) name: Mapped[i18n_name] slug: Mapped[str] = mapped_column(unique=True) @@ -105,7 +105,7 @@ def __declare_last__(cls) -> None: class DeviceType(Base, AuditUserMixin): __tablename__ = "device_type" - __visible_name__ = {"en_US": "Device Type", "zh_CN": "设备型号"} + __visible_name__ = {"en": "Device Type", "zh": "设备型号"} __table_args__ = (UniqueConstraint("manufacturer_id", "name"),) id: Mapped[int_pk] = mapped_column(nullable=False) name: Mapped[str] = mapped_column(unique=True) @@ -135,7 +135,7 @@ def __declare_last__(cls) -> None: class Manufacturer(Base, AuditUserMixin): __tablename__ = "manufacturer" - __visible_name__ = {"en_US": "Manufacturer", "zh_CN": "厂商"} + __visible_name__ = {"en": "Manufacturer", "zh": "厂商"} __i18n_fields__ = {"name"} id: Mapped[int_pk] = mapped_column(nullable=False) name: Mapped[i18n_name] diff --git a/backend/src/features/intend/views.py b/backend/src/features/intend/views.py deleted file mode 100644 index 09ec642..0000000 --- a/backend/src/features/intend/views.py +++ /dev/null @@ -1,103 +0,0 @@ -from sqladmin import ModelView - -from src.features.intend import models - - -class DeviceTypeView(ModelView, model=models.DeviceType): - category = "Intend" - name = "Device Type" - name_plural = "Device Types" - - icon = "fa-solid fa-hard-drive" - - column_list = [ - models.DeviceType.name, - models.DeviceType.u_height, - models.DeviceType.snmp_sysobjectid, - models.DeviceType.manufacturer, - models.DeviceType.platform, - models.DeviceType.created_at, - models.DeviceType.updated_at, - ] - - -class PlatformView(ModelView, model=models.Platform): - category = "Intend" - - name = "Platform" - name_plural = "Platforms" - icon = "fa-solid fa-shredder" - - column_list = [ - models.Platform.name, - models.Platform.slug, - models.Platform.description, - models.Platform.netmiko_driver, - models.Platform.created_at, - models.Platform.updated_at, - ] - - -class DeviceRoleView(ModelView, model=models.DeviceRole): - category = "Intend" - - name = "Device Role" - name_plural = "Device Roles" - icon = "fa-solid fa-tablet-rugged" - - column_list = [ - models.DeviceRole.name, - models.DeviceRole.priority, - models.DeviceRole.abbreviation, - models.DeviceRole.description, - models.DeviceRole.created_at, - models.DeviceRole.updated_at, - ] - - -class CircuitTypeView(ModelView, model=models.CircuitType): - category = "Intend" - - name = "Circuit Type" - name_plural = "Circuit Types" - icon = "fa-sharp fa-solid fa-plug" - - column_list = [ - models.CircuitType.name, - models.CircuitType.slug, - models.CircuitType.description, - models.CircuitType.created_at, - models.CircuitType.updated_at, - ] - - -class IPRoleView(ModelView, model=models.IPRole): - category = "Intend" - - name = "IP Role" - name_plural = "IP Roles" - - icon = "fa-solid fa-network-wired" - - column_list = [ - models.IPRole.name, - models.IPRole.slug, - models.IPRole.description, - models.IPRole.created_at, - models.IPRole.updated_at, - ] - - -class ManufacturerView(ModelView, model=models.Manufacturer): - category = "Intend" - name = "Manufacturer" - name_plural = "Manufacturers" - - icon = "fa-solid fa-industry" - - column_list = [ - models.Manufacturer.name, - models.Manufacturer.slug, - models.Manufacturer.created_at, - models.Manufacturer.updated_at, - ] diff --git a/backend/src/features/ipam/models.py b/backend/src/features/ipam/models.py index 93e4926..ad1d66c 100644 --- a/backend/src/features/ipam/models.py +++ b/backend/src/features/ipam/models.py @@ -47,7 +47,7 @@ class IPAddressUser(Base): class Block(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "block" - __visible_name__ = {"en_US": "IP Block", "zh_CN": "IP地址段"} + __visible_name__ = {"en": "IP Block", "zh": "IP地址段"} __search_fields__ = {"block"} id: Mapped[int_pk] name: Mapped[str] @@ -60,7 +60,7 @@ class Block(Base, AuditUserMixin, AuditLogMixin): class Prefix(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "prefix" - __visible_name__ = {"en_US": "IP Prefix", "zh_CN": "IP子网段"} + __visible_name__ = {"en": "IP Prefix", "zh": "IP子网段"} __search_fields__ = {"prefix"} id: Mapped[int_pk] prefix: Mapped[IPvAnyNetwork] = mapped_column(PgCIDR, unique=True, index=True) @@ -79,7 +79,7 @@ class Prefix(Base, AuditUserMixin, AuditLogMixin): class ASN(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "asn" - __visible_name__ = {"en_US": "AS Number", "zh_CN": "AS号"} + __visible_name__ = {"en": "AS Number", "zh": "AS号"} __search_fields__ = {"asn"} id: Mapped[int_pk] asn: Mapped[int] = mapped_column(unique=True) @@ -90,7 +90,7 @@ class ASN(Base, AuditUserMixin, AuditLogMixin): class IPRange(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "ip_range" - __visible_name__ = {"en_US": "IP Range", "zh_CN": "IP地址串"} + __visible_name__ = {"en": "IP Range", "zh": "IP地址串"} id: Mapped[int_pk] start_address: Mapped[IPvAnyInterface] = mapped_column(PgIpInterface) end_address: Mapped[IPvAnyInterface] = mapped_column(PgIpInterface) @@ -106,7 +106,7 @@ def size(self) -> int: class IPAddress(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "ip_address" - __visible_name__ = {"en_US": "IP Address", "zh_CN": "IP地址"} + __visible_name__ = {"en": "IP Address", "zh": "IP地址"} __search_fields__ = {"address"} id: Mapped[int_pk] address: Mapped[IPvAnyInterface] = mapped_column(PgIpInterface) diff --git a/backend/src/features/ipam/views.py b/backend/src/features/ipam/views.py deleted file mode 100644 index b803405..0000000 --- a/backend/src/features/ipam/views.py +++ /dev/null @@ -1,57 +0,0 @@ -from sqladmin import ModelView - -from src.features.ipam import models - - -class BlockView(ModelView, model=models.Block): - category = "IPAM" - name = "IP Block" - name_plural = "IP Blocks" - column_list = [ - models.Block.name, - models.Block.block, - models.Block.size, - models.Block.range, - models.Block.is_private, - models.Block.description, - ] - column_searchable_list = [models.Block.name] - column_filters = [ - models.Block.block, - models.Block.is_private, - ] - icon = "codepen" - - -class PrefixView(ModelView, model=models.Prefix): - category = "IPAM" - name = "Prefix" - name_plural = "Prefixes" - - column_list = [ - models.Prefix.prefix, - models.Prefix.site, - models.Prefix.vrf, - models.Prefix.role, - models.Prefix.vlan, - ] - column_searchable_list = [models.Prefix.prefix] - column_filters = [ - models.Prefix.site, - models.Prefix.vrf, - models.Prefix.role, - models.Prefix.vlan, - ] - icon = "codepen" - - -class ASNView(ModelView, model=models.ASN): - category = "IPAM" - name = "ASN" - name_plural = "ASNs" - - -class VLANView(ModelView, model=models.VLAN): - category = "IPAM" - name = "VLAN" - name_plural = "VLANS" diff --git a/backend/src/features/netconfig/models.py b/backend/src/features/netconfig/models.py index b9b17bd..0f812a4 100644 --- a/backend/src/features/netconfig/models.py +++ b/backend/src/features/netconfig/models.py @@ -16,7 +16,7 @@ class BaseLineConfig(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "baseline_config" - __visible_name__ = {"en_US": "Baseline Configuration", "zh_CN": "基线配置"} + __visible_name__ = {"en": "Baseline Configuration", "zh": "基线配置"} id: Mapped[int_pk] aaa_server: Mapped[list[str] | None] = mapped_column(ARRAY(String, dimensions=1)) dhcp_server: Mapped[list[str] | None] = mapped_column(ARRAY(String, dimensions=1)) @@ -31,7 +31,7 @@ class BaseLineConfig(Base, AuditUserMixin, AuditLogMixin): class AuthCredential(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "auth_credential" - __visible_name__ = {"en_US": "Auth Crendential", "zh_CN": "认证凭证"} + __visible_name__ = {"en": "Auth Crendential", "zh": "认证凭证"} id: Mapped[int_pk] cli: Mapped[str | None] = mapped_column(EncryptedString()) snmpv2_community: Mapped[str | None] = mapped_column(EncryptedString()) @@ -43,7 +43,7 @@ class AuthCredential(Base, AuditUserMixin, AuditLogMixin): class TextFsmTemplate(Base, AuditUserMixin): __tablename__ = "textfsm_template" - __visible_name__ = {"en_US": "TextFSM Template", "zh_CN": "TextFSM模板"} + __visible_name__ = {"en": "TextFSM Template", "zh": "TextFSM模板"} id: Mapped[int_pk] name: Mapped[str] template: Mapped[str] @@ -53,7 +53,7 @@ class TextFsmTemplate(Base, AuditUserMixin): class JinjaTemplate(Base, AuditUserMixin): __tablename__ = "jinja_template" - __visible_name__ = {"en_US": "Jinja Template", "zh_CN": "Jinja模板"} + __visible_name__ = {"en": "Jinja Template", "zh": "Jinja模板"} id: Mapped[int_pk] name: Mapped[str] template: Mapped[str] diff --git a/backend/src/features/netconfig/views.py b/backend/src/features/netconfig/views.py deleted file mode 100644 index c7da401..0000000 --- a/backend/src/features/netconfig/views.py +++ /dev/null @@ -1,56 +0,0 @@ -from sqladmin import ModelView - -from src.features.netconfig.models import AuthCredential, BaseLineConfig, JinjaTemplate, TextFsmTemplate - - -class BaseLineConfigView(ModelView, model=BaseLineConfig): - name = "Baseline Configuration" - name_plural = "Baseline Configurations" - category = "Network Configuration" - column_list = [ - BaseLineConfig.aaa_server, - BaseLineConfig.dhcp_server, - BaseLineConfig.dns_server, - BaseLineConfig.ntp_server, - BaseLineConfig.syslog_server, - BaseLineConfig.netflow_server, - ] - - -class AuthCredentialView(ModelView, model=AuthCredential): - name = "Auth Credential" - name_plural = "Auth Credentials" - category = "Network Configuration" - column_list = [ - AuthCredential.cli, - AuthCredential.snmpv2_community, - AuthCredential.snmpv3, - AuthCredential.created_at, - AuthCredential.updated_at, - ] - - -class JinjaTemplateView(ModelView, model=JinjaTemplate): - name = "Jinja Template" - name_plural = "Jinja Templates" - category = "Network Configuration" - column_list = [ - JinjaTemplate.name, - JinjaTemplate.template, - JinjaTemplate.platform, - JinjaTemplate.created_at, - JinjaTemplate.updated_at, - ] - - -class TextFsmTemplateView(ModelView, model=TextFsmTemplate): - name = "TextFSM Template" - name_plural = "TextFSM Templates" - category = "Network Configuration" - column_list = [ - TextFsmTemplate.name, - TextFsmTemplate.template, - TextFsmTemplate.platform, - TextFsmTemplate.created_at, - TextFsmTemplate.updated_at, - ] diff --git a/backend/src/features/org/api.py b/backend/src/features/org/api.py index cc543ac..b5e9820 100644 --- a/backend/src/features/org/api.py +++ b/backend/src/features/org/api.py @@ -35,8 +35,8 @@ async def get_site_group(self, id: int) -> schemas.SiteGroup: db_group = await self.service.get_one_or_404( self.session, id, - selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.avatar), + selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.avatar), ) return schemas.SiteGroup.model_validate(db_group) @@ -45,8 +45,8 @@ async def get_site_groups(self, q: schemas.SiteGroupQuery = Depends()) -> ListT[ count, results = await self.service.list_and_count( self.session, q, - selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.avatar), + selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.avatar), ) return ListT(count=count, results=[schemas.SiteGroupList.model_validate(r) for r in results]) @@ -79,11 +79,11 @@ async def get_site(self, id: int) -> schemas.Site: db_site = await self.service.get_one_or_404( self.session, id, - selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.avatar), + selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.avatar), selectinload(Site.site_group).load_only(SiteGroup.id, SiteGroup.name), - selectinload(Site.network_contact).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(Site.it_contact).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(Site.network_contact).load_only(User.id, User.name, User.email, User.avatar), + selectinload(Site.it_contact).load_only(User.id, User.name, User.email, User.avatar), ) return schemas.Site.model_validate(db_site) @@ -92,11 +92,11 @@ async def get_sites(self, q: schemas.SiteQuery = Depends()) -> ListT[schemas.Sit count, results = await self.service.list_and_count( self.session, q, - selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(SiteGroup.created_by).load_only(User.id, User.name, User.email, User.avatar), + selectinload(SiteGroup.updated_by).load_only(User.id, User.name, User.email, User.avatar), selectinload(Site.site_group).load_only(SiteGroup.id, SiteGroup.name), - selectinload(Site.network_contact).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(Site.it_contact).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(Site.network_contact).load_only(User.id, User.name, User.email, User.avatar), + selectinload(Site.it_contact).load_only(User.id, User.name, User.email, User.avatar), ) return ListT(count=count, results=[schemas.Site.model_validate(r) for r in results]) @@ -142,8 +142,8 @@ async def get_location(self, id: int) -> schemas.Location: self.session, id, selectinload(Location.site).load_only(Site.id, Site.name, Site.site_code), - selectinload(Location.created_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), - selectinload(Location.updated_by).load_only(User.id, User.name, User.email, User.phone, User.avatar), + selectinload(Location.created_by).load_only(User.id, User.name, User.email, User.avatar), + selectinload(Location.updated_by).load_only(User.id, User.name, User.email, User.avatar), ) return schemas.Location.model_validate(db_location) diff --git a/backend/src/features/org/models.py b/backend/src/features/org/models.py index 96ca64b..ed106ca 100644 --- a/backend/src/features/org/models.py +++ b/backend/src/features/org/models.py @@ -22,7 +22,7 @@ class Site(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "site" __search_fields__ = {"name", "site_code", "physical_address"} - __visible_name__ = {"en_US": "Site", "zh_CN": "站点"} + __visible_name__ = {"en": "Site", "zh": "站点"} id: Mapped[int_pk] name: Mapped[str] = mapped_column(unique=True) site_code: Mapped[str] = mapped_column(unique=True, index=True) @@ -75,7 +75,7 @@ class SiteGroup(Base, AuditUserMixin): __tablename__ = "site_group" __search_fields__ = {"name", "slug"} - __visible_name__ = {"en_US": "Site Group", "zh_CN": "站点组"} + __visible_name__ = {"en": "Site Group", "zh": "站点组"} id: Mapped[int] = mapped_column(Integer, primary_key=True) name: Mapped[str] = mapped_column(unique=True) description: Mapped[str | None] @@ -91,7 +91,7 @@ class Location(Base, AuditUserMixin, AuditLogMixin): __tablename__ = "location" __table_args__ = (UniqueConstraint("site_id", "name"),) - __visible_name__ = {"en_US": "Location", "zh_CN": "位置"} + __visible_name__ = {"en": "Location", "zh": "位置"} id: Mapped[int] = mapped_column(primary_key=True) name: Mapped[str] location_type: Mapped[LocationType] = mapped_column(ChoiceType(LocationType, impl=String())) diff --git a/backend/src/features/org/views.py b/backend/src/features/org/views.py deleted file mode 100644 index 5284eb5..0000000 --- a/backend/src/features/org/views.py +++ /dev/null @@ -1,76 +0,0 @@ -from sqladmin import ModelView - -from src.features.org import models - - -class SiteGroupView(ModelView, model=models.SiteGroup): - name = "Site Group" - name_plural = "Site Groups" - category = "Organization" - - column_list = [ - models.SiteGroup.name, - models.SiteGroup.description, - models.SiteGroup.site_count, - models.SiteGroup.created_at, - models.SiteGroup.updated_at, - models.SiteGroup.created_by, - models.SiteGroup.updated_by, - ] - - column_sortable_list = [models.SiteGroup.name] - column_filters = [models.SiteGroup.name] - page_size = 20 - page_size_options = [20, 50, 100, 200] - form_create_rules = ["name", "description"] - icon = "fa-solid fa-sitemap" - - -class SiteView(ModelView, model=models.Site): - name = "Site" - name_plural = "Sites" - category = "Organization" - icon = "fa-solid fa-location-dot" - - column_list = [ - models.Site.name, - models.Site.site_code, - models.Site.status, - models.Site.country, - models.Site.city, - models.Site.site_group, - models.Site.network_contact, - models.Site.it_contact, - models.Site.created_at, - models.Site.updated_at, - models.Site.created_by, - models.Site.updated_by, - ] - - column_sortable_list = [models.Site.name, models.Site.site_code] - column_filters = [models.Site.name] - page_size = 20 - page_size_options = [20, 50, 100, 200] - - -class LocationView(ModelView, model=models.Location): - name = "Location" - name_plural = "Locations" - category = "Organization" - icon = "fa-solid fa-buildings" - - column_list = [ - models.Location.name, - models.Location.site, - models.Location.location_type, - models.Location.status, - models.Location.created_at, - models.Location.updated_at, - models.Location.created_by, - models.Location.updated_by, - ] - - column_sortable_list = [models.Location.name] - column_filters = [models.Location.name] - page_size = 20 - page_size_options = [20, 50, 100, 200] diff --git a/backend/src/libs/countries/en_US.json b/backend/src/libs/countries/en.json similarity index 100% rename from backend/src/libs/countries/en_US.json rename to backend/src/libs/countries/en.json diff --git a/backend/src/libs/countries/zh_CN.json b/backend/src/libs/countries/zh.json similarity index 100% rename from backend/src/libs/countries/zh_CN.json rename to backend/src/libs/countries/zh.json diff --git a/backend/tests/libs/test_country_sdk.py b/backend/tests/libs/test_country_sdk.py index 96b2530..dd5e819 100644 --- a/backend/tests/libs/test_country_sdk.py +++ b/backend/tests/libs/test_country_sdk.py @@ -6,10 +6,10 @@ @pytest.mark.parametrize( ("name", "language", "expected"), [ - ("中国", "zh_CN", {"code": "CN", "name": "中国", "visible_name": "中国 (CN)", "timezone": 8}), + ("中国", "zh", {"code": "CN", "name": "中国", "visible_name": "中国 (CN)", "timezone": 8}), ( "United States", - "en_US", + "en", {"code": "US", "name": "United States", "visible_name": "United States (US)", "timezone": -6}, ), ],