mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-11-04 12:51:23 +00:00 
			
		
		
		
	Co-authored-by: Hyejin Yoon <yoonhyejin@Hyejins-MacBook-Pro.local> Co-authored-by: Shirshanka Das <shirshanka@apache.org>
		
			
				
	
	
		
			28 lines
		
	
	
		
			759 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			759 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import logging
 | 
						|
 | 
						|
from datahub.api.entities.corpuser.corpuser import CorpUser, CorpUserGenerationConfig
 | 
						|
from datahub.ingestion.graph.client import DataHubGraph, DataHubGraphConfig
 | 
						|
 | 
						|
log = logging.getLogger(__name__)
 | 
						|
logging.basicConfig(level=logging.INFO)
 | 
						|
 | 
						|
user_email = "bar@acryl.io"
 | 
						|
 | 
						|
user: CorpUser = CorpUser(
 | 
						|
    id=user_email,
 | 
						|
    display_name="The Bar",
 | 
						|
    email=user_email,
 | 
						|
    title="Software Engineer",
 | 
						|
    first_name="The",
 | 
						|
    last_name="Bar",
 | 
						|
    full_name="The Bar",
 | 
						|
)
 | 
						|
 | 
						|
# Create graph client
 | 
						|
datahub_graph = DataHubGraph(DataHubGraphConfig(server="http://localhost:8080"))
 | 
						|
for event in user.generate_mcp(
 | 
						|
    generation_config=CorpUserGenerationConfig(override_editable=False)
 | 
						|
):
 | 
						|
    datahub_graph.emit(event)
 | 
						|
log.info(f"Upserted user {user.urn}")
 |