public bool CreateTenant(string tenantName, TenantSettings tenantSettings) { List <TenantConfiguration> tenants = TenantIOReader.ReadTenantsFromConfigFile(); var tenant = tenants.Find(x => x.Name == tenantName); if (tenant != null) { return(false); } var tenantConfiguration = new TenantConfiguration() { Name = tenantName, Settings = tenantSettings }; tenants.Add(tenantConfiguration); if (TenantIOWriter.WriteTenantsConfiguration(tenants) == true) { _tenantRepository.AddTenantFromApi(tenantConfiguration); _storageHubService.CreateTenantAsync(_tenantFactory .CreateTenant(tenantConfiguration.Name, tenantConfiguration.Settings.DigitalSignature, tenantConfiguration.Settings.EnableEncryption, tenantConfiguration.Settings.AllowProductCreation, tenantConfiguration.Settings.EnableAuthorization, tenantConfiguration.Settings.Tokens, tenantConfiguration.Settings.Logging, tenantConfiguration.Settings.EnableGeoReplication, tenantConfiguration.Settings.CertificatePath)); return(true); } return(false); }
public void AddTenantFromApi(TenantConfiguration tenantConfig) { AddTenant(tenantConfig.Name, tenantFactory .CreateTenant(tenantConfig.Name, tenantConfig.Settings.DigitalSignature, tenantConfig.Settings.EnableEncryption, tenantConfig.Settings.AllowProductCreation, tenantConfig.Settings.EnableAuthorization, tenantConfig.Settings.Tokens, tenantConfig.Settings.Logging, tenantConfig.Settings.EnableGeoReplication, tenantConfig.Settings.CertificatePath)); // add products tenantConfig.Products.ForEach(product => { AddProduct(tenantConfig.Name, product.Name, tenantFactory.CreateProduct(product.Name)); // add components of product product.Components.ForEach(component => { AddComponent(tenantConfig.Name, product.Name, component.Name, tenantFactory.CreateComponent(component.Name, component.Settings.AllowSchemaValidation, component.Settings.AllowTopicCreation, component.Settings.EnableAuthorization, component.Settings.Tokens)); // Add topics from configuration component.Topics.ForEach(topic => { AddTopic(tenantConfig.Name, product.Name, component.Name, topic.Name, tenantFactory.CreateTopic(topic.Name)); }); }); }); }