from diagrams import Cluster, Diagram

from diagrams.azure.database import DatabaseForMariadbServers
from diagrams.onprem.inmemory import Redis
from diagrams.onprem.container import Docker
from diagrams.onprem.network import Nginx, Internet
from diagrams.onprem.groupware import Nextcloud
import diagrams.generic.storage as storage_1
import diagrams.outscale.storage as storage_2
from diagrams.azure.identity import Groups

with Diagram(filename="./assets/dia_nc_pelican", show=False):
    out = Internet("Internet")
    ldap = Groups("LDAP")
    nfs = storage_1.Storage("NFS")

    with Cluster("Interactive workstation"):
        local_storage = storage_2.Storage("local storage")

        with Cluster("Containers"):
            docker = Docker("Docker")

            with Cluster("SSL Proxy"):
                proxy = Nginx("Nginx")

            with Cluster("Web server"):
                nc_frontend = Nextcloud()
                ldap >> nc_frontend << nfs            

            with Cluster("Database"):
                nc_db = DatabaseForMariadbServers("MariaDB")
                nc_frontend << nc_db

            with Cluster("Caching"):
                nc_redis = Redis("Redis")
                nc_frontend << nc_redis

        nc_frontend << local_storage
      
    out >> proxy >> nc_frontend
    out << proxy << nc_frontend
    