import 'dart:convert';

class StorageData {
  static final StorageData _storages = StorageData._internal();
  late final List<dynamic> _data;

  /// Informace o úložištích ve formátu JSON
  ///
  /// Jednotlivé prvky jsou uspořádány dle priority, poslední je tedy nejobecnější.
  /// Všechny prvky jsou povinné, jejich hodnoty mohou být však prázdné.
  /// name - unikátní identifikátor, používá se pro ladění
  /// fqdn - hlavní hostname storage
  /// match_host - regex pro určení zda tyto data odpovídají danému hostovi
  /// match_path - regex pro zachycení dle cesty
  /// scpDirect - umožňuje kopírovat přímo mezi poli, nutný správně nastavený jailkit
  /// scpRemote - umožňuje kopírování metodou SCP z/na pole
  /// copy - podporuje normální kopírování, typicky do NFS
  /// nfsMounts - pole (první prvek primární) prefixů, které se používají pro připojení úložiště
  static const _jsonArray = r'''
    [
      {
        "name": "brno1-cerit",
        "fqdn": "storage-brno1-cerit.metacentrum.cz",
        "match_host": "^storage-brno1-cerit.*",
        "match_path": "^/(auto|storage)/brno1-cerit/.*",
        "scpDirect": false,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/brno1-cerit", "/auto/brno1-cerit" ]      
      },     
      {
        "name": "brno2",
        "fqdn": "storage-brno2.metacentrum.cz",
        "match_host": "^storage-brno2.*",
        "match_path": "^/(auto|storage)/brno2/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/brno2", "/auto/brno2" ]
      },
      {
        "name": "brno3-cerit",
        "fqdn": "storage-brno3-cerit.metacentrum.cz",
        "match_host": "^storage-brno3-cerit.*",
        "match_path": "^/(auto|storage)/brno3-cerit/.*",
        "scpDirect": false,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/brno3-cerit", "/auto/brno3-cerit" ]
      },      
      {
        "name": "brno11-elixir",
        "fqdn": "storage-brno11-elixir.metacentrum.cz",
        "match_host": "^storage-brno11-elixir.*",
        "match_path": "^/(auto|storage)/brno11-elixir/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/brno11-elixir", "/auto/brno11-elixir" ]
      },
      {
        "name": "brno12-cerit",
        "fqdn": "storage-brno12-cerit.metacentrum.cz",
        "match_host": "^storage-brno12-cerit.*",
        "match_path": "^/(auto|storage)/brno12-cerit/.*",
        "scpDirect": false,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/brno12-cerit", "/auto/brno12-cerit" ]
      },      
      {
        "name": "brno14-ceitec",
        "fqdn": "storage-brno14-ceitec.metacentrum.cz",
        "match_host": "^storage-brno14-ceitec.*",
        "match_path": "^/(auto|storage)/brno14-ceitec/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/brno14-ceitec", "/auto/brno14-ceitec" ]
      },
      {
        "name": "budejovice1",
        "fqdn": "storage-budejovice1.metacentrum.cz",
        "match_host": "^storage-budejovice1.*",
        "match_path": "^/(auto|storage)/budejovice1/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/budejovice1", "/auto/budejovice1" ]
      },      
      {
        "name": "liberec3-tul",
        "fqdn": "storage-liberec3-tul.metacentrum.cz",
        "match_host": "^storage-liberec3-tul.*",
        "match_path": "^/(auto|storage)/liberec3-tul/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/liberec3-tul", "/auto/liberec3-tul" ]
      },     
      {
        "name": "plzen1",
        "fqdn": "storage-plzen1.metacentrum.cz",
        "match_host": "^storage-plzen1.*",
        "match_path": "^/(auto|storage)/plzen1/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/plzen1", "/auto/plzen1" ]
      },
      {
        "name": "plzen4-ntis",
        "fqdn": "storage-plzen4.ntis.zcu.cz",
        "match_host": "^storage-plzen4.*",
        "match_path": "^/(auto|storage)/plzen4-ntis/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/plzen4-ntis", "/auto/plzen4-ntis" ]
      },
      {
        "name": "vestec1",
        "fqdn": "storage-vestec1-elixir.metacentrum.cz",
        "match_host": "^storage-praha1.*",
        "match_path": "^/(auto|storage)/praha1/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/praha1", "/auto/praha1" ]
      },
      {
        "name": "praha2-natur",
        "fqdn": "storage-praha2-natur.metacentrum.cz",
        "match_host": "^storage-praha2.*",
        "match_path": "^/(auto|storage)/praha2-natur/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/praha2-natur", "/auto/praha2-natur" ]
      },
      {
        "name": "praha5-elixir",
        "fqdn": "storage-praha5-elixir.metacentrum.cz",
        "match_host": "^storage-praha5-elixir.*",
        "match_path": "^/(auto|storage)/praha5-elixir/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/praha5-elixir", "/auto/praha5-elixir" ]
      },
      {
        "name": "praha6-fzu",
        "fqdn": "storage-praha6-fzu.metacentrum.cz",
        "match_host": "^storage-praha6-fzu.*",
        "match_path": "^/(auto|storage)/praha6-fzu/.*",
        "scpDirect": false,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/praha6-fzu", "/auto/praha6-fzu" ]
      },
      {
        "name": "pruhonice1-ibot",
        "fqdn": "storage-pruhonice1-ibot.metacentrum.cz",
        "match_host": "^storage-pruhonice1-ibot.*",
        "match_path": "^/(auto|storage)/pruhonice1-ibot/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/pruhonice1-ibot", "/auto/pruhonice1-ibot" ]
      },
      {
        "name": "vestec1-elixir",
        "fqdn": "storage-vestec1-elixir.metacentrum.cz",
        "match_host": "^storage-vestec1-elixir.*",
        "match_path": "^/(auto|storage)/vestec1-elixir/.*",
        "scpDirect": true,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/vestec1-elixir", "/auto/vestec1-elixir" ]
      },
      {
        "name": "du-cesnet",
        "fqdn": "storage-du-cesnet.metacentrum.cz",
        "match_host": "^storage-du-cesnet.*",
        "match_path": "^/(auto|storage)/du-cesnet/.*",
        "scpDirect": false,
        "scpRemote": true,
        "copy": true,
        "nfsMounts": [ "/storage/du-cesnet", "/auto/du-cesnet" ]
      },                 
      {
        "name": "local_filesystem",
        "fqdn": "",
        "match_host": "^$",
        "match_path": "^.+$",
        "scpDirect": false,
        "scpRemote": false,
        "copy": true,
        "nfsMounts": [ "" ]
      },      
      {  "name": "unknown_remote",
         "fqdn": "",
         "match_host": "^\\S+$",
         "match_path": "^.+$",
         "scpDirect": false,
         "scpRemote": false,
         "copy": false,
         "nfsMounts": [ "" ]
      }
    ]
    ''';

  factory StorageData() {
    return _storages;
  }

  StorageData._internal() {
    _data = jsonDecode(_jsonArray);
  }

  List<dynamic> getData() {
    return _data;
  }
}