# Info: KCL AWS provider server schemas for provisioning (Provisioning)
# Author: JesusPerezLorenzo
# Release: 0.0.4
# Date: 1-04-2024
import regex
import .defaults_aws as defaults

schema Provision_env_aws:
    """
    AWS provision env data settings
    """
    vpc: str
    subnet: str
    cidr_block: str
    avail_zone: str
    # aws security group
    sg?: defaults.SecurityGroup

    check:
        len(vpc) > 0, "Check VPC value"
        len(subnet) > 0, "Check Subnet value"
        len(avail_zone) > 0, "Check availability Zone value"
        len(cidr_block) == 0 or regex.match(cidr_block, "^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}\/(?:3[0-2]|[0-2]?[0-9])$"), "'cidr_block = ${cidr_block}' check value definition"

schema Provision_aws:
    """
    AWS provision data settings
    """
    # Main settings data
    main: Provision_env_aws
    # Privaten settings data
    priv?: Provision_env_aws

