import uuid


def generate_dcos_engine_template(
        linux_ssh_public_key: str,
        num_masters: int,
        master_vm_size: str,
        num_windows_private_agents: int,
        windows_private_vm_size: str,
        num_windows_public_agents: int,
        windows_public_vm_size: str,
        num_linux_private_agents: int,
        linux_private_vm_size: str,
        num_linux_public_agents: int,
        linux_public_vm_size: str,
        windows_admin_user: str,
        windows_admin_password: str,
        linux_admin_user: str,
        dcos_engine_orchestrator_release: str,
        ):
    """ Generates the template provided to dcos-engine
    """
    unique_id = str(uuid.uuid4())[:8] + 'dcos'
    template = {
        "apiVersion": "vlabs",
        "properties": {
            "orchestratorProfile": {
                "orchestratorType": "DCOS",
                "orchestratorRelease": dcos_engine_orchestrator_release
            },
            "masterProfile": {
                "count": num_masters,
                "dnsPrefix": "master" + unique_id,
                "vmSize": master_vm_size
            },
            "agentPoolProfiles": [
                {
                    "name": "wpub",
                    "count": num_windows_public_agents,
                    "vmSize": windows_public_vm_size,
                    "osType": "Windows",
                    "dnsPrefix": "wpub" + unique_id,
                    "ports": [80, 443, 8080, 3389]
                },
                {
                    "name": "wpri",
                    "count": num_windows_private_agents,
                    "vmSize": windows_private_vm_size,
                    "osType": "Windows",
                },
                {
                    "name": "linpub",
                    "count": num_linux_public_agents,
                    "vmSize": linux_public_vm_size,
                    "osType": "Linux",
                    "dnsPrefix": "linpub" + unique_id,
                    "ports": [80, 443, 22]
                },
                {
                    "name": "linpri",
                    "count": num_linux_private_agents,
                    "vmSize": linux_private_vm_size,
                    "osType": "Linux"
                }
            ],
            "windowsProfile": {
                "adminUsername": windows_admin_user,
                "adminPassword": windows_admin_password
            },
            "linuxProfile": {
                "adminUsername": linux_admin_user,
                "ssh": {
                    "publicKeys": [
                        {
                            "keyData": linux_ssh_public_key
                        }
                    ]
                }
            }
        }
    }
    return template