5
5
from typing import (Any , Dict , List , Optional , Tuple , Union , # noqa: F401
6
6
no_type_check )
7
7
8
+ import neo4j
8
9
from amundsen_common .models .dashboard import DashboardSummary
9
10
from amundsen_common .models .popular_table import PopularTable
10
11
from amundsen_common .models .table import (Application , Column , Reader , Source ,
14
15
from amundsen_common .models .user import User as UserEntity
15
16
from beaker .cache import CacheManager
16
17
from beaker .util import parse_cache_config_options
18
+ from flask import current_app , has_app_context
17
19
from neo4j import BoltStatementResult , Driver , GraphDatabase # noqa: F401
18
- import neo4j
19
20
21
+ from metadata_service import config
20
22
from metadata_service .entity .dashboard_detail import DashboardDetail as DashboardDetailEntity
21
23
from metadata_service .entity .dashboard_query import DashboardQuery as DashboardQueryEntity
22
24
from metadata_service .entity .description import Description
@@ -60,6 +62,7 @@ def __init__(self, *,
60
62
value needs to be smaller than surrounding network environment's timeout.
61
63
"""
62
64
endpoint = f'{ host } :{ port } '
65
+ LOGGER .info ('NEO4J endpoint: {}' .format (endpoint ))
63
66
trust = neo4j .TRUST_SYSTEM_CA_SIGNED_CERTIFICATES if validate_ssl else neo4j .TRUST_ALL_CERTIFICATES
64
67
self ._driver = GraphDatabase .driver (endpoint , max_connection_pool_size = num_conns ,
65
68
connection_timeout = 10 ,
@@ -817,6 +820,19 @@ def get_users(self) -> List[UserEntity]:
817
820
818
821
@staticmethod
819
822
def _build_user_from_record (record : dict , manager_name : str = '' ) -> UserEntity :
823
+ """
824
+ Builds user record from Cypher query result. Other than the one defined in amundsen_common.models.user.User,
825
+ you could add more fields from User node into the User model by specifying keys in config.USER_OTHER_KEYS
826
+ :param record:
827
+ :param manager_name:
828
+ :return:
829
+ """
830
+ other_key_values = {}
831
+ if has_app_context () and current_app .config [config .USER_OTHER_KEYS ]:
832
+ for k in current_app .config [config .USER_OTHER_KEYS ]:
833
+ if k in record :
834
+ other_key_values [k ] = record [k ]
835
+
820
836
return UserEntity (email = record ['email' ],
821
837
first_name = record .get ('first_name' ),
822
838
last_name = record .get ('last_name' ),
@@ -827,7 +843,8 @@ def _build_user_from_record(record: dict, manager_name: str = '') -> UserEntity:
827
843
slack_id = record .get ('slack_id' ),
828
844
employee_type = record .get ('employee_type' ),
829
845
role_name = record .get ('role_name' ),
830
- manager_fullname = record .get ('manager_fullname' , manager_name ))
846
+ manager_fullname = record .get ('manager_fullname' , manager_name ),
847
+ other_key_values = other_key_values )
831
848
832
849
@staticmethod
833
850
def _get_user_resource_relationship_clause (relation_type : UserResourceRel , id : str = None ,
0 commit comments