示例#1
0
 def action() -> Tenant:
     # noinspection PyTypeChecker
     tenant: Tenant = tenant_service.delete(tenant_id)
     if tenant is None:
         raise_404()
     CacheService.tenant().remove(tenant_id)
     return tenant
    def find_by_id(self, tenant_id: TenantId) -> Optional[Tenant]:
        tenant = CacheService.tenant().get(tenant_id)
        if tenant is not None:
            return tenant

        storage_service = TenantStorageService(ask_meta_storage(),
                                               ask_snowflake_generator(),
                                               self.principalService)
        storage_service.begin_transaction()
        try:
            # noinspection PyTypeChecker
            tenant: Tenant = storage_service.find_by_id(tenant_id)
            if tenant is None:
                return None

            CacheService.tenant().put(tenant)
            return tenant
        finally:
            storage_service.close_transaction()
示例#3
0
 def action(a_tenant: Tenant) -> Tenant:
     if tenant_service.is_storable_id_faked(a_tenant.tenantId):
         tenant_service.redress_storable_id(a_tenant)
         # noinspection PyTypeChecker
         a_tenant: Tenant = tenant_service.create(a_tenant)
         if ask_create_pipeline_monitor_topics_on_tenant_create():
             topics = ask_pipeline_monitor_topics()
             create_topics_and_pipelines(
                 topics, lambda source_topics:
                 ask_pipeline_monitor_pipelines(source_topics),
                 a_tenant.tenantId, tenant_service, principal_service)
         if ask_create_dqc_topics_on_tenant_create():
             topics = ask_dqc_topics()
             create_topics_and_pipelines(
                 topics,
                 lambda source_topics: ask_dqc_pipelines(source_topics),
                 a_tenant.tenantId, tenant_service, principal_service)
     else:
         # noinspection PyTypeChecker
         a_tenant: Tenant = tenant_service.update(a_tenant)
     CacheService.tenant().put(a_tenant)
     return a_tenant
async def clear_all_tenants_cache(
        principal_service: PrincipalService = Depends(
            get_super_admin_principal)) -> None:
    CacheService.tenant().clear()