Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
initial work for feature templates documentation for ansible generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cicharka committed Apr 23, 2024
1 parent 25689b7 commit f3ecbba
Showing 1 changed file with 85 additions and 36 deletions.
121 changes: 85 additions & 36 deletions catalystwan/api/templates/models/cisco_aaa_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,58 @@


class User(FeatureTemplateValidator):
name: str
password: Optional[str] = None
secret: Optional[str] = None
privilege: Optional[str] = None
pubkey_chain: List[str] = Field(default=[], json_schema_extra={"vmanage_key": "pubkey-chain", "vip_type": "ignore"})
name: str = Field(description="The name of the user")
password: Optional[str] = Field(default=None, description="The password for the user")
secret: Optional[str] = Field(default=None, description="The secret for the user")
privilege: Optional[str] = Field(default=None, description="The privilege level for the user")
pubkey_chain: List[str] = Field(
default=[],
json_schema_extra={"vmanage_key": "pubkey-chain", "vip_type": "ignore"},
description="List of public keys for the user",
)


class RadiusServer(FeatureTemplateValidator):
model_config = ConfigDict(populate_by_name=True, coerce_numbers_to_str=True)

address: str
auth_port: int = Field(default=1812, json_schema_extra={"vmanage_key": "auth-port"})
acct_port: int = Field(default=1813, json_schema_extra={"vmanage_key": "acct-port"})
timeout: int = Field(default=5)
retransmit: int = 3
key: str
secret_key: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "secret-key"})
key_enum: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "key-enum"})
key_type: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "key-type"})
address: str = Field(description="The IP address or hostname of the RADIUS server")
auth_port: int = Field(
default=1812,
json_schema_extra={"vmanage_key": "auth-port"},
description="The authentication port for the RADIUS server",
)
acct_port: int = Field(
default=1813,
json_schema_extra={"vmanage_key": "acct-port"},
description="The accounting port for the RADIUS server",
)
timeout: int = Field(default=5, description="The timeout period in seconds for the RADIUS server")
retransmit: int = Field(default=3, description="The number of retransmit attempts for the RADIUS server")
key: str = Field(description="The key for the RADIUS server")
secret_key: Optional[str] = Field(
default=None,
json_schema_extra={"vmanage_key": "secret-key"},
description="The secret key for the RADIUS server",
)
key_enum: Optional[str] = Field(
default=None,
json_schema_extra={"vmanage_key": "key-enum"},
description="The key enumeration for the RADIUS server",
)
key_type: Optional[str] = Field(
default=None, json_schema_extra={"vmanage_key": "key-type"}, description="The key type for the RADIUS server"
)


class RadiusGroup(FeatureTemplateValidator):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)

group_name: str = Field(json_schema_extra={"vmanage_key": "group-name"})
vpn: Optional[int] = None
source_interface: Optional[str] = Field(json_schema_extra={"vmanage_key": "source-interface"})
server: List[RadiusServer] = []
group_name: str = Field(json_schema_extra={"vmanage_key": "group-name"}, description="The name of the RADIUS group")
vpn: Optional[int] = Field(description="The VPN ID for the RADIUS group")
source_interface: Optional[str] = Field(
json_schema_extra={"vmanage_key": "source-interface"}, description="The source interface for the RADIUS group"
)
server: List[RadiusServer] = Field(default=[], description="The list of RADIUS servers for the group")


class DomainStripping(str, Enum):
Expand All @@ -49,36 +73,61 @@ class DomainStripping(str, Enum):
class TacacsServer(FeatureTemplateValidator):
model_config = ConfigDict(populate_by_name=True)

address: str
port: int = 49
timeout: int = Field(default=5)
key: str
secret_key: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "secret-key"})
key_enum: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "key-enum"})
address: str = Field(description="The IP address or hostname of the TACACS+ server")
port: int = Field(default=49, description="The port for the TACACS+ server")
timeout: int = Field(default=5, description="The timeout period in seconds for the TACACS+ server")
key: str = Field(description="The key for the TACACS+ server")
secret_key: Optional[str] = Field(
default=None,
json_schema_extra={"vmanage_key": "secret-key"},
description="The secret key for the TACACS+ server",
)
key_enum: Optional[str] = Field(
default=None,
json_schema_extra={"vmanage_key": "key-enum"},
description="The key enumeration for the TACACS+ server",
)


class TacacsGroup(FeatureTemplateValidator):
model_config = ConfigDict(populate_by_name=True)

group_name: str = Field(json_schema_extra={"vmanage_key": "group-name"})
vpn: int = 0
source_interface: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "source-interface"})
server: List[TacacsServer] = []
group_name: str = Field(
json_schema_extra={"vmanage_key": "group-name"}, description="The name of the TACACS+ group"
)
vpn: int = Field(default=0, description="The VPN ID for the TACACS+ group")
source_interface: Optional[str] = Field(
default=None,
json_schema_extra={"vmanage_key": "source-interface"},
description="The source interface for the TACACS+ group",
)
server: List[TacacsServer] = Field(default=[], description="The list of TACACS+ servers for the group")


class CiscoAAAModel(FeatureTemplate):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
docs_description: str = Field(exclude=True, description="Cisco AAA Feature Template configuration.")

user: Optional[List[User]] = None
authentication_group: bool = Field(default=False, json_schema_extra={"vmanage_key": "authentication_group"})
accounting_group: bool = True
radius: Optional[List[RadiusGroup]] = None
user: Optional[List[User]] = Field(default=False, description="List of user configurations")
authentication_group: bool = Field(
default=False,
json_schema_extra={"vmanage_key": "authentication_group"},
description="Whether to enable the authentication group",
)
accounting_group: bool = Field(default=True, description="Whether to enable the accounting group")
radius: Optional[List[RadiusGroup]] = Field(default=None, description="List of Radius group configurations")
domain_stripping: Optional[DomainStripping] = Field(
default=None, json_schema_extra={"vmanage_key": "domain-stripping"}
default=None,
json_schema_extra={"vmanage_key": "domain-stripping"},
description="The domain stripping configuration",
)
port: int = Field(default=1700, description="The port number for AAA")
tacacs: Optional[List[TacacsGroup]] = Field(default=None, description="List of TACACS group configurations")
server_auth_order: str = Field(
default="local",
json_schema_extra={"vmanage_key": "server-auth-order"},
description="Authentication order to user access",
)
port: int = 1700
tacacs: Optional[List[TacacsGroup]] = None
server_auth_order: str = Field(default="local", json_schema_extra={"vmanage_key": "server-auth-order"})

payload_path: ClassVar[Path] = Path(__file__).parent / "DEPRECATED"
type: ClassVar[str] = "cedge_aaa"

0 comments on commit f3ecbba

Please sign in to comment.