def _get_create_glossary_term(self, term_name: str) -> Union[AtlasGlossaryTerm, AtlasEntityHeader]: """ Since Atlas does not provide any API to find a term directly by a qualified name, we need to look for AtlasGlossaryTerm via basic search, if found then return, else create a new glossary term under the user defined glossary. :param term_name: Name of the term. NOTE: this is different from qualified name. :return: Term Object. """ params = { 'typeName': "AtlasGlossaryTerm", 'excludeDeletedEntities': True, 'includeSubTypes': True, 'attributes': ["assignedEntities", ], 'entityFilters': {'condition': "AND", 'criterion': [{'attributeName': "name", 'operator': "=", 'attributeValue': term_name}] } } result = self.client.discovery.faceted_search(search_parameters=params) if result.approximateCount: term = result.entities[0] else: glossary_guid = self._get_user_defined_glossary_guid() glossary_def = AtlasGlossaryHeader({'glossaryGuid': glossary_guid}) term_def = AtlasGlossaryTerm({'name': term_name, 'anchor': glossary_def}) term = self.client.glossary.create_glossary_term(term_def) return term
def _create_glossary_terms(self, glossary_terms: List[Dict]) -> None: for glossary_term_spec in glossary_terms: glossary_name = glossary_term_spec.get('glossary') term_name = glossary_term_spec.get('term') glossary_def = AtlasGlossary({ 'name': glossary_name, 'shortDescription': '' }) try: glossary = self._atlas_client.glossary.create_glossary( glossary_def) except AtlasServiceException: LOGGER.info(f'Glossary: {glossary_name} already exists.') glossary = next( filter(lambda x: x.get('name') == glossary_name, self._atlas_client.glossary.get_all_glossaries())) glossary_guid = glossary['guid'] glossary_def = AtlasGlossaryHeader({'glossaryGuid': glossary_guid}) term_def = AtlasGlossaryTerm({ 'name': term_name, 'anchor': glossary_def }) try: self._atlas_client.glossary.create_glossary_term(term_def) except AtlasServiceException: LOGGER.info(f'Glossary Term: {term_name} already exists.')
def create_glossary_term(self): header = AtlasGlossaryHeader(self.emp_glossary.guid, None, self.emp_glossary.name) term = AtlasGlossaryTerm(None, None, "EmpSalaryTerm", None, None, None, None, None, None, None, header) self.emp_salary_term = self.client.glossary.create_glossary_term(term) if self.emp_salary_term: LOG.info("Created Term for Employee Salary: %s with guid: %s", self.emp_salary_term.name, self.emp_salary_term.guid)
def create_glossary_term(self): header = AtlasGlossaryHeader({ 'glossaryGuid': self.emp_glossary.guid, 'displayText': self.emp_glossary.name }) term = AtlasGlossaryTerm({'name': 'EmpSalaryTerm', 'anchor': header}) self.emp_salary_term = self.client.glossary.create_glossary_term(term) if self.emp_salary_term: LOG.info("Created Term for Employee Salary: %s with guid: %s", self.emp_salary_term.name, self.emp_salary_term.guid)
def create_glossary_category(self): header = AtlasGlossaryHeader(self.emp_glossary.guid, None, self.emp_glossary.name) category = AtlasGlossaryCategory(None, None, "EmpSalaryCategory", None, None, None, None, header) self.emp_company_category = self.client.glossary.create_glossary_category( category) if self.emp_company_category: LOG.info( "Created Category for Employee Category: %s with guid: %s", self.emp_company_category.name, self.emp_company_category.guid)
def create_glossary_category(self): header = AtlasGlossaryHeader({ 'glossaryGuid': self.emp_glossary.guid, 'displayText': self.emp_glossary.name }) category = AtlasGlossaryCategory({ 'name': 'EmpSalaryCategory', 'anchor': header }) self.emp_company_category = self.client.glossary.create_glossary_category( category) if self.emp_company_category: LOG.info( "Created Category for Employee Category: %s with guid: %s", self.emp_company_category.name, self.emp_company_category.guid)