You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2020/12/29 02:25:39 UTC
[atlas] branch master updated: ATLAS-4089: refactor Python Atlas
Client to PEP8
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new a11d59f ATLAS-4089: refactor Python Atlas Client to PEP8
a11d59f is described below
commit a11d59f7a7f0fad96f153c161525a05881c5bf66
Author: Mariusz Górski <go...@gmail.com>
AuthorDate: Mon Dec 28 17:30:32 2020 -0800
ATLAS-4089: refactor Python Atlas Client to PEP8
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
---
intg/src/main/python/Makefile | 13 ++
intg/src/main/python/apache_atlas/__init__.py | 7 +-
.../main/python/apache_atlas/client/__init__.py | 3 +-
intg/src/main/python/apache_atlas/client/admin.py | 11 +-
.../main/python/apache_atlas/client/base_client.py | 65 ++++----
.../main/python/apache_atlas/client/discovery.py | 89 ++++++-----
intg/src/main/python/apache_atlas/client/entity.py | 177 +++++++++++++--------
.../main/python/apache_atlas/client/glossary.py | 176 +++++++++++---------
.../src/main/python/apache_atlas/client/lineage.py | 22 +--
.../python/apache_atlas/client/relationship.py | 34 ++--
.../src/main/python/apache_atlas/client/typedef.py | 53 +++---
intg/src/main/python/apache_atlas/exceptions.py | 11 +-
.../src/main/python/apache_atlas/model/__init__.py | 3 +-
intg/src/main/python/apache_atlas/model/admin.py | 10 +-
.../main/python/apache_atlas/model/discovery.py | 104 ++++++------
intg/src/main/python/apache_atlas/model/enums.py | 110 +++++++------
.../src/main/python/apache_atlas/model/glossary.py | 136 ++++++++--------
.../src/main/python/apache_atlas/model/instance.py | 118 +++++++-------
intg/src/main/python/apache_atlas/model/lineage.py | 23 ++-
intg/src/main/python/apache_atlas/model/misc.py | 26 +--
intg/src/main/python/apache_atlas/model/profile.py | 15 +-
.../main/python/apache_atlas/model/relationship.py | 53 +++---
intg/src/main/python/apache_atlas/model/typedef.py | 132 ++++++++-------
intg/src/main/python/apache_atlas/utils.py | 48 +++---
intg/src/main/python/requirements-dev.txt | 2 +
intg/src/main/python/setup.py | 2 +-
intg/src/main/python/tox.ini | 2 +
27 files changed, 780 insertions(+), 665 deletions(-)
diff --git a/intg/src/main/python/Makefile b/intg/src/main/python/Makefile
new file mode 100644
index 0000000..b204e01
--- /dev/null
+++ b/intg/src/main/python/Makefile
@@ -0,0 +1,13 @@
+.PHONY: test_unit
+test_unit:
+ python3 -b -m pytest tests
+
+lint:
+ python3 -m flake8
+
+.PHONY: mypy
+mypy:
+ mypy --ignore-missing-imports --follow-imports=skip --strict-optional --warn-no-return .
+
+.PHONY: test
+test: lint mypy
diff --git a/intg/src/main/python/apache_atlas/__init__.py b/intg/src/main/python/apache_atlas/__init__.py
index 4aa54b8..0c9069a 100644
--- a/intg/src/main/python/apache_atlas/__init__.py
+++ b/intg/src/main/python/apache_atlas/__init__.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,15 +15,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
import logging
from logging.config import dictConfig
logging_config = dict(
version=1,
formatters={
- 'f': {'format':
- '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'}
+ 'f': {'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'}
},
handlers={
'h': {'class': 'logging.StreamHandler',
@@ -39,4 +36,4 @@ logging_config = dict(
dictConfig(logging_config)
-logger = logging.getLogger()
\ No newline at end of file
+logger = logging.getLogger()
diff --git a/intg/src/main/python/apache_atlas/client/__init__.py b/intg/src/main/python/apache_atlas/client/__init__.py
index f115594..d9984f1 100644
--- a/intg/src/main/python/apache_atlas/client/__init__.py
+++ b/intg/src/main/python/apache_atlas/client/__init__.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -15,4 +14,4 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
-# limitations under the License.
\ No newline at end of file
+# limitations under the License.
diff --git a/intg/src/main/python/apache_atlas/client/admin.py b/intg/src/main/python/apache_atlas/client/admin.py
index 171bcf8..ebe72dc 100644
--- a/intg/src/main/python/apache_atlas/client/admin.py
+++ b/intg/src/main/python/apache_atlas/client/admin.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,15 +15,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.admin import *
-from apache_atlas.utils import *
+from apache_atlas.model.admin import AtlasAdminMetrics
+from apache_atlas.utils import API
+from apache_atlas.utils import BASE_URI
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
class AdminClient:
BASE_ADMIN_URL = BASE_URI + "admin/"
- GET_METRICS_API = API(BASE_ADMIN_URL + "metrics", HttpMethod.GET, HTTPStatus.OK)
+ GET_METRICS_API = API(BASE_ADMIN_URL + "metrics", HTTPMethod.GET, HTTPStatus.OK)
def __init__(self, client):
self.client = client
diff --git a/intg/src/main/python/apache_atlas/client/base_client.py b/intg/src/main/python/apache_atlas/client/base_client.py
index fe0ddf4..2402611 100644
--- a/intg/src/main/python/apache_atlas/client/base_client.py
+++ b/intg/src/main/python/apache_atlas/client/base_client.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,55 +15,57 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
import copy
-import os
import json
import logging
+import os
+
+from requests import Session
-from requests import Session
-from apache_atlas.client.discovery import DiscoveryClient
-from apache_atlas.client.entity import EntityClient
-from apache_atlas.client.glossary import GlossaryClient
-from apache_atlas.client.lineage import LineageClient
+from apache_atlas.client.admin import AdminClient
+from apache_atlas.client.discovery import DiscoveryClient
+from apache_atlas.client.entity import EntityClient
+from apache_atlas.client.glossary import GlossaryClient
+from apache_atlas.client.lineage import LineageClient
from apache_atlas.client.relationship import RelationshipClient
-from apache_atlas.client.admin import AdminClient
-from apache_atlas.client.typedef import TypeDefClient
-from apache_atlas.exceptions import AtlasServiceException
-from apache_atlas.utils import HttpMethod, HTTPStatus, type_coerce
+from apache_atlas.client.typedef import TypeDefClient
+from apache_atlas.exceptions import AtlasServiceException
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
+from apache_atlas.utils import type_coerce
LOG = logging.getLogger('apache_atlas')
class AtlasClient:
def __init__(self, host, auth):
- session = Session()
+ session = Session()
session.auth = auth
- self.host = host
- self.session = session
+ self.host = host
+ self.session = session
self.request_params = {'headers': {}}
- self.typedef = TypeDefClient(self)
- self.entity = EntityClient(self)
- self.lineage = LineageClient(self)
- self.discovery = DiscoveryClient(self)
- self.glossary = GlossaryClient(self)
- self.relationship = RelationshipClient(self)
- self.admin = AdminClient(self)
+ self.typedef = TypeDefClient(self)
+ self.entity = EntityClient(self)
+ self.lineage = LineageClient(self)
+ self.discovery = DiscoveryClient(self)
+ self.glossary = GlossaryClient(self)
+ self.relationship = RelationshipClient(self)
+ self.admin = AdminClient(self)
logging.getLogger("requests").setLevel(logging.WARNING)
def call_api(self, api, response_type=None, query_params=None, request_obj=None):
params = copy.deepcopy(self.request_params)
- path = os.path.join(self.host, api.path)
+ path = os.path.join(self.host, api.path)
- params['headers']['Accept'] = api.consumes
+ params['headers']['Accept'] = api.consumes
params['headers']['Content-type'] = api.produces
- if query_params:
+ if query_params is not None:
params['params'] = query_params
- if request_obj:
+ if request_obj is not None:
params['data'] = json.dumps(request_obj)
if LOG.isEnabledFor(logging.DEBUG):
@@ -75,13 +76,13 @@ class AtlasClient:
response = None
- if api.method == HttpMethod.GET:
+ if api.method == HTTPMethod.GET:
response = self.session.get(path, **params)
- elif api.method == HttpMethod.POST:
+ elif api.method == HTTPMethod.POST:
response = self.session.post(path, **params)
- elif api.method == HttpMethod.PUT:
+ elif api.method == HTTPMethod.PUT:
response = self.session.put(path, **params)
- elif api.method == HttpMethod.DELETE:
+ elif api.method == HTTPMethod.DELETE:
response = self.session.delete(path, **params)
if response is not None:
@@ -90,11 +91,11 @@ class AtlasClient:
if response is None:
return None
elif response.status_code == api.expected_status:
- if not response_type:
+ if response_type is None:
return None
try:
- if response.content:
+ if response.content is not None:
if LOG.isEnabledFor(logging.DEBUG):
LOG.debug("<== __call_api(%s,%s,%s), result = %s", vars(api), params, request_obj, response)
diff --git a/intg/src/main/python/apache_atlas/client/discovery.py b/intg/src/main/python/apache_atlas/client/discovery.py
index 5bead22..04f5fc9 100644
--- a/intg/src/main/python/apache_atlas/client/discovery.py
+++ b/intg/src/main/python/apache_atlas/client/discovery.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,41 +15,46 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.discovery import *
-from apache_atlas.utils import API, HttpMethod, HTTPStatus
+from apache_atlas.model.discovery import AtlasQuickSearchResult
+from apache_atlas.model.discovery import AtlasSearchResult
+from apache_atlas.model.discovery import AtlasSuggestionsResult
+from apache_atlas.model.discovery import AtlasUserSavedSearch
+from apache_atlas.utils import API
+from apache_atlas.utils import BASE_URI
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
class DiscoveryClient:
- DISCOVERY_URI = BASE_URI + "v2/search"
- DSL_SEARCH_URI = DISCOVERY_URI + "/dsl"
+ DISCOVERY_URI = BASE_URI + "v2/search"
+ DSL_SEARCH_URI = DISCOVERY_URI + "/dsl"
FULL_TEXT_SEARCH_URI = DISCOVERY_URI + "/fulltext"
- BASIC_SEARCH_URI = DISCOVERY_URI + "/basic"
- FACETED_SEARCH_URI = BASIC_SEARCH_URI
- SAVED_SEARCH_URI = DISCOVERY_URI + "/saved"
- QUICK_SEARCH_URI = DISCOVERY_URI + "/quick"
-
- DSL_SEARCH = API(DSL_SEARCH_URI, HttpMethod.GET, HTTPStatus.OK)
- FULL_TEXT_SEARCH = API(FULL_TEXT_SEARCH_URI, HttpMethod.GET, HTTPStatus.OK)
- BASIC_SEARCH = API(BASIC_SEARCH_URI, HttpMethod.GET, HTTPStatus.OK)
- FACETED_SEARCH = API(FACETED_SEARCH_URI, HttpMethod.POST, HTTPStatus.OK)
- ATTRIBUTE_SEARCH = API(DISCOVERY_URI + "/attribute", HttpMethod.GET, HTTPStatus.OK)
- RELATIONSHIP_SEARCH = API(DISCOVERY_URI + "/relationship", HttpMethod.GET, HTTPStatus.OK)
- QUICK_SEARCH_WITH_GET = API(QUICK_SEARCH_URI, HttpMethod.GET, HTTPStatus.OK)
- QUICK_SEARCH_WITH_POST = API(QUICK_SEARCH_URI, HttpMethod.POST, HTTPStatus.OK)
- GET_SUGGESTIONS = API(DISCOVERY_URI + "/suggestions", HttpMethod.GET, HTTPStatus.OK)
+ BASIC_SEARCH_URI = DISCOVERY_URI + "/basic"
+ FACETED_SEARCH_URI = BASIC_SEARCH_URI
+ SAVED_SEARCH_URI = DISCOVERY_URI + "/saved"
+ QUICK_SEARCH_URI = DISCOVERY_URI + "/quick"
+
+ DSL_SEARCH = API(DSL_SEARCH_URI, HTTPMethod.GET, HTTPStatus.OK)
+ FULL_TEXT_SEARCH = API(FULL_TEXT_SEARCH_URI, HTTPMethod.GET, HTTPStatus.OK)
+ BASIC_SEARCH = API(BASIC_SEARCH_URI, HTTPMethod.GET, HTTPStatus.OK)
+ FACETED_SEARCH = API(FACETED_SEARCH_URI, HTTPMethod.POST, HTTPStatus.OK)
+ ATTRIBUTE_SEARCH = API(DISCOVERY_URI + "/attribute", HTTPMethod.GET, HTTPStatus.OK)
+ RELATIONSHIP_SEARCH = API(DISCOVERY_URI + "/relationship", HTTPMethod.GET, HTTPStatus.OK)
+ QUICK_SEARCH_WITH_GET = API(QUICK_SEARCH_URI, HTTPMethod.GET, HTTPStatus.OK)
+ QUICK_SEARCH_WITH_POST = API(QUICK_SEARCH_URI, HTTPMethod.POST, HTTPStatus.OK)
+ GET_SUGGESTIONS = API(DISCOVERY_URI + "/suggestions", HTTPMethod.GET, HTTPStatus.OK)
# Saved Search
- GET_SAVED_SEARCHES = API(SAVED_SEARCH_URI, HttpMethod.GET, HTTPStatus.OK)
- GET_SAVED_SEARCH = API(SAVED_SEARCH_URI + "/{search_name}", HttpMethod.GET, HTTPStatus.OK)
- ADD_SAVED_SEARCH = API(SAVED_SEARCH_URI, HttpMethod.POST, HTTPStatus.OK)
- UPDATE_SAVED_SEARCH = API(SAVED_SEARCH_URI, HttpMethod.PUT, HTTPStatus.OK)
- DELETE_SAVED_SEARCH = API(SAVED_SEARCH_URI + "/{guid}", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- EXECUTE_SAVED_SEARCH_BY_NAME = API(SAVED_SEARCH_URI + "/execute/{search_name}", HttpMethod.GET, HTTPStatus.OK)
- EXECUTE_SAVED_SEARCH_BY_GUID = API(SAVED_SEARCH_URI + "/execute/guid/{search_guid}", HttpMethod.GET, HTTPStatus.OK)
-
- QUERY = "query"
- LIMIT = "limit"
+ GET_SAVED_SEARCHES = API(SAVED_SEARCH_URI, HTTPMethod.GET, HTTPStatus.OK)
+ GET_SAVED_SEARCH = API(SAVED_SEARCH_URI + "/{search_name}", HTTPMethod.GET, HTTPStatus.OK)
+ ADD_SAVED_SEARCH = API(SAVED_SEARCH_URI, HTTPMethod.POST, HTTPStatus.OK)
+ UPDATE_SAVED_SEARCH = API(SAVED_SEARCH_URI, HTTPMethod.PUT, HTTPStatus.OK)
+ DELETE_SAVED_SEARCH = API(SAVED_SEARCH_URI + "/{guid}", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ EXECUTE_SAVED_SEARCH_BY_NAME = API(SAVED_SEARCH_URI + "/execute/{search_name}", HTTPMethod.GET, HTTPStatus.OK)
+ EXECUTE_SAVED_SEARCH_BY_GUID = API(SAVED_SEARCH_URI + "/execute/guid/{search_guid}", HTTPMethod.GET, HTTPStatus.OK)
+
+ QUERY = "query"
+ LIMIT = "limit"
OFFSET = "offset"
STATUS = "Status"
@@ -80,7 +84,7 @@ class DiscoveryClient:
def basic_search(self, type_name, classification, query, exclude_deleted_entities, limit, offset):
query_params = {"typeName": type_name, "classification": classification, DiscoveryClient.QUERY: query,
"excludeDeletedEntities": exclude_deleted_entities, DiscoveryClient.LIMIT: limit,
- DiscoveryClient.OFFSET: offset }
+ DiscoveryClient.OFFSET: offset}
return self.client.call_api(DiscoveryClient.BASIC_SEARCH, AtlasSearchResult, query_params)
@@ -93,12 +97,13 @@ class DiscoveryClient:
return self.client.call_api(DiscoveryClient.ATTRIBUTE_SEARCH, AtlasSearchResult, query_params)
- def relationship_search(self, guid, relation, sort_by_attribute, sort_order, exclude_deleted_entities, limit, offset):
+ def relationship_search(self, guid, relation, sort_by_attribute, sort_order, exclude_deleted_entities, limit,
+ offset):
query_params = {"guid": guid, "relation": relation, "sortBy": sort_by_attribute,
"excludeDeletedEntities": exclude_deleted_entities,
DiscoveryClient.LIMIT: limit, DiscoveryClient.OFFSET: offset}
- if sort_order:
+ if sort_order is not None:
query_params["sortOrder"] = str(sort_order)
return self.client.call_api(DiscoveryClient.RELATIONSHIP_SEARCH, AtlasSearchResult, query_params)
@@ -117,10 +122,10 @@ class DiscoveryClient:
def get_suggestions(self, prefix_string, field_name):
query_params = {}
- if not prefix_string:
+ if prefix_string is not None:
query_params["prefixString"] = prefix_string
- if not field_name:
+ if field_name is not None:
query_params["fieldName"] = field_name
return self.client.call_api(DiscoveryClient.GET_SUGGESTIONS, AtlasSuggestionsResult, query_params)
@@ -145,12 +150,14 @@ class DiscoveryClient:
def delete_saved_search(self, guid):
return self.client.call_api(DiscoveryClient.DELETE_SAVED_SEARCH.format_path({'guid': guid}))
- def execute_saved_search(self, user_name, search_name):
+ def execute_saved_search_with_user_name(self, user_name, search_name):
query_params = {"user", user_name}
- return self.client.call_api(DiscoveryClient.EXECUTE_SAVED_SEARCH_BY_NAME.format_path({'search_name': search_name}),
- AtlasSearchResult, query_params)
+ return self.client.call_api(
+ DiscoveryClient.EXECUTE_SAVED_SEARCH_BY_NAME.format_path({'search_name': search_name}),
+ AtlasSearchResult, query_params)
- def execute_saved_search(self, search_guid):
- return self.client.call_api(DiscoveryClient.EXECUTE_SAVED_SEARCH_BY_GUID.format_path({'search_guid': search_guid}),
- AtlasSearchResult)
\ No newline at end of file
+ def execute_saved_search_with_search_guid(self, search_guid):
+ return self.client.call_api(
+ DiscoveryClient.EXECUTE_SAVED_SEARCH_BY_GUID.format_path({'search_guid': search_guid}),
+ AtlasSearchResult)
diff --git a/intg/src/main/python/apache_atlas/client/entity.py b/intg/src/main/python/apache_atlas/client/entity.py
index ebfe27f..7edacf9 100644
--- a/intg/src/main/python/apache_atlas/client/entity.py
+++ b/intg/src/main/python/apache_atlas/client/entity.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,69 +15,97 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.instance import *
-from apache_atlas.utils import *
+from apache_atlas.model.instance import AtlasClassifications
+from apache_atlas.model.instance import AtlasEntitiesWithExtInfo
+from apache_atlas.model.instance import AtlasEntityHeader
+from apache_atlas.model.instance import AtlasEntityHeaders
+from apache_atlas.model.instance import AtlasEntityWithExtInfo
+from apache_atlas.model.instance import EntityMutationResponse
+from apache_atlas.utils import API
+from apache_atlas.utils import APPLICATION_JSON
+from apache_atlas.utils import APPLICATION_OCTET_STREAM
+from apache_atlas.utils import attributes_to_params
+from apache_atlas.utils import BASE_URI
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
+from apache_atlas.utils import list_attributes_to_params
+from apache_atlas.utils import MULTIPART_FORM_DATA
class EntityClient:
- ENTITY_API = BASE_URI + "v2/entity/"
- PREFIX_ATTR = "attr:"
- PREFIX_ATTR_ = "attr_"
- ADMIN_API = BASE_URI + "admin/"
- ENTITY_PURGE_API = ADMIN_API + "purge/"
- ENTITY_BULK_API = ENTITY_API + "bulk/"
+ ENTITY_API = BASE_URI + "v2/entity/"
+ PREFIX_ATTR = "attr:"
+ PREFIX_ATTR_ = "attr_"
+ ADMIN_API = BASE_URI + "admin/"
+ ENTITY_PURGE_API = ADMIN_API + "purge/"
+ ENTITY_BULK_API = ENTITY_API + "bulk/"
BULK_SET_CLASSIFICATIONS = "bulk/setClassifications"
- BULK_HEADERS = "bulk/headers"
+ BULK_HEADERS = "bulk/headers"
# Entity APIs
- GET_ENTITY_BY_GUID = API(ENTITY_API + "guid", HttpMethod.GET, HTTPStatus.OK)
- GET_ENTITY_BY_UNIQUE_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type", HttpMethod.GET, HTTPStatus.OK)
- GET_ENTITIES_BY_GUIDS = API(ENTITY_BULK_API, HttpMethod.GET, HTTPStatus.OK)
- GET_ENTITIES_BY_UNIQUE_ATTRIBUTE = API(ENTITY_BULK_API + "uniqueAttribute/type", HttpMethod.GET, HTTPStatus.OK)
- GET_ENTITY_HEADER_BY_GUID = API(ENTITY_API + "guid/{entity_guid}/header", HttpMethod.GET, HTTPStatus.OK)
- GET_ENTITY_HEADER_BY_UNIQUE_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/{type_name}/header", HttpMethod.GET, HTTPStatus.OK)
-
- GET_AUDIT_EVENTS = API(ENTITY_API + "{guid}/audit", HttpMethod.GET, HTTPStatus.OK)
- CREATE_ENTITY = API(ENTITY_API, HttpMethod.POST, HTTPStatus.OK)
- CREATE_ENTITIES = API(ENTITY_BULK_API, HttpMethod.POST, HTTPStatus.OK)
- UPDATE_ENTITY = API(ENTITY_API, HttpMethod.POST, HTTPStatus.OK)
- UPDATE_ENTITY_BY_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/", HttpMethod.PUT, HTTPStatus.OK)
- UPDATE_ENTITIES = API(ENTITY_BULK_API, HttpMethod.POST, HTTPStatus.OK)
- PARTIAL_UPDATE_ENTITY_BY_GUID = API(ENTITY_API + "guid/{entity_guid}", HttpMethod.PUT, HTTPStatus.OK)
- DELETE_ENTITY_BY_GUID = API(ENTITY_API + "guid", HttpMethod.DELETE, HTTPStatus.OK)
- DELETE_ENTITY_BY_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/", HttpMethod.DELETE, HTTPStatus.OK)
- DELETE_ENTITIES_BY_GUIDS = API(ENTITY_BULK_API, HttpMethod.DELETE, HTTPStatus.OK)
- PURGE_ENTITIES_BY_GUIDS = API(ENTITY_PURGE_API, HttpMethod.PUT, HTTPStatus.OK)
+ GET_ENTITY_BY_GUID = API(ENTITY_API + "guid", HTTPMethod.GET, HTTPStatus.OK)
+ GET_ENTITY_BY_UNIQUE_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type", HTTPMethod.GET, HTTPStatus.OK)
+ GET_ENTITIES_BY_GUIDS = API(ENTITY_BULK_API, HTTPMethod.GET, HTTPStatus.OK)
+ GET_ENTITIES_BY_UNIQUE_ATTRIBUTE = API(ENTITY_BULK_API + "uniqueAttribute/type", HTTPMethod.GET, HTTPStatus.OK)
+ GET_ENTITY_HEADER_BY_GUID = API(ENTITY_API + "guid/{entity_guid}/header", HTTPMethod.GET, HTTPStatus.OK)
+ GET_ENTITY_HEADER_BY_UNIQUE_ATTRIBUTE = API(
+ ENTITY_API + "uniqueAttribute/type/{type_name}/header", HTTPMethod.GET, HTTPStatus.OK)
+
+ GET_AUDIT_EVENTS = API(ENTITY_API + "{guid}/audit", HTTPMethod.GET, HTTPStatus.OK)
+ CREATE_ENTITY = API(ENTITY_API, HTTPMethod.POST, HTTPStatus.OK)
+ CREATE_ENTITIES = API(ENTITY_BULK_API, HTTPMethod.POST, HTTPStatus.OK)
+ UPDATE_ENTITY = API(ENTITY_API, HTTPMethod.POST, HTTPStatus.OK)
+ UPDATE_ENTITY_BY_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/", HTTPMethod.PUT, HTTPStatus.OK)
+ UPDATE_ENTITIES = API(ENTITY_BULK_API, HTTPMethod.POST, HTTPStatus.OK)
+ PARTIAL_UPDATE_ENTITY_BY_GUID = API(ENTITY_API + "guid/{entity_guid}", HTTPMethod.PUT, HTTPStatus.OK)
+ DELETE_ENTITY_BY_GUID = API(ENTITY_API + "guid", HTTPMethod.DELETE, HTTPStatus.OK)
+ DELETE_ENTITY_BY_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/", HTTPMethod.DELETE, HTTPStatus.OK)
+ DELETE_ENTITIES_BY_GUIDS = API(ENTITY_BULK_API, HTTPMethod.DELETE, HTTPStatus.OK)
+ PURGE_ENTITIES_BY_GUIDS = API(ENTITY_PURGE_API, HTTPMethod.PUT, HTTPStatus.OK)
# Classification APIs
- GET_CLASSIFICATIONS = API(ENTITY_API + "guid/{guid}/classifications", HttpMethod.GET, HTTPStatus.OK)
- GET_FROM_CLASSIFICATION = API(ENTITY_API + "guid/{entity_guid}/classification/{classification}", HttpMethod.GET, HTTPStatus.OK)
- ADD_CLASSIFICATIONS = API(ENTITY_API + "guid/{guid}/classifications", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- ADD_CLASSIFICATION = API(ENTITY_BULK_API + "/classification", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- ADD_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/{type_name}/classifications", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- UPDATE_CLASSIFICATIONS = API(ENTITY_API + "guid/{guid}/classifications", HttpMethod.PUT, HTTPStatus.NO_CONTENT)
- UPDATE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/{type_name}/classifications", HttpMethod.PUT, HTTPStatus.NO_CONTENT)
- UPDATE_BULK_SET_CLASSIFICATIONS = API(ENTITY_API + BULK_SET_CLASSIFICATIONS, HttpMethod.POST, HTTPStatus.OK)
- DELETE_CLASSIFICATION = API(ENTITY_API + "guid/{guid}/classification/{classification_name}", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- DELETE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/{type_name}/classification/{" "classification_name}", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- GET_BULK_HEADERS = API(ENTITY_API + BULK_HEADERS, HttpMethod.GET, HTTPStatus.OK)
+ GET_CLASSIFICATIONS = API(ENTITY_API + "guid/{guid}/classifications", HTTPMethod.GET, HTTPStatus.OK)
+ GET_FROM_CLASSIFICATION = API(
+ ENTITY_API + "guid/{entity_guid}/classification/{classification}", HTTPMethod.GET, HTTPStatus.OK)
+ ADD_CLASSIFICATIONS = API(ENTITY_API + "guid/{guid}/classifications", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ ADD_CLASSIFICATION = API(ENTITY_BULK_API + "/classification", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ ADD_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE = API(
+ ENTITY_API + "uniqueAttribute/type/{type_name}/classifications", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ UPDATE_CLASSIFICATIONS = API(ENTITY_API + "guid/{guid}/classifications", HTTPMethod.PUT, HTTPStatus.NO_CONTENT)
+ UPDATE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE = API(
+ ENTITY_API + "uniqueAttribute/type/{type_name}/classifications", HTTPMethod.PUT, HTTPStatus.NO_CONTENT)
+ UPDATE_BULK_SET_CLASSIFICATIONS = API(ENTITY_API + BULK_SET_CLASSIFICATIONS, HTTPMethod.POST, HTTPStatus.OK)
+ DELETE_CLASSIFICATION = API(
+ ENTITY_API + "guid/{guid}/classification/{classification_name}", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ DELETE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE = API(
+ ENTITY_API + "uniqueAttribute/type/{type_name}/classification/{" "classification_name}", HTTPMethod.DELETE,
+ HTTPStatus.NO_CONTENT)
+ GET_BULK_HEADERS = API(ENTITY_API + BULK_HEADERS, HTTPMethod.GET, HTTPStatus.OK)
# Business Attributes APIs
- ADD_BUSINESS_ATTRIBUTE = API(ENTITY_API + "guid/{entity_guid}/businessmetadata", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- ADD_BUSINESS_ATTRIBUTE_BY_NAME = API(ENTITY_API + "guid/{entity_guid}/businessmetadata/{bm_name}", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- DELETE_BUSINESS_ATTRIBUTE = API(ENTITY_API + "guid/{entity_guid}/businessmetadata", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- DELETE_BUSINESS_ATTRIBUTE_BY_NAME = API(ENTITY_API + "guid/{entity_guid}/businessmetadata/{bm_name}", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- GET_BUSINESS_METADATA_TEMPLATE = API(ENTITY_API + "businessmetadata/import/template", HttpMethod.GET, HTTPStatus.OK, APPLICATION_JSON, APPLICATION_OCTET_STREAM)
- IMPORT_BUSINESS_METADATA = API(ENTITY_API + "businessmetadata/import", HttpMethod.POST, HTTPStatus.OK, MULTIPART_FORM_DATA, APPLICATION_JSON)
+ ADD_BUSINESS_ATTRIBUTE = API(
+ ENTITY_API + "guid/{entity_guid}/businessmetadata", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ ADD_BUSINESS_ATTRIBUTE_BY_NAME = API(
+ ENTITY_API + "guid/{entity_guid}/businessmetadata/{bm_name}", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ DELETE_BUSINESS_ATTRIBUTE = API(
+ ENTITY_API + "guid/{entity_guid}/businessmetadata", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ DELETE_BUSINESS_ATTRIBUTE_BY_NAME = API(
+ ENTITY_API + "guid/{entity_guid}/businessmetadata/{bm_name}", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ GET_BUSINESS_METADATA_TEMPLATE = API(ENTITY_API + "businessmetadata/import/template",
+ HTTPMethod.GET, HTTPStatus.OK, APPLICATION_JSON, APPLICATION_OCTET_STREAM)
+ IMPORT_BUSINESS_METADATA = API(ENTITY_API + "businessmetadata/import", HTTPMethod.POST,
+ HTTPStatus.OK, MULTIPART_FORM_DATA, APPLICATION_JSON)
# Labels APIs
- ADD_LABELS = API(ENTITY_API + "guid/{entity_guid}/labels", HttpMethod.PUT, HTTPStatus.NO_CONTENT)
- ADD_LABELS_BY_UNIQUE_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/{type_name}/labels", HttpMethod.PUT, HTTPStatus.NO_CONTENT)
- SET_LABELS = API(ENTITY_API + "guid/%s/labels", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- SET_LABELS_BY_UNIQUE_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/{entity_guid}/labels", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- DELETE_LABELS = API(ENTITY_API + "guid/{entity_guid}/labels", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- DELETE_LABELS_BY_UNIQUE_ATTRIBUTE = API(ENTITY_API + "uniqueAttribute/type/{type_name}/labels", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
+ ADD_LABELS = API(ENTITY_API + "guid/{entity_guid}/labels", HTTPMethod.PUT, HTTPStatus.NO_CONTENT)
+ ADD_LABELS_BY_UNIQUE_ATTRIBUTE = API(
+ ENTITY_API + "uniqueAttribute/type/{type_name}/labels", HTTPMethod.PUT, HTTPStatus.NO_CONTENT)
+ SET_LABELS = API(ENTITY_API + "guid/%s/labels", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ SET_LABELS_BY_UNIQUE_ATTRIBUTE = API(
+ ENTITY_API + "uniqueAttribute/type/{entity_guid}/labels", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ DELETE_LABELS = API(ENTITY_API + "guid/{entity_guid}/labels", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ DELETE_LABELS_BY_UNIQUE_ATTRIBUTE = API(
+ ENTITY_API + "uniqueAttribute/type/{type_name}/labels", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
def __init__(self, client):
self.client = client
@@ -86,7 +113,8 @@ class EntityClient:
def get_entity_by_guid(self, guid, min_ext_info=False, ignore_relationships=False):
query_params = {"minExtInfo": min_ext_info, "ignoreRelationships": ignore_relationships}
- return self.client.call_api(EntityClient.GET_ENTITY_BY_GUID.format_path_with_params(guid), AtlasEntityWithExtInfo, query_params)
+ return self.client.call_api(EntityClient.GET_ENTITY_BY_GUID.format_path_with_params(guid),
+ AtlasEntityWithExtInfo, query_params)
def get_entity_by_attribute(self, type_name, uniq_attributes, min_ext_info=False, ignore_relationships=False):
query_params = attributes_to_params(uniq_attributes)
@@ -101,7 +129,8 @@ class EntityClient:
return self.client.call_api(EntityClient.GET_ENTITIES_BY_GUIDS, AtlasEntitiesWithExtInfo, query_params)
- def get_entities_by_attribute(self, type_name, uniq_attributes_list, min_ext_info=False, ignore_relationships=False):
+ def get_entities_by_attribute(self, type_name, uniq_attributes_list, min_ext_info=False,
+ ignore_relationships=False):
query_params = list_attributes_to_params(uniq_attributes_list)
query_params["minExtInfo"] = min_ext_info
query_params["ignoreRelationships"] = ignore_relationships
@@ -116,13 +145,14 @@ class EntityClient:
def get_entity_header_by_attribute(self, type_name, uniq_attributes):
query_params = attributes_to_params(uniq_attributes)
- return self.client.call_api(EntityClient.GET_ENTITY_HEADER_BY_UNIQUE_ATTRIBUTE.format_path({'type_name': type_name}),
- AtlasEntityHeader, query_params)
+ return self.client.call_api(
+ EntityClient.GET_ENTITY_HEADER_BY_UNIQUE_ATTRIBUTE.format_path({'type_name': type_name}),
+ AtlasEntityHeader, query_params)
def get_audit_events(self, guid, start_key, audit_action, count):
query_params = {"startKey": start_key, "count": count}
- if audit_action:
+ if audit_action is not None:
query_params["auditAction"] = audit_action
return self.client.call_api(EntityClient.GET_AUDIT_EVENTS.format_path({'guid': guid}), list, query_params)
@@ -142,11 +172,13 @@ class EntityClient:
def partial_update_entity_by_guid(self, entity_guid, attr_value, attr_name):
query_params = {"name", attr_name}
- return self.client.call_api(EntityClient.PARTIAL_UPDATE_ENTITY_BY_GUID.format_path({'entity_guid': entity_guid}),
- EntityMutationResponse, attr_value, query_params)
+ return self.client.call_api(
+ EntityClient.PARTIAL_UPDATE_ENTITY_BY_GUID.format_path({'entity_guid': entity_guid}),
+ EntityMutationResponse, attr_value, query_params)
def delete_entity_by_guid(self, guid):
- return self.client.call_api(EntityClient.DELETE_ENTITY_BY_GUID.format_path_with_params(guid), EntityMutationResponse)
+ return self.client.call_api(EntityClient.DELETE_ENTITY_BY_GUID.format_path_with_params(guid),
+ EntityMutationResponse)
def delete_entity_by_attribute(self, type_name, uniq_attributes):
query_param = attributes_to_params(uniq_attributes)
@@ -180,16 +212,19 @@ class EntityClient:
def add_classifications_by_type(self, type_name, uniq_attributes, classifications):
query_param = attributes_to_params(uniq_attributes)
- self.client.call_api(EntityClient.ADD_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE.format_path({'type_name': type_name}),
- None, query_param, classifications)
+ self.client.call_api(
+ EntityClient.ADD_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE.format_path({'type_name': type_name}),
+ None, query_param, classifications)
def update_classifications(self, guid, classifications):
- self.client.call_api(EntityClient.UPDATE_CLASSIFICATIONS.format_path({'guid': guid}), None, None, classifications)
+ self.client.call_api(EntityClient.UPDATE_CLASSIFICATIONS.format_path(
+ {'guid': guid}), None, None, classifications)
def update_classifications_by_attr(self, type_name, uniq_attributes, classifications):
query_param = attributes_to_params(uniq_attributes)
- self.client.call_api(EntityClient.UPDATE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE.format_path({'type_name': type_name}),
+ self.client.call_api(
+ EntityClient.UPDATE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE.format_path({'type_name': type_name}),
None, query_param, classifications)
def set_classifications(self, entity_headers):
@@ -213,9 +248,10 @@ class EntityClient:
def remove_classification_by_name(self, type_name, uniq_attributes, classification_name):
query_params = attributes_to_params(uniq_attributes)
- query = {'type_name': type_name, 'classification_name': classification_name}
+ query = {'type_name': type_name, 'classification_name': classification_name}
- self.client.call_api(EntityClient.DELETE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE.format_path({query}), None, query_params)
+ self.client.call_api(EntityClient.DELETE_CLASSIFICATION_BY_TYPE_AND_ATTRIBUTE.format_path(
+ {query}), None, query_params)
def get_entity_headers(self, tag_update_start_time):
query_params = {"tagUpdateStartTime", tag_update_start_time}
@@ -232,7 +268,8 @@ class EntityClient:
def add_or_update_business_attributes_bm_name(self, entity_guid, bm_name, business_attributes):
query = {'entity_guid': entity_guid, 'bm_name': bm_name}
- self.client.call_api(EntityClient.ADD_BUSINESS_ATTRIBUTE_BY_NAME.format_path(query), None, None, business_attributes)
+ self.client.call_api(EntityClient.ADD_BUSINESS_ATTRIBUTE_BY_NAME.format_path(query),
+ None, None, business_attributes)
def remove_business_attributes(self, entity_guid, business_attributes):
self.client.call_api(EntityClient.DELETE_BUSINESS_ATTRIBUTE.format_path({'entity_guid': entity_guid}), None,
@@ -241,7 +278,8 @@ class EntityClient:
def remove_business_attributes_bm_name(self, entity_guid, bm_name, business_attributes):
query = {'entity_guid': entity_guid, 'bm_name': bm_name}
- self.client.call_api(EntityClient.DELETE_BUSINESS_ATTRIBUTE_BY_NAME.format_path(query), None, None, business_attributes)
+ self.client.call_api(EntityClient.DELETE_BUSINESS_ATTRIBUTE_BY_NAME.format_path(query),
+ None, None, business_attributes)
# Labels APIs
def add_labels_by_guid(self, entity_guid, labels):
@@ -268,4 +306,5 @@ class EntityClient:
def set_labels_by_name(self, type_name, uniq_attributes, labels):
query_param = attributes_to_params(uniq_attributes)
- self.client.call_api(EntityClient.ADD_LABELS_BY_UNIQUE_ATTRIBUTE.format({'type_name': type_name}), None, query_param, labels)
\ No newline at end of file
+ self.client.call_api(EntityClient.ADD_LABELS_BY_UNIQUE_ATTRIBUTE.format(
+ {'type_name': type_name}), None, query_param, labels)
diff --git a/intg/src/main/python/apache_atlas/client/glossary.py b/intg/src/main/python/apache_atlas/client/glossary.py
index ed7acdf..efa0612 100644
--- a/intg/src/main/python/apache_atlas/client/glossary.py
+++ b/intg/src/main/python/apache_atlas/client/glossary.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,60 +15,74 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.glossary import *
-from apache_atlas.utils import *
+from apache_atlas.model.glossary import AtlasGlossary
+from apache_atlas.model.glossary import AtlasGlossaryCategory
+from apache_atlas.model.glossary import AtlasGlossaryExtInfo
+from apache_atlas.model.glossary import AtlasGlossaryTerm
+from apache_atlas.utils import API
+from apache_atlas.utils import APPLICATION_JSON
+from apache_atlas.utils import APPLICATION_OCTET_STREAM
+from apache_atlas.utils import BASE_URI
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
+from apache_atlas.utils import MULTIPART_FORM_DATA
class GlossaryClient:
- GLOSSARY_URI = BASE_URI + "v2/glossary"
- GLOSSARY_TERM = GLOSSARY_URI + "/term"
- GLOSSARY_TERMS = GLOSSARY_URI + "/terms"
- GLOSSARY_CATEGORY = GLOSSARY_URI + "/category"
+ GLOSSARY_URI = BASE_URI + "v2/glossary"
+ GLOSSARY_TERM = GLOSSARY_URI + "/term"
+ GLOSSARY_TERMS = GLOSSARY_URI + "/terms"
+ GLOSSARY_CATEGORY = GLOSSARY_URI + "/category"
GLOSSARY_CATEGORIES = GLOSSARY_URI + "/categories"
- GET_ALL_GLOSSARIES = API(GLOSSARY_URI, HttpMethod.GET, HTTPStatus.OK)
- GET_GLOSSARY_BY_GUID = API(GLOSSARY_URI + "/{glossary_guid}", HttpMethod.GET, HTTPStatus.OK)
- GET_DETAILED_GLOSSARY = API(GLOSSARY_URI + "/{glossary_guid}/detailed", HttpMethod.GET, HTTPStatus.OK)
-
- GET_GLOSSARY_TERM = API(GLOSSARY_TERM, HttpMethod.GET, HTTPStatus.OK)
- GET_GLOSSARY_TERMS = API(GLOSSARY_URI + "/{glossary_guid}/terms", HttpMethod.GET, HTTPStatus.OK)
- GET_GLOSSARY_TERMS_HEADERS = API(GLOSSARY_URI + "/{glossary_guid}/terms/headers", HttpMethod.GET, HTTPStatus.OK)
-
- GET_GLOSSARY_CATEGORY = API(GLOSSARY_CATEGORY, HttpMethod.GET, HTTPStatus.OK)
- GET_GLOSSARY_CATEGORIES = API(GLOSSARY_URI + "/{glossary_guid}/categories", HttpMethod.GET, HTTPStatus.OK)
- GET_GLOSSARY_CATEGORIES_HEADERS = API(GLOSSARY_URI + "/{glossary_guid}/categories/headers", HttpMethod.GET, HTTPStatus.OK)
-
- GET_CATEGORY_TERMS = API(GLOSSARY_CATEGORY + "/{category_guid}/terms", HttpMethod.GET, HTTPStatus.OK)
- GET_RELATED_TERMS = API(GLOSSARY_TERMS + "/{term_guid}/related", HttpMethod.GET, HTTPStatus.OK)
- GET_RELATED_CATEGORIES = API(GLOSSARY_CATEGORY + "/{category_guid}/related", HttpMethod.GET, HTTPStatus.OK)
- CREATE_GLOSSARY = API(GLOSSARY_URI, HttpMethod.POST, HTTPStatus.OK)
- CREATE_GLOSSARY_TERM = API(GLOSSARY_TERM, HttpMethod.POST, HTTPStatus.OK)
- CREATE_GLOSSARY_TERMS = API(GLOSSARY_TERMS, HttpMethod.POST, HTTPStatus.OK)
- CREATE_GLOSSARY_CATEGORY = API(GLOSSARY_CATEGORY, HttpMethod.POST, HTTPStatus.OK)
- CREATE_GLOSSARY_CATEGORIES = API(GLOSSARY_CATEGORIES, HttpMethod.POST, HTTPStatus.OK)
-
- UPDATE_GLOSSARY_BY_GUID = API(GLOSSARY_URI + "/{glossary_guid}", HttpMethod.PUT, HTTPStatus.OK)
- UPDATE_PARTIAL_GLOSSARY = API(GLOSSARY_URI + "/{glossary_guid}/partial", HttpMethod.PUT, HTTPStatus.OK)
- UPDATE_GLOSSARY_TERM = API(GLOSSARY_TERM + "/{term_guid}", HttpMethod.PUT, HTTPStatus.OK)
- UPDATE_PARTIAL_TERM = API(GLOSSARY_TERM + "/{term_guid}/partial", HttpMethod.PUT, HTTPStatus.OK)
-
- UPDATE_CATEGORY_BY_GUID = API(GLOSSARY_CATEGORY + "/{category_guid}", HttpMethod.PUT, HTTPStatus.OK)
- UPDATE_PARTIAL_CATEGORY = API(GLOSSARY_CATEGORY + "/{category_guid}/partial", HttpMethod.PUT, HTTPStatus.OK)
-
- DELETE_GLOSSARY_BY_GUID = API(GLOSSARY_URI + "/{glossary_guid}", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- DELETE_TERM_BY_GUID = API(GLOSSARY_TERM + "/{term_guid}", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- DELETE_CATEGORY_BY_GUID = API(GLOSSARY_CATEGORY + "/{category_guid}", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
-
- GET_ENTITIES_ASSIGNED_WITH_TERM = API(GLOSSARY_TERMS + "/{term_guid}/assignedEntities", HttpMethod.GET, HTTPStatus.OK)
- ASSIGN_TERM_TO_ENTITIES = API(GLOSSARY_TERMS + "/{term_guid}/assignedEntities", HttpMethod.POST, HTTPStatus.NO_CONTENT)
- DISASSOCIATE_TERM_FROM_ENTITIES = API(GLOSSARY_TERMS + "/{term_guid}/assignedEntities", HttpMethod.PUT, HTTPStatus.NO_CONTENT)
-
- GET_IMPORT_GLOSSARY_TEMPLATE = API(GLOSSARY_URI + "/import/template", HttpMethod.GET, HTTPStatus.OK, APPLICATION_JSON, APPLICATION_OCTET_STREAM)
- IMPORT_GLOSSARY = API(GLOSSARY_URI + "/import", HttpMethod.POST, HTTPStatus.OK, MULTIPART_FORM_DATA, APPLICATION_JSON)
-
- QUERY = "query"
- LIMIT = "limit"
+ GET_ALL_GLOSSARIES = API(GLOSSARY_URI, HTTPMethod.GET, HTTPStatus.OK)
+ GET_GLOSSARY_BY_GUID = API(GLOSSARY_URI + "/{glossary_guid}", HTTPMethod.GET, HTTPStatus.OK)
+ GET_DETAILED_GLOSSARY = API(GLOSSARY_URI + "/{glossary_guid}/detailed", HTTPMethod.GET, HTTPStatus.OK)
+
+ GET_GLOSSARY_TERM = API(GLOSSARY_TERM, HTTPMethod.GET, HTTPStatus.OK)
+ GET_GLOSSARY_TERMS = API(GLOSSARY_URI + "/{glossary_guid}/terms", HTTPMethod.GET, HTTPStatus.OK)
+ GET_GLOSSARY_TERMS_HEADERS = API(GLOSSARY_URI + "/{glossary_guid}/terms/headers", HTTPMethod.GET, HTTPStatus.OK)
+
+ GET_GLOSSARY_CATEGORY = API(GLOSSARY_CATEGORY, HTTPMethod.GET, HTTPStatus.OK)
+ GET_GLOSSARY_CATEGORIES = API(GLOSSARY_URI + "/{glossary_guid}/categories", HTTPMethod.GET, HTTPStatus.OK)
+ GET_GLOSSARY_CATEGORIES_HEADERS = API(
+ GLOSSARY_URI + "/{glossary_guid}/categories/headers", HTTPMethod.GET, HTTPStatus.OK)
+
+ GET_CATEGORY_TERMS = API(GLOSSARY_CATEGORY + "/{category_guid}/terms", HTTPMethod.GET, HTTPStatus.OK)
+ GET_RELATED_TERMS = API(GLOSSARY_TERMS + "/{term_guid}/related", HTTPMethod.GET, HTTPStatus.OK)
+ GET_RELATED_CATEGORIES = API(GLOSSARY_CATEGORY + "/{category_guid}/related", HTTPMethod.GET, HTTPStatus.OK)
+ CREATE_GLOSSARY = API(GLOSSARY_URI, HTTPMethod.POST, HTTPStatus.OK)
+ CREATE_GLOSSARY_TERM = API(GLOSSARY_TERM, HTTPMethod.POST, HTTPStatus.OK)
+ CREATE_GLOSSARY_TERMS = API(GLOSSARY_TERMS, HTTPMethod.POST, HTTPStatus.OK)
+ CREATE_GLOSSARY_CATEGORY = API(GLOSSARY_CATEGORY, HTTPMethod.POST, HTTPStatus.OK)
+ CREATE_GLOSSARY_CATEGORIES = API(GLOSSARY_CATEGORIES, HTTPMethod.POST, HTTPStatus.OK)
+
+ UPDATE_GLOSSARY_BY_GUID = API(GLOSSARY_URI + "/{glossary_guid}", HTTPMethod.PUT, HTTPStatus.OK)
+ UPDATE_PARTIAL_GLOSSARY = API(GLOSSARY_URI + "/{glossary_guid}/partial", HTTPMethod.PUT, HTTPStatus.OK)
+ UPDATE_GLOSSARY_TERM = API(GLOSSARY_TERM + "/{term_guid}", HTTPMethod.PUT, HTTPStatus.OK)
+ UPDATE_PARTIAL_TERM = API(GLOSSARY_TERM + "/{term_guid}/partial", HTTPMethod.PUT, HTTPStatus.OK)
+
+ UPDATE_CATEGORY_BY_GUID = API(GLOSSARY_CATEGORY + "/{category_guid}", HTTPMethod.PUT, HTTPStatus.OK)
+ UPDATE_PARTIAL_CATEGORY = API(GLOSSARY_CATEGORY + "/{category_guid}/partial", HTTPMethod.PUT, HTTPStatus.OK)
+
+ DELETE_GLOSSARY_BY_GUID = API(GLOSSARY_URI + "/{glossary_guid}", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ DELETE_TERM_BY_GUID = API(GLOSSARY_TERM + "/{term_guid}", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ DELETE_CATEGORY_BY_GUID = API(GLOSSARY_CATEGORY + "/{category_guid}", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+
+ GET_ENTITIES_ASSIGNED_WITH_TERM = API(
+ GLOSSARY_TERMS + "/{term_guid}/assignedEntities", HTTPMethod.GET, HTTPStatus.OK)
+ ASSIGN_TERM_TO_ENTITIES = API(
+ GLOSSARY_TERMS + "/{term_guid}/assignedEntities", HTTPMethod.POST, HTTPStatus.NO_CONTENT)
+ DISASSOCIATE_TERM_FROM_ENTITIES = API(
+ GLOSSARY_TERMS + "/{term_guid}/assignedEntities", HTTPMethod.PUT, HTTPStatus.NO_CONTENT)
+
+ GET_IMPORT_GLOSSARY_TEMPLATE = API(GLOSSARY_URI + "/import/template", HTTPMethod.GET,
+ HTTPStatus.OK, APPLICATION_JSON, APPLICATION_OCTET_STREAM)
+ IMPORT_GLOSSARY = API(GLOSSARY_URI + "/import", HTTPMethod.POST,
+ HTTPStatus.OK, MULTIPART_FORM_DATA, APPLICATION_JSON)
+
+ QUERY = "query"
+ LIMIT = "limit"
OFFSET = "offset"
STATUS = "Status"
@@ -90,7 +103,8 @@ class GlossaryClient:
AtlasGlossaryExtInfo)
def get_glossary_term(self, term_guid):
- return self.client.call_api(GlossaryClient.GET_GLOSSARY_TERM.format_path_with_params(term_guid), AtlasGlossaryTerm)
+ return self.client.call_api(GlossaryClient.GET_GLOSSARY_TERM.format_path_with_params(term_guid),
+ AtlasGlossaryTerm)
def get_glossary_terms(self, glossary_guid, sort_by_attribute, limit, offset):
query_params = {"glossaryGuid": glossary_guid, GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset,
@@ -103,8 +117,9 @@ class GlossaryClient:
query_params = {"glossaryGuid": glossary_guid, GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset,
"sort": sort_by_attribute}
- return self.client.call_api(GlossaryClient.GET_GLOSSARY_TERMS_HEADERS.format_path({'glossary_guid': glossary_guid}),
- list, query_params)
+ return self.client.call_api(
+ GlossaryClient.GET_GLOSSARY_TERMS_HEADERS.format_path({'glossary_guid': glossary_guid}),
+ list, query_params)
def get_glossary_category(self, category_guid):
return self.client.call_api(GlossaryClient.GET_GLOSSARY_CATEGORY.format_path_with_params(category_guid),
@@ -114,15 +129,17 @@ class GlossaryClient:
query_params = {"glossaryGuid": glossary_guid, GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset,
"sort": sort_by_attribute}
- return self.client.call_api(GlossaryClient.GET_GLOSSARY_CATEGORIES.format_path({'glossary_guid': glossary_guid}),
- list, query_params)
+ return self.client.call_api(
+ GlossaryClient.GET_GLOSSARY_CATEGORIES.format_path({'glossary_guid': glossary_guid}),
+ list, query_params)
def get_glossary_category_headers(self, glossary_guid, sort_by_attribute, limit, offset):
query_params = {"glossaryGuid": glossary_guid, GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset,
"sort": sort_by_attribute}
- return self.client.call_api(GlossaryClient.GET_GLOSSARY_CATEGORIES_HEADERS.format_path({'glossary_guid': glossary_guid}),
- list, query_params)
+ return self.client.call_api(
+ GlossaryClient.GET_GLOSSARY_CATEGORIES_HEADERS.format_path({'glossary_guid': glossary_guid}),
+ list, query_params)
def get_category_terms(self, category_guid, sort_by_attribute, limit, offset):
query_params = {"categoryGuid": category_guid, GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset,
@@ -133,9 +150,10 @@ class GlossaryClient:
def get_related_terms(self, term_guid, sort_by_attribute, limit, offset):
query_params = {"termGuid": term_guid, GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset,
- "sort": sort_by_attribute }
+ "sort": sort_by_attribute}
- return self.client.call_api(GlossaryClient.GET_RELATED_TERMS.format_path({'term_guid': term_guid}), dict, query_params)
+ return self.client.call_api(GlossaryClient.GET_RELATED_TERMS.format_path({'term_guid': term_guid}), dict,
+ query_params)
def get_related_categories(self, category_guid, sort_by_attribute, limit, offset):
query_params = {GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset, "sort": sort_by_attribute}
@@ -153,18 +171,21 @@ class GlossaryClient:
return self.client.call_api(GlossaryClient.CREATE_GLOSSARY_TERMS, list, None, glossary_terms)
def create_glossary_category(self, glossary_category):
- return self.client.call_api(GlossaryClient.CREATE_GLOSSARY_CATEGORY, AtlasGlossaryCategory, None, glossary_category)
+ return self.client.call_api(GlossaryClient.CREATE_GLOSSARY_CATEGORY, AtlasGlossaryCategory, None,
+ glossary_category)
def create_glossary_categories(self, glossary_categories):
return self.client.call_api(GlossaryClient.CREATE_GLOSSARY_CATEGORIES, list, glossary_categories)
def update_glossary_by_guid(self, glossary_guid, updated_glossary):
- return self.client.call_api(GlossaryClient.UPDATE_GLOSSARY_BY_GUID.format_path({'glossary_guid': glossary_guid}),
- AtlasGlossary, None, updated_glossary)
+ return self.client.call_api(
+ GlossaryClient.UPDATE_GLOSSARY_BY_GUID.format_path({'glossary_guid': glossary_guid}),
+ AtlasGlossary, None, updated_glossary)
def partial_update_glossary_by_guid(self, glossary_guid, attributes):
- return self.client.call_api(GlossaryClient.UPDATE_PARTIAL_GLOSSARY.format_path({'glossary_guid': glossary_guid}),
- AtlasGlossary, attributes)
+ return self.client.call_api(
+ GlossaryClient.UPDATE_PARTIAL_GLOSSARY.format_path({'glossary_guid': glossary_guid}),
+ AtlasGlossary, attributes)
def update_glossary_term_by_guid(self, term_guid, glossary_term):
return self.client.call_api(GlossaryClient.UPDATE_GLOSSARY_TERM.format_path({'term_guid': term_guid}),
@@ -175,31 +196,38 @@ class GlossaryClient:
AtlasGlossaryTerm, attributes)
def update_glossary_category_by_guid(self, category_guid, glossary_category):
- return self.client.call_api(GlossaryClient.UPDATE_CATEGORY_BY_GUID.format_path({'category_guid': category_guid}),
- AtlasGlossaryCategory, glossary_category)
+ return self.client.call_api(
+ GlossaryClient.UPDATE_CATEGORY_BY_GUID.format_path({'category_guid': category_guid}),
+ AtlasGlossaryCategory, glossary_category)
def partial_update_category_by_guid(self, category_guid, attributes):
- return self.client.call_api(GlossaryClient.UPDATE_PARTIAL_CATEGORY.format_path({'category_guid': category_guid}),
- AtlasGlossaryCategory, None, attributes)
+ return self.client.call_api(
+ GlossaryClient.UPDATE_PARTIAL_CATEGORY.format_path({'category_guid': category_guid}),
+ AtlasGlossaryCategory, None, attributes)
def delete_glossary_by_guid(self, glossary_guid):
- return self.client.call_api(GlossaryClient.DELETE_GLOSSARY_BY_GUID.format_path({'glossary_guid': glossary_guid}))
+ return self.client.call_api(
+ GlossaryClient.DELETE_GLOSSARY_BY_GUID.format_path({'glossary_guid': glossary_guid}))
def delete_glossary_term_by_guid(self, term_guid):
return self.client.call_api(GlossaryClient.DELETE_TERM_BY_GUID.format_path({'term_guid': term_guid}))
def delete_glossary_category_by_guid(self, category_guid):
- return self.client.call_api(GlossaryClient.DELETE_CATEGORY_BY_GUID.format_path({'category_guid': category_guid}))
+ return self.client.call_api(
+ GlossaryClient.DELETE_CATEGORY_BY_GUID.format_path({'category_guid': category_guid}))
def get_entities_assigned_with_term(self, term_guid, sort_by_attribute, limit, offset):
- query_params = {"termGuid": term_guid, GlossaryClient.LIMIT: limit, GlossaryClient.OFFSET: offset, "sort": sort_by_attribute }
+ query_params = {"termGuid": term_guid, GlossaryClient.LIMIT: limit,
+ GlossaryClient.OFFSET: offset, "sort": sort_by_attribute}
- return self.client.call_api(GlossaryClient.GET_ENTITIES_ASSIGNED_WITH_TERM.format_path({'term_guid': term_guid}), list, query_params)
+ return self.client.call_api(
+ GlossaryClient.GET_ENTITIES_ASSIGNED_WITH_TERM.format_path({'term_guid': term_guid}), list, query_params)
def assign_term_to_entities(self, term_guid, related_object_ids):
return self.client.call_api(GlossaryClient.ASSIGN_TERM_TO_ENTITIES.format_path({'term_guid': term_guid}),
None, None, related_object_ids)
def disassociate_term_from_entities(self, term_guid, related_object_ids):
- return self.client.call_api(GlossaryClient.DISASSOCIATE_TERM_FROM_ENTITIES.format_path({'term_guid': term_guid}),
- None, None, related_object_ids)
+ return self.client.call_api(
+ GlossaryClient.DISASSOCIATE_TERM_FROM_ENTITIES.format_path({'term_guid': term_guid}),
+ None, None, related_object_ids)
diff --git a/intg/src/main/python/apache_atlas/client/lineage.py b/intg/src/main/python/apache_atlas/client/lineage.py
index 980efcd..e98c037 100644
--- a/intg/src/main/python/apache_atlas/client/lineage.py
+++ b/intg/src/main/python/apache_atlas/client/lineage.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,15 +15,18 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.lineage import *
-from apache_atlas.utils import *
+from apache_atlas.model.lineage import AtlasLineageInfo
+from apache_atlas.utils import API
+from apache_atlas.utils import attributes_to_params
+from apache_atlas.utils import BASE_URI
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
class LineageClient:
- LINEAGE_URI = BASE_URI + "v2/lineage"
- LINEAGE_INFO = API(LINEAGE_URI, HttpMethod.GET, HTTPStatus.OK)
- GET_LINEAGE_BY_ATTRIBUTES = API(LINEAGE_URI + "/uniqueAttribute/type/", HttpMethod.GET, HTTPStatus.OK)
+ LINEAGE_URI = BASE_URI + "v2/lineage"
+ LINEAGE_INFO = API(LINEAGE_URI, HTTPMethod.GET, HTTPStatus.OK)
+ GET_LINEAGE_BY_ATTRIBUTES = API(LINEAGE_URI + "/uniqueAttribute/type/", HTTPMethod.GET, HTTPStatus.OK)
def __init__(self, client):
self.client = client
@@ -32,9 +34,11 @@ class LineageClient:
def get_lineage_info(self, guid, direction, depth):
query_params = {"direction": direction, "depth": depth}
- return self.client.call_api(LineageClient.LINEAGE_INFO.format_path_with_params(guid), AtlasLineageInfo, query_params)
+ return self.client.call_api(LineageClient.LINEAGE_INFO.format_path_with_params(guid), AtlasLineageInfo,
+ query_params)
def get_lineage_info_attr(self, type_name, attributes, direction, depth):
query_params = attributes_to_params(attributes, {"direction": direction, "depth": depth})
- return self.client.call_api(LineageClient.GET_LINEAGE_BY_ATTRIBUTES.format_path_with_params(type_name), AtlasLineageInfo, query_params)
\ No newline at end of file
+ return self.client.call_api(LineageClient.GET_LINEAGE_BY_ATTRIBUTES.format_path_with_params(type_name),
+ AtlasLineageInfo, query_params)
diff --git a/intg/src/main/python/apache_atlas/client/relationship.py b/intg/src/main/python/apache_atlas/client/relationship.py
index 72b701a..f5790a4 100644
--- a/intg/src/main/python/apache_atlas/client/relationship.py
+++ b/intg/src/main/python/apache_atlas/client/relationship.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,31 +15,36 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.relationship import *
-from apache_atlas.utils import *
+from apache_atlas.model.relationship import AtlasRelationship
+from apache_atlas.model.relationship import AtlasRelationshipWithExtInfo
+from apache_atlas.utils import API
+from apache_atlas.utils import BASE_URI
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
class RelationshipClient:
- RELATIONSHIPS_URI = BASE_URI + "v2/relationship/"
- BULK_HEADERS = "bulk/headers"
- BULK_SET_CLASSIFICATIONS = "bulk/setClassifications"
+ RELATIONSHIPS_URI = BASE_URI + "v2/relationship/"
+ BULK_HEADERS = "bulk/headers"
+ BULK_SET_CLASSIFICATIONS = "bulk/setClassifications"
- GET_RELATIONSHIP_BY_GUID = API(RELATIONSHIPS_URI + "guid", HttpMethod.GET, HTTPStatus.OK)
- CREATE_RELATIONSHIP = API(RELATIONSHIPS_URI, HttpMethod.POST, HTTPStatus.OK)
- UPDATE_RELATIONSHIP = API(RELATIONSHIPS_URI, HttpMethod.PUT, HTTPStatus.OK)
- DELETE_RELATIONSHIP_BY_GUID = API(RELATIONSHIPS_URI + "guid", HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
+ GET_RELATIONSHIP_BY_GUID = API(RELATIONSHIPS_URI + "guid", HTTPMethod.GET, HTTPStatus.OK)
+ CREATE_RELATIONSHIP = API(RELATIONSHIPS_URI, HTTPMethod.POST, HTTPStatus.OK)
+ UPDATE_RELATIONSHIP = API(RELATIONSHIPS_URI, HTTPMethod.PUT, HTTPStatus.OK)
+ DELETE_RELATIONSHIP_BY_GUID = API(RELATIONSHIPS_URI + "guid", HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
def __init__(self, client):
self.client = client
def get_relationship_by_guid(self, guid):
- return self.client.call_api(RelationshipClient.GET_RELATIONSHIP_BY_GUID.format_path_with_params(guid), AtlasRelationshipWithExtInfo)
+ return self.client.call_api(RelationshipClient.GET_RELATIONSHIP_BY_GUID.format_path_with_params(guid),
+ AtlasRelationshipWithExtInfo)
- def get_relationship_by_guid(self, guid, extended_info):
+ def get_relationship_by_guid_with_ext_info(self, guid, extended_info):
query_params = {"extendedInfo": extended_info}
- return self.client.call_api(RelationshipClient.GET_RELATIONSHIP_BY_GUID.format_path_with_params(guid), AtlasRelationshipWithExtInfo, query_params)
+ return self.client.call_api(RelationshipClient.GET_RELATIONSHIP_BY_GUID.format_path_with_params(guid),
+ AtlasRelationshipWithExtInfo, query_params)
def create_relationship(self, relationship):
return self.client.call_api(RelationshipClient.CREATE_RELATIONSHIP, AtlasRelationship, relationship)
@@ -49,4 +53,4 @@ class RelationshipClient:
return self.client.call_api(RelationshipClient.UPDATE_RELATIONSHIP, AtlasRelationship, relationship)
def delete_relationship_by_guid(self, guid):
- return self.client.call_api(RelationshipClient.DELETE_RELATIONSHIP_BY_GUID.format_path_with_params(guid))
\ No newline at end of file
+ return self.client.call_api(RelationshipClient.DELETE_RELATIONSHIP_BY_GUID.format_path_with_params(guid))
diff --git a/intg/src/main/python/apache_atlas/client/typedef.py b/intg/src/main/python/apache_atlas/client/typedef.py
index 2ee8f5a..aa1581d 100644
--- a/intg/src/main/python/apache_atlas/client/typedef.py
+++ b/intg/src/main/python/apache_atlas/client/typedef.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,26 +15,34 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.typedef import *
-from apache_atlas.utils import *
+from apache_atlas.model.typedef import AtlasBusinessMetadataDef
+from apache_atlas.model.typedef import AtlasClassificationDef
+from apache_atlas.model.typedef import AtlasEntityDef
+from apache_atlas.model.typedef import AtlasEnumDef
+from apache_atlas.model.typedef import AtlasRelationshipDef
+from apache_atlas.model.typedef import AtlasStructDef
+from apache_atlas.model.typedef import AtlasTypesDef
+from apache_atlas.utils import API
+from apache_atlas.utils import BASE_URI
+from apache_atlas.utils import HTTPMethod
+from apache_atlas.utils import HTTPStatus
class TypeDefClient:
- TYPES_API = BASE_URI + "v2/types/"
- TYPEDEFS_API = TYPES_API + "typedefs/"
- TYPEDEF_BY_NAME = TYPES_API + "typedef/name"
- TYPEDEF_BY_GUID = TYPES_API + "typedef/guid"
+ TYPES_API = BASE_URI + "v2/types/"
+ TYPEDEFS_API = TYPES_API + "typedefs/"
+ TYPEDEF_BY_NAME = TYPES_API + "typedef/name"
+ TYPEDEF_BY_GUID = TYPES_API + "typedef/guid"
GET_BY_NAME_TEMPLATE = TYPES_API + "{path_type}/name/{name}"
GET_BY_GUID_TEMPLATE = TYPES_API + "{path_type}/guid/{guid}"
- GET_TYPEDEF_BY_NAME = API(TYPEDEF_BY_NAME, HttpMethod.GET, HTTPStatus.OK)
- GET_TYPEDEF_BY_GUID = API(TYPEDEF_BY_GUID, HttpMethod.GET, HTTPStatus.OK)
- GET_ALL_TYPE_DEFS = API(TYPEDEFS_API, HttpMethod.GET, HTTPStatus.OK)
- GET_ALL_TYPE_DEF_HEADERS = API(TYPEDEFS_API + "headers", HttpMethod.GET, HTTPStatus.OK)
- CREATE_TYPE_DEFS = API(TYPEDEFS_API, HttpMethod.POST, HTTPStatus.OK)
- DELETE_TYPE_DEFS = API(TYPEDEFS_API, HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
- DELETE_TYPE_DEF_BY_NAME = API(TYPEDEF_BY_NAME, HttpMethod.DELETE, HTTPStatus.NO_CONTENT)
+ GET_TYPEDEF_BY_NAME = API(TYPEDEF_BY_NAME, HTTPMethod.GET, HTTPStatus.OK)
+ GET_TYPEDEF_BY_GUID = API(TYPEDEF_BY_GUID, HTTPMethod.GET, HTTPStatus.OK)
+ GET_ALL_TYPE_DEFS = API(TYPEDEFS_API, HTTPMethod.GET, HTTPStatus.OK)
+ GET_ALL_TYPE_DEF_HEADERS = API(TYPEDEFS_API + "headers", HTTPMethod.GET, HTTPStatus.OK)
+ CREATE_TYPE_DEFS = API(TYPEDEFS_API, HTTPMethod.POST, HTTPStatus.OK)
+ DELETE_TYPE_DEFS = API(TYPEDEFS_API, HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
+ DELETE_TYPE_DEF_BY_NAME = API(TYPEDEF_BY_NAME, HTTPMethod.DELETE, HTTPStatus.NO_CONTENT)
def __init__(self, client):
self.client = client
@@ -50,9 +57,9 @@ class TypeDefClient:
try:
obj = self.client.call_api(TypeDefClient.GET_TYPEDEF_BY_GUID.format_path_with_params(guid), str)
- if not obj:
+ if obj is None:
return False
- except Exception as e:
+ except Exception:
return False
return True
@@ -61,9 +68,9 @@ class TypeDefClient:
try:
obj = self.client.call_api(TypeDefClient.GET_TYPEDEF_BY_NAME.format_path_with_params(name), str)
- if not obj:
+ if obj is None:
return False
- except Exception as e:
+ except Exception:
return False
return True
@@ -117,14 +124,14 @@ class TypeDefClient:
return self.client.call_api(TypeDefClient.DELETE_TYPE_DEF_BY_NAME.format_path_with_params(type_name))
def __get_typedef_by_name(self, name, typedef_class):
- path_type = self.__get_path_for_type(typedef_class);
- api = API(TypeDefClient.GET_BY_NAME_TEMPLATE, HttpMethod.GET, HTTPStatus.OK)
+ path_type = self.__get_path_for_type(typedef_class)
+ api = API(TypeDefClient.GET_BY_NAME_TEMPLATE, HTTPMethod.GET, HTTPStatus.OK)
return self.client.call_api(api.format_path({'path_type': path_type, 'name': name}), typedef_class)
def __get_typedef_by_guid(self, guid, typedef_class):
path_type = self.__get_path_for_type(typedef_class)
- api = API(TypeDefClient.GET_BY_GUID_TEMPLATE, HttpMethod.GET, HTTPStatus.OK)
+ api = API(TypeDefClient.GET_BY_GUID_TEMPLATE, HTTPMethod.GET, HTTPStatus.OK)
return self.client.call_api(api.format_path({'path_type': path_type, 'guid': guid}), typedef_class)
@@ -142,4 +149,4 @@ class TypeDefClient:
if issubclass(AtlasBusinessMetadataDef, typedef_class):
return "businessmetadatadef"
- return ""
\ No newline at end of file
+ return ""
diff --git a/intg/src/main/python/apache_atlas/exceptions.py b/intg/src/main/python/apache_atlas/exceptions.py
index 839befa..092a45f 100644
--- a/intg/src/main/python/apache_atlas/exceptions.py
+++ b/intg/src/main/python/apache_atlas/exceptions.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -32,10 +31,10 @@ class AtlasServiceException(Exception):
if api:
msg = "Metadata service API {method} : {path} failed".format(**{'method': api.method, 'path': api.path})
- if response.content:
- status = response.status_code if response.status_code else -1
- msg = "Metadata service API with url {url} and method {method} : failed with status {status} and " \
- "Response Body is :{response}". \
- format(**{'url': response.url, 'method': api.method, 'status': status, 'response': response.json()})
+ if response.content is not None:
+ status = response.status_code if response.status_code is not None else -1
+ msg = "Metadata service API with url {url} and method {method} : failed with status {status} and " \
+ "Response Body is :{response}". \
+ format(**{'url': response.url, 'method': api.method, 'status': status, 'response': response.json()})
Exception.__init__(self, msg)
diff --git a/intg/src/main/python/apache_atlas/model/__init__.py b/intg/src/main/python/apache_atlas/model/__init__.py
index f115594..d9984f1 100644
--- a/intg/src/main/python/apache_atlas/model/__init__.py
+++ b/intg/src/main/python/apache_atlas/model/__init__.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -15,4 +14,4 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
-# limitations under the License.
\ No newline at end of file
+# limitations under the License.
diff --git a/intg/src/main/python/apache_atlas/model/admin.py b/intg/src/main/python/apache_atlas/model/admin.py
index 3be8a94..e826f94 100644
--- a/intg/src/main/python/apache_atlas/model/admin.py
+++ b/intg/src/main/python/apache_atlas/model/admin.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,8 +15,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.instance import AtlasBase
+from apache_atlas.model.misc import AtlasBase
class AtlasAdminMetrics(AtlasBase):
@@ -28,6 +26,6 @@ class AtlasAdminMetrics(AtlasBase):
_data = attrs.get('data', {})
self.general = _data.get('general', {})
- self.tag = _data.get('tag', {})
- self.entity = _data.get('entity', {})
- self.system = _data.get('system', {})
+ self.tag = _data.get('tag', {})
+ self.entity = _data.get('entity', {})
+ self.system = _data.get('system', {})
diff --git a/intg/src/main/python/apache_atlas/model/discovery.py b/intg/src/main/python/apache_atlas/model/discovery.py
index 61a992c..2df4a39 100644
--- a/intg/src/main/python/apache_atlas/model/discovery.py
+++ b/intg/src/main/python/apache_atlas/model/discovery.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,12 +15,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
import enum
-from apache_atlas.model.enums import *
-from apache_atlas.model.instance import *
-from apache_atlas.utils import *
+from apache_atlas.model.enums import QueryType
+from apache_atlas.model.instance import AtlasEntityHeader
+from apache_atlas.model.misc import AtlasBase
+from apache_atlas.model.misc import AtlasBaseModelObject
+from apache_atlas.utils import non_null
+from apache_atlas.utils import type_coerce
+from apache_atlas.utils import type_coerce_dict
+from apache_atlas.utils import type_coerce_dict_list
+from apache_atlas.utils import type_coerce_list
class AtlasAggregationEntry(AtlasBase):
@@ -36,13 +40,13 @@ class AtlasQuickSearchResult(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.searchResults = attrs.get('searchResults')
+ self.searchResults = attrs.get('searchResults')
self.aggregationMetrics = attrs.get('aggregationMetrics')
def type_coerce_attrs(self):
super(AtlasQuickSearchResult, self).type_coerce_attrs()
- self.searchResults = type_coerce(self.searchResults, AtlasSearchResult)
+ self.searchResults = type_coerce(self.searchResults, AtlasSearchResult)
self.aggregationMetrics = type_coerce_dict_list(self.aggregationMetrics, AtlasAggregationEntry)
@@ -50,22 +54,22 @@ class AtlasSearchResult(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.queryType = non_null(attrs.get('queryType'), QueryType.BASIC.name)
+ self.queryType = non_null(attrs.get('queryType'), QueryType.BASIC.name)
self.searchParameters = attrs.get('searchParameters')
- self.queryText = attrs.get('queryText')
- self.type = attrs.get('type')
- self.classification = attrs.get('classification')
- self.entities = attrs.get('entities')
- self.attributes = attrs.get('attributes')
- self.fullTextResult = attrs.get('fullTextResult')
+ self.queryText = attrs.get('queryText')
+ self.type = attrs.get('type')
+ self.classification = attrs.get('classification')
+ self.entities = attrs.get('entities')
+ self.attributes = attrs.get('attributes')
+ self.fullTextResult = attrs.get('fullTextResult')
self.referredEntities = attrs.get('referredEntities')
self.approximateCount = non_null(attrs.get('approximateCount'), -1)
def type_coerce_attrs(self):
super(AtlasSearchResult, self).type_coerce_attrs()
- self.entities = type_coerce_list(self.entities, AtlasEntityHeader)
- self.attributes = type_coerce(self.attributes, AttributeSearchResult)
+ self.entities = type_coerce_list(self.entities, AtlasEntityHeader)
+ self.attributes = type_coerce(self.attributes, AttributeSearchResult)
self.referredEntities = type_coerce_dict(self.referredEntities, AtlasEntityHeader)
@@ -73,7 +77,7 @@ class AttributeSearchResult(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.name = attrs.get('name')
+ self.name = attrs.get('name')
self.values = attrs.get('values')
@@ -82,7 +86,7 @@ class AtlasFullTextResult(AtlasBase):
AtlasBase.__init__(self, attrs)
self.entity = attrs.get('entity')
- self.score = attrs.get('score')
+ self.score = attrs.get('score')
def type_coerce_attrs(self):
super(AtlasFullTextResult, self).type_coerce_attrs()
@@ -94,23 +98,23 @@ class AtlasSuggestionsResult(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.suggestions = attrs.get('suggestions')
+ self.suggestions = attrs.get('suggestions')
self.prefixString = attrs.get('prefixString')
- self.fieldName = attrs.get('fieldName')
+ self.fieldName = attrs.get('fieldName')
class QuickSearchParameters(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.query = attrs.get('query')
- self.typeName = attrs.get('typeName')
- self.entityFilters = attrs.get('entityFilters')
- self.includeSubTypes = attrs.get('includeSubTypes')
+ self.query = attrs.get('query')
+ self.typeName = attrs.get('typeName')
+ self.entityFilters = attrs.get('entityFilters')
+ self.includeSubTypes = attrs.get('includeSubTypes')
self.excludeDeletedEntities = attrs.get('excludeDeletedEntities')
- self.offset = attrs.get('offset')
- self.limit = attrs.get('limit')
- self.attributes = attrs.get('attributes')
+ self.offset = attrs.get('offset')
+ self.limit = attrs.get('limit')
+ self.attributes = attrs.get('attributes')
def type_coerce_attrs(self):
super(QuickSearchParameters, self).type_coerce_attrs()
@@ -122,38 +126,38 @@ class SearchParameters(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.query = attrs.get('query')
- self.typeName = attrs.get('typeName')
- self.classification = attrs.get('classification')
- self.termName = attrs.get('termName')
- self.sortBy = attrs.get('sortBy')
- self.excludeDeletedEntities = attrs.get('excludeDeletedEntities')
+ self.query = attrs.get('query')
+ self.typeName = attrs.get('typeName')
+ self.classification = attrs.get('classification')
+ self.termName = attrs.get('termName')
+ self.sortBy = attrs.get('sortBy')
+ self.excludeDeletedEntities = attrs.get('excludeDeletedEntities')
self.includeClassificationAttributes = attrs.get('includeClassificationAttributes')
- self.includeSubTypes = non_null(attrs.get('includeSubTypes'), True)
- self.includeSubClassifications = non_null(attrs.get('includeSubClassifications'), True)
- self.limit = attrs.get('limit')
- self.offset = attrs.get('offset')
- self.entityFilters = attrs.get('entityFilters')
- self.tagFilters = attrs.get('tagFilters')
- self.attributes = attrs.get('attributes')
- self.sortOrder = attrs.get('sortOrder')
+ self.includeSubTypes = non_null(attrs.get('includeSubTypes'), True)
+ self.includeSubClassifications = non_null(attrs.get('includeSubClassifications'), True)
+ self.limit = attrs.get('limit')
+ self.offset = attrs.get('offset')
+ self.entityFilters = attrs.get('entityFilters')
+ self.tagFilters = attrs.get('tagFilters')
+ self.attributes = attrs.get('attributes')
+ self.sortOrder = attrs.get('sortOrder')
def type_coerce_attrs(self):
super(SearchParameters, self).type_coerce_attrs()
self.entityFilters = type_coerce(self.entityFilters, FilterCriteria)
- self.tagFilters = type_coerce(self.tagFilters, FilterCriteria)
+ self.tagFilters = type_coerce(self.tagFilters, FilterCriteria)
class FilterCriteria(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.attributeName = attrs.get('attributeName')
- self.operator = attrs.get('operator')
+ self.attributeName = attrs.get('attributeName')
+ self.operator = attrs.get('operator')
self.attributeValue = attrs.get('attributeValue')
- self.condition = attrs.get('condition')
- self.criterion = attrs.get('criterion')
+ self.condition = attrs.get('condition')
+ self.criterion = attrs.get('criterion')
def type_coerce_attrs(self):
super(FilterCriteria, self).type_coerce_attrs()
@@ -165,11 +169,11 @@ class AtlasUserSavedSearch(AtlasBaseModelObject):
def __init__(self, attrs={}):
AtlasBaseModelObject.__init__(self, attrs)
- self.ownerName = attrs.get('ownerName')
- self.name = attrs.get('name')
- self.searchType = attrs.get('searchType')
+ self.ownerName = attrs.get('ownerName')
+ self.name = attrs.get('name')
+ self.searchType = attrs.get('searchType')
self.searchParameters = attrs.get('searchParameters')
- self.uiParameters = attrs.get('uiParameters')
+ self.uiParameters = attrs.get('uiParameters')
def type_coerce_attrs(self):
super(AtlasUserSavedSearch, self).type_coerce_attrs()
diff --git a/intg/src/main/python/apache_atlas/model/enums.py b/intg/src/main/python/apache_atlas/model/enums.py
index a5064f5..4f308ed 100644
--- a/intg/src/main/python/apache_atlas/model/enums.py
+++ b/intg/src/main/python/apache_atlas/model/enums.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,109 +15,108 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
import enum
class AtlasTermAssignmentStatus(enum.Enum):
DISCOVERED = 0
- PROPOSED = 1
- IMPORTED = 2
- VALIDATED = 3
+ PROPOSED = 1
+ IMPORTED = 2
+ VALIDATED = 3
DEPRECATED = 4
- OBSOLETE = 5
- OTHER = 6
+ OBSOLETE = 5
+ OTHER = 6
class AtlasTermRelationshipStatus(enum.Enum):
- DRAFT = 0
- ACTIVE = 1
+ DRAFT = 0
+ ACTIVE = 1
DEPRECATED = 2
- OBSOLETE = 3
- OTHER = 99
+ OBSOLETE = 3
+ OTHER = 99
class TypeCategory(enum.Enum):
- PRIMITIVE = 0
- OBJECT_ID_TYPE = 1
- ENUM = 2
- STRUCT = 3
- CLASSIFICATION = 4
- ENTITY = 5
- ARRAY = 6
- MAP = 7
- RELATIONSHIP = 8
+ PRIMITIVE = 0
+ OBJECT_ID_TYPE = 1
+ ENUM = 2
+ STRUCT = 3
+ CLASSIFICATION = 4
+ ENTITY = 5
+ ARRAY = 6
+ MAP = 7
+ RELATIONSHIP = 8
BUSINESS_METADATA = 9
class Cardinality(enum.Enum):
SINGLE = 0
- LIST = 1
- SET = 2
+ LIST = 1
+ SET = 2
class Condition(enum.Enum):
AND = 0
- OR = 1
+ OR = 1
class EntityOperation(enum.Enum):
- CREATE = 0
- UPDATE = 1
+ CREATE = 0
+ UPDATE = 1
PARTIAL_UPDATE = 2
- DELETE = 3
- PURGE = 4
+ DELETE = 3
+ PURGE = 4
class EntityStatus(enum.Enum):
- ACTIVE = 0
+ ACTIVE = 0
DELETED = 1
- PURGED = 2
+ PURGED = 2
class IndexType(enum.Enum):
DEFAULT = 0
- STRING = 1
+ STRING = 1
class LineageDirection(enum.Enum):
- INPUT = 0
+ INPUT = 0
OUTPUT = 1
- BOTH = 2
+ BOTH = 2
class Operator(enum.Enum):
- LT = ("<", "lt")
- GT = ('>', 'gt')
- LTE = ('<=', 'lte')
- GTE = ('>=', 'gte')
- EQ = ('=', 'eq')
- NEQ = ('!=', 'neq')
- IN = ('in', 'IN')
- LIKE = ('like', 'LIKE')
- STARTS_WITH = ('startsWith', 'STARTSWITH', 'begins_with', 'BEGINS_WITH')
- ENDS_WITH = ('endsWith', 'ENDSWITH', 'ends_with', 'ENDS_WITH')
- CONTAINS = ('contains', 'CONTAINS')
+ LT = ("<", "lt")
+ GT = ('>', 'gt')
+ LTE = ('<=', 'lte')
+ GTE = ('>=', 'gte')
+ EQ = ('=', 'eq')
+ NEQ = ('!=', 'neq')
+ IN = ('in', 'IN')
+ LIKE = ('like', 'LIKE')
+ STARTS_WITH = ('startsWith', 'STARTSWITH', 'begins_with', 'BEGINS_WITH')
+ ENDS_WITH = ('endsWith', 'ENDSWITH', 'ends_with', 'ENDS_WITH')
+ CONTAINS = ('contains', 'CONTAINS')
NOT_CONTAINS = ('not_contains', 'NOT_CONTAINS')
CONTAINS_ANY = ('containsAny', 'CONTAINSANY', 'contains_any', 'CONTAINS_ANY')
CONTAINS_ALL = ('containsAll', 'CONTAINSALL', 'contains_all', 'CONTAINS_ALL')
- IS_NULL = ('isNull', 'ISNULL', 'is_null', 'IS_NULL')
- NOT_NULL = ('notNull', 'NOTNULL', 'not_null', 'NOT_NULL')
+ IS_NULL = ('isNull', 'ISNULL', 'is_null', 'IS_NULL')
+ NOT_NULL = ('notNull', 'NOTNULL', 'not_null', 'NOT_NULL')
class PropagateTags(enum.Enum):
- NONE = 0
+ NONE = 0
ONE_TO_TWO = 1
TWO_TO_ONE = 2
- BOTH = 3
+ BOTH = 3
class QueryType(enum.Enum):
- DSL = 0
- FULL_TEXT = 1
- GREMLIN = 2
- BASIC = 3
- ATTRIBUTE = 4
+ DSL = 0
+ FULL_TEXT = 1
+ GREMLIN = 2
+ BASIC = 3
+ ATTRIBUTE = 4
RELATIONSHIP = 5
@@ -129,21 +127,21 @@ class RelationshipCategory(enum.Enum):
class RelationshipStatus(enum.Enum):
- ACTIVE = 0
+ ACTIVE = 0
DELETED = 1
class SavedSearchType(enum.Enum):
- BASIC = 0
+ BASIC = 0
ADVANCED = 1
class SortOrder(enum.Enum):
- ASCENDING = 0
+ ASCENDING = 0
DESCENDING = 1
class SortType(enum.Enum):
NONE = 0
- ASC = 1
+ ASC = 1
DESC = 2
diff --git a/intg/src/main/python/apache_atlas/model/glossary.py b/intg/src/main/python/apache_atlas/model/glossary.py
index c81e333..7a0faac 100644
--- a/intg/src/main/python/apache_atlas/model/glossary.py
+++ b/intg/src/main/python/apache_atlas/model/glossary.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,43 +15,45 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-import apache_atlas.model.instance
-
-from apache_atlas.model.misc import *
-from apache_atlas.utils import *
+from apache_atlas.model.instance import AtlasBase
+from apache_atlas.model.instance import AtlasClassification
+from apache_atlas.model.instance import AtlasRelatedObjectId
+from apache_atlas.model.misc import AtlasBaseModelObject
+from apache_atlas.utils import type_coerce
+from apache_atlas.utils import type_coerce_dict
+from apache_atlas.utils import type_coerce_list
class AtlasGlossaryBaseObject(AtlasBaseModelObject):
def __init__(self, attrs={}):
AtlasBaseModelObject.__init__(self, attrs)
- self.qualifiedName = attrs.get('qualifiedName')
- self.name = attrs.get('name')
- self.shortDescription = attrs.get('shortDescription')
- self.longDescription = attrs.get('longDescription')
+ self.qualifiedName = attrs.get('qualifiedName')
+ self.name = attrs.get('name')
+ self.shortDescription = attrs.get('shortDescription')
+ self.longDescription = attrs.get('longDescription')
self.additionalAttributes = attrs.get('additionalAttributes')
- self.classifications = attrs.get('classifications')
+ self.classifications = attrs.get('classifications')
def type_coerce_attrs(self):
super(AtlasGlossaryBaseObject, self).type_coerce_attrs()
- self.classifications = type_coerce_list(self.classifications, apache_atlas.model.instance.AtlasClassification)
+ self.classifications = type_coerce_list(self.classifications, AtlasClassification)
class AtlasGlossary(AtlasGlossaryBaseObject):
def __init__(self, attrs={}):
AtlasGlossaryBaseObject.__init__(self, attrs)
- self.language = attrs.get('language')
- self.usage = attrs.get('usage')
- self.terms = attrs.get('terms')
+ self.language = attrs.get('language')
+ self.usage = attrs.get('usage')
+ self.terms = attrs.get('terms')
self.categories = attrs.get('categories')
def type_coerce_attrs(self):
super(AtlasGlossary, self).type_coerce_attrs()
- self.terms = type_coerce_list(self.classifications, AtlasRelatedTermHeader)
+ self.terms = type_coerce_list(self.classifications, AtlasRelatedTermHeader)
self.categories = type_coerce_list(self.categories, AtlasRelatedCategoryHeader)
@@ -60,13 +61,13 @@ class AtlasGlossaryExtInfo(AtlasGlossary):
def __init__(self, attrs={}):
AtlasGlossary.__init__(self, attrs)
- self.termInfo = attrs.get('termInfo')
+ self.termInfo = attrs.get('termInfo')
self.categoryInfo = attrs.get('categoryInfo')
def type_coerce_attrs(self):
super(AtlasGlossaryExtInfo, self).type_coerce_attrs()
- self.termInfo = type_coerce_dict(self.termInfo, AtlasGlossaryTerm)
+ self.termInfo = type_coerce_dict(self.termInfo, AtlasGlossaryTerm)
self.categoryInfo = type_coerce_dict(self.categoryInfo, AtlasGlossaryCategory)
@@ -78,7 +79,7 @@ class AtlasGlossaryCategory(AtlasGlossaryBaseObject):
self.anchor = attrs.get('anchor')
# Category hierarchy links
- self.parentCategory = attrs.get('parentCategory')
+ self.parentCategory = attrs.get('parentCategory')
self.childrenCategories = attrs.get('childrenCategories')
# Terms associated with this category
@@ -87,10 +88,10 @@ class AtlasGlossaryCategory(AtlasGlossaryBaseObject):
def type_coerce_attrs(self):
super(AtlasGlossaryCategory, self).type_coerce_attrs()
- self.anchor = type_coerce(self.anchor, AtlasGlossaryHeader)
- self.parentCategory = type_coerce(self.parentCategory, AtlasRelatedCategoryHeader)
+ self.anchor = type_coerce(self.anchor, AtlasGlossaryHeader)
+ self.parentCategory = type_coerce(self.parentCategory, AtlasRelatedCategoryHeader)
self.childrenCategories = type_coerce_list(self.childrenCategories, AtlasRelatedCategoryHeader)
- self.terms = type_coerce_list(self.terms, AtlasRelatedTermHeader)
+ self.terms = type_coerce_list(self.terms, AtlasRelatedTermHeader)
class AtlasGlossaryTerm(AtlasGlossaryBaseObject):
@@ -98,14 +99,14 @@ class AtlasGlossaryTerm(AtlasGlossaryBaseObject):
AtlasGlossaryBaseObject.__init__(self, attrs)
# Core attributes
- self.examples = attrs.get('examples')
+ self.examples = attrs.get('examples')
self.abbreviation = attrs.get('abbreviation')
- self.usage = attrs.get('usage')
+ self.usage = attrs.get('usage')
# Attributes derived from relationships
- self.anchor = attrs.get('anchor')
+ self.anchor = attrs.get('anchor')
self.assignedEntities = attrs.get('assignedEntities')
- self.categories = attrs.get('categories')
+ self.categories = attrs.get('categories')
# Related Terms
self.seeAlso = attrs.get('seeAlso')
@@ -117,43 +118,43 @@ class AtlasGlossaryTerm(AtlasGlossaryBaseObject):
self.antonyms = attrs.get('antonyms')
# Term preference
- self.preferredTerms = attrs.get('preferredTerms')
+ self.preferredTerms = attrs.get('preferredTerms')
self.preferredToTerms = attrs.get('preferredToTerms')
# Term replacements
self.replacementTerms = attrs.get('replacementTerms')
- self.replacedBy = attrs.get('replacedBy')
+ self.replacedBy = attrs.get('replacedBy')
# Term translations
self.translationTerms = attrs.get('translationTerms')
- self.translatedTerms = attrs.get('translatedTerms')
+ self.translatedTerms = attrs.get('translatedTerms')
# Term classification
- self.isA = attrs.get('isA')
+ self.isA = attrs.get('isA')
self.classifies = attrs.get('classifies')
# Values for terms
- self.validValues = attrs.get('validValues')
+ self.validValues = attrs.get('validValues')
self.validValuesFor = attrs.get('validValuesFor')
def type_coerce_attrs(self):
super(AtlasGlossaryTerm, self).type_coerce_attrs()
- self.anchor = type_coerce(self.anchor, AtlasGlossaryHeader)
- self.assignedEntities = type_coerce_list(self.assignedEntities, apache_atlas.model.instance.AtlasRelatedObjectId)
- self.categories = type_coerce_list(self.categories, AtlasTermCategorizationHeader)
- self.seeAlso = type_coerce_list(self.seeAlso, AtlasRelatedTermHeader)
- self.synonyms = type_coerce_list(self.synonyms, AtlasRelatedTermHeader)
- self.antonyms = type_coerce_list(self.antonyms, AtlasRelatedTermHeader)
- self.preferredTerms = type_coerce_list(self.preferredTerms, AtlasRelatedTermHeader)
+ self.anchor = type_coerce(self.anchor, AtlasGlossaryHeader)
+ self.assignedEntities = type_coerce_list(self.assignedEntities, AtlasRelatedObjectId)
+ self.categories = type_coerce_list(self.categories, AtlasTermCategorizationHeader)
+ self.seeAlso = type_coerce_list(self.seeAlso, AtlasRelatedTermHeader)
+ self.synonyms = type_coerce_list(self.synonyms, AtlasRelatedTermHeader)
+ self.antonyms = type_coerce_list(self.antonyms, AtlasRelatedTermHeader)
+ self.preferredTerms = type_coerce_list(self.preferredTerms, AtlasRelatedTermHeader)
self.preferredToTerms = type_coerce_list(self.preferredToTerms, AtlasRelatedTermHeader)
self.replacementTerms = type_coerce_list(self.replacementTerms, AtlasRelatedTermHeader)
- self.replacedBy = type_coerce_list(self.replacedBy, AtlasRelatedTermHeader)
+ self.replacedBy = type_coerce_list(self.replacedBy, AtlasRelatedTermHeader)
self.translationTerms = type_coerce_list(self.translationTerms, AtlasRelatedTermHeader)
- self.isA = type_coerce_list(self.isA, AtlasRelatedTermHeader)
- self.classifies = type_coerce_list(self.classifies, AtlasRelatedTermHeader)
- self.validValues = type_coerce_list(self.validValues, AtlasRelatedTermHeader)
- self.validValuesFor = type_coerce_list(self.validValuesFor, AtlasRelatedTermHeader)
+ self.isA = type_coerce_list(self.isA, AtlasRelatedTermHeader)
+ self.classifies = type_coerce_list(self.classifies, AtlasRelatedTermHeader)
+ self.validValues = type_coerce_list(self.validValues, AtlasRelatedTermHeader)
+ self.validValuesFor = type_coerce_list(self.validValuesFor, AtlasRelatedTermHeader)
class AtlasGlossaryHeader(AtlasBase):
@@ -162,46 +163,47 @@ class AtlasGlossaryHeader(AtlasBase):
self.glossaryGuid = attrs.get('glossaryGuid')
self.relationGuid = attrs.get('relationGuid')
- self.displayText = attrs.get('displayText')
+ self.displayText = attrs.get('displayText')
class AtlasRelatedCategoryHeader(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.categoryGuid = attrs.get('categoryGuid')
+ self.categoryGuid = attrs.get('categoryGuid')
self.parentCategoryGuid = attrs.get('parentCategoryGuid')
- self.relationGuid = attrs.get('relationGuid')
- self.displayText = attrs.get('displayText')
- self.description = attrs.get('description')
+ self.relationGuid = attrs.get('relationGuid')
+ self.displayText = attrs.get('displayText')
+ self.description = attrs.get('description')
class AtlasRelatedTermHeader(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.termGuid = attrs.get('termGuid')
+ self.termGuid = attrs.get('termGuid')
self.relationGuid = attrs.get('relationGuid')
- self.displayText = attrs.get('displayText')
- self.description = attrs.get('description')
- self.expression = attrs.get('expression')
- self.steward = attrs.get('steward')
- self.source = attrs.get('source')
- self.status = attrs.get('status')
+ self.displayText = attrs.get('displayText')
+ self.description = attrs.get('description')
+ self.expression = attrs.get('expression')
+ self.steward = attrs.get('steward')
+ self.source = attrs.get('source')
+ self.status = attrs.get('status')
+
class AtlasTermAssignmentHeader(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.termGuid = attrs.get('termGuid')
+ self.termGuid = attrs.get('termGuid')
self.relationGuid = attrs.get('relationGuid')
- self.description = attrs.get('description')
- self.displayText = attrs.get('displayText')
- self.expression = attrs.get('expression')
- self.createdBy = attrs.get('createdBy')
- self.steward = attrs.get('steward')
- self.source = attrs.get('source')
- self.confidence = attrs.get('confidence')
+ self.description = attrs.get('description')
+ self.displayText = attrs.get('displayText')
+ self.expression = attrs.get('expression')
+ self.createdBy = attrs.get('createdBy')
+ self.steward = attrs.get('steward')
+ self.source = attrs.get('source')
+ self.confidence = attrs.get('confidence')
class AtlasTermCategorizationHeader(AtlasBase):
@@ -210,8 +212,6 @@ class AtlasTermCategorizationHeader(AtlasBase):
self.categoryGuid = attrs.get('categoryGuid')
self.relationGuid = attrs.get('relationGuid')
- self.description = attrs.get('description')
- self.displayText = attrs.get('displayText')
- self.status = attrs.get('status')
-
-
+ self.description = attrs.get('description')
+ self.displayText = attrs.get('displayText')
+ self.status = attrs.get('status')
diff --git a/intg/src/main/python/apache_atlas/model/instance.py b/intg/src/main/python/apache_atlas/model/instance.py
index 89dbe35..707d5bb 100644
--- a/intg/src/main/python/apache_atlas/model/instance.py
+++ b/intg/src/main/python/apache_atlas/model/instance.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,23 +15,28 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-import apache_atlas.model.glossary
-
-from apache_atlas.model.enums import *
-from apache_atlas.model.misc import *
-from apache_atlas.utils import *
+from apache_atlas.model.enums import EntityStatus
+from apache_atlas.model.glossary import AtlasTermAssignmentHeader
+from apache_atlas.model.misc import AtlasBase
+from apache_atlas.model.misc import next_id
+from apache_atlas.model.misc import Plist
+from apache_atlas.model.misc import TimeBoundary
+from apache_atlas.utils import non_null
+from apache_atlas.utils import type_coerce
+from apache_atlas.utils import type_coerce_dict
+from apache_atlas.utils import type_coerce_dict_list
+from apache_atlas.utils import type_coerce_list
class AtlasStruct(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.typeName = attrs.get('typeName')
+ self.typeName = attrs.get('typeName')
self.attributes = attrs.get('attributes')
def get_attribute(self, name):
- return self.attributes[name] if self.attributes and name in self.attributes else None
+ return self.attributes[name] if self.attributes is not None and name in self.attributes else None
def set_attribute(self, name, value):
if self.attributes is None:
@@ -41,7 +45,7 @@ class AtlasStruct(AtlasBase):
self.attributes[name] = value
def remove_attribute(self, name):
- if name and self.attributes and name in self.attributes:
+ if name and self.attributes is not None and name in self.attributes:
del self.attributes[name]
@@ -49,13 +53,13 @@ class AtlasEntity(AtlasStruct):
def __init__(self, attrs={}):
AtlasStruct.__init__(self, attrs)
- self.guid = attrs.get('guid')
+ self.guid = attrs.get('guid')
self.relationshipAttributes = attrs.get('relationshipAttributes')
- self.classifications = attrs.get('classifications')
- self.meanings = attrs.get('meanings')
- self.customAttributes = attrs.get('customAttributes')
- self.businessAttributes = attrs.get('businessAttributes')
- self.labels = attrs.get('labels')
+ self.classifications = attrs.get('classifications')
+ self.meanings = attrs.get('meanings')
+ self.customAttributes = attrs.get('customAttributes')
+ self.businessAttributes = attrs.get('businessAttributes')
+ self.labels = attrs.get('labels')
if self.guid is None:
self.guid = next_id()
@@ -64,10 +68,11 @@ class AtlasEntity(AtlasStruct):
super(AtlasEntity, self).type_coerce_attrs()
self.classifications = type_coerce_list(self.classifications, AtlasClassification)
- self.meanings = type_coerce_list(self.meanings, apache_atlas.model.glossary.AtlasTermAssignmentHeader)
+ self.meanings = type_coerce_list(self.meanings, AtlasTermAssignmentHeader)
def get_relationship_attribute(self, name):
- return self.relationshipAttributes[name] if self.relationshipAttributes and name in self.relationshipAttributes else None
+ return self.relationshipAttributes[
+ name] if self.relationshipAttributes is not None and name in self.relationshipAttributes else None
def set_relationship_attribute(self, name, value):
if self.relationshipAttributes is None:
@@ -76,7 +81,7 @@ class AtlasEntity(AtlasStruct):
self.relationshipAttributes[name] = value
def remove_relationship_attribute(self, name):
- if name and self.relationshipAttributes and name in self.relationshipAttributes:
+ if name and self.relationshipAttributes is not None and name in self.relationshipAttributes:
del self.relationshipAttributes[name]
@@ -92,7 +97,8 @@ class AtlasEntityExtInfo(AtlasBase):
self.referredEntities = type_coerce_dict(self.referredEntities, AtlasEntity)
def get_referenced_entity(self, guid):
- return self.referredEntities[guid] if self.referredEntities and guid in self.referredEntities else None
+ return self.referredEntities[
+ guid] if self.referredEntities is not None and guid in self.referredEntities else None
def add_referenced_entity(self, entity):
if self.referredEntities is None:
@@ -100,6 +106,7 @@ class AtlasEntityExtInfo(AtlasBase):
self.referredEntities[entity.guid] = entity
+
class AtlasEntityWithExtInfo(AtlasEntityExtInfo):
def __init__(self, attrs={}):
AtlasEntityExtInfo.__init__(self, attrs)
@@ -134,35 +141,34 @@ class AtlasEntityHeader(AtlasStruct):
def __init__(self, attrs={}):
AtlasStruct.__init__(self, attrs)
- self.guid = attrs.get('guid')
- self.status = non_null(attrs.get('status'), EntityStatus.ACTIVE.name)
- self.displayText = attrs.get('displayText')
+ self.guid = attrs.get('guid')
+ self.status = non_null(attrs.get('status'), EntityStatus.ACTIVE.name)
+ self.displayText = attrs.get('displayText')
self.classificationNames = attrs.get('classificationNames')
- self.classifications = attrs.get('classifications')
- self.meaningNames = attrs.get('meaningNames')
- self.meanings = attrs.get('.meanings')
- self.isIncomplete = non_null(attrs.get('isIncomplete'), False)
- self.labels = attrs.get('labels')
+ self.classifications = attrs.get('classifications')
+ self.meaningNames = attrs.get('meaningNames')
+ self.meanings = attrs.get('.meanings')
+ self.isIncomplete = non_null(attrs.get('isIncomplete'), False)
+ self.labels = attrs.get('labels')
if self.guid is None:
self.guid = next_id()
-
def type_coerce_attrs(self):
super(AtlasEntityHeader, self).type_coerce_attrs()
self.classifications = type_coerce_list(self.classifications, AtlasClassification)
- self.meanings = type_coerce_list(self.meanings, apache_atlas.model.glossary.AtlasTermAssignmentHeader)
+ self.meanings = type_coerce_list(self.meanings, AtlasTermAssignmentHeader)
class AtlasClassification(AtlasStruct):
def __init__(self, attrs={}):
AtlasStruct.__init__(self, attrs)
- self.entityGuid = attrs.get('entityGuid')
- self.entityStatus = non_null(attrs.get('entityStatus'), EntityStatus.ACTIVE.name)
- self.propagate = attrs.get('propagate');
- self.validityPeriods = attrs.get('validityPeriods')
+ self.entityGuid = attrs.get('entityGuid')
+ self.entityStatus = non_null(attrs.get('entityStatus'), EntityStatus.ACTIVE.name)
+ self.propagate = attrs.get('propagate')
+ self.validityPeriods = attrs.get('validityPeriods')
self.removePropagationsOnEntityDelete = attrs.get('removePropagationsOnEntityDelete')
def type_coerce_attrs(self):
@@ -175,8 +181,8 @@ class AtlasObjectId(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.guid = attrs.get('guid')
- self.typeName = attrs.get('typeName')
+ self.guid = attrs.get('guid')
+ self.typeName = attrs.get('typeName')
self.uniqueAttributes = attrs.get('uniqueAttributes')
@@ -184,11 +190,11 @@ class AtlasRelatedObjectId(AtlasObjectId):
def __init__(self, attrs={}):
AtlasObjectId.__init__(self, attrs)
- self.entityStatus = attrs.get('entityStatus')
- self.displayText = attrs.get('displayText')
- self.relationshipType = attrs.get('relationshipType')
- self.relationshipGuid = attrs.get('relationshipGuid')
- self.relationshipStatus = attrs.get('relationshipStatus')
+ self.entityStatus = attrs.get('entityStatus')
+ self.displayText = attrs.get('displayText')
+ self.relationshipType = attrs.get('relationshipType')
+ self.relationshipGuid = attrs.get('relationshipGuid')
+ self.relationshipStatus = attrs.get('relationshipStatus')
self.relationshipAttributes = attrs.get('relationshipAttributes')
def type_coerce_attrs(self):
@@ -198,13 +204,13 @@ class AtlasRelatedObjectId(AtlasObjectId):
class AtlasClassifications(Plist):
- def __init__(self, attrs={}):
+ def __init__(self, attrs={}):
Plist.__init__(self, attrs)
def type_coerce_attrs(self):
super(AtlasClassifications, self).type_coerce_attrs()
- PList.list = type_coerce_list(Plist.list, AtlasClassification)
+ Plist.list = type_coerce_list(Plist.list, AtlasClassification)
class AtlasEntityHeaders(AtlasBase):
@@ -251,7 +257,7 @@ class EntityMutation(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.op = attrs.get('op')
+ self.op = attrs.get('op')
self.entity = attrs.get('entity')
def type_coerce_attrs(self):
@@ -266,20 +272,20 @@ class AtlasCheckStateRequest(AtlasBase):
self.entityGuids = attrs.get('entityGuids')
self.entityTypes = attrs.get('entityTypes')
- self.fixIssues = attrs.get('fixIssues')
+ self.fixIssues = attrs.get('fixIssues')
class AtlasCheckStateResult(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.entitiesScanned = attrs.get('entitiesScanned')
- self.entitiesOk = attrs.get('entitiesOk')
- self.entitiesFixed = attrs.get('entitiesFixed')
+ self.entitiesScanned = attrs.get('entitiesScanned')
+ self.entitiesOk = attrs.get('entitiesOk')
+ self.entitiesFixed = attrs.get('entitiesFixed')
self.entitiesPartiallyFixed = attrs.get('entitiesPartiallyFixed')
- self.entitiesNotFixed = attrs.get('entitiesNotFixed')
- self.state = attrs.get('state')
- self.entities = attrs.get('entities')
+ self.entitiesNotFixed = attrs.get('entitiesNotFixed')
+ self.state = attrs.get('state')
+ self.entities = attrs.get('entities')
def type_coerce_attrs(self):
super(AtlasCheckStateResult, self).type_coerce_attrs()
@@ -291,9 +297,9 @@ class AtlasEntityState(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.guid = attrs.get('guid')
+ self.guid = attrs.get('guid')
self.typeName = attrs.get('typeName')
- self.name = attrs.get('name')
- self.status = attrs.get('status')
- self.state = attrs.get('state')
- self.issues = attrs.get('issues')
+ self.name = attrs.get('name')
+ self.status = attrs.get('status')
+ self.state = attrs.get('state')
+ self.issues = attrs.get('issues')
diff --git a/intg/src/main/python/apache_atlas/model/lineage.py b/intg/src/main/python/apache_atlas/model/lineage.py
index 01ba08a..180989d 100644
--- a/intg/src/main/python/apache_atlas/model/lineage.py
+++ b/intg/src/main/python/apache_atlas/model/lineage.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,33 +15,33 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.instance import *
-from apache_atlas.utils import *
+from apache_atlas.model.instance import AtlasBase
+from apache_atlas.model.instance import AtlasEntityHeader
+from apache_atlas.utils import type_coerce_dict
+from apache_atlas.utils import type_coerce_list
class AtlasLineageInfo(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.baseEntityGuid = attrs.get('baseEntityGuid')
+ self.baseEntityGuid = attrs.get('baseEntityGuid')
self.lineageDirection = attrs.get('lineageDirection')
- self.lineageDepth = attrs.get('lineageDepth')
- self.guidEntityMap = attrs.get('guidEntityMap')
- self.relations = attrs.get('relations')
-
+ self.lineageDepth = attrs.get('lineageDepth')
+ self.guidEntityMap = attrs.get('guidEntityMap')
+ self.relations = attrs.get('relations')
def type_coerce_attrs(self):
super(AtlasLineageInfo, self).type_coerce_attrs()
self.guidEntityMap = type_coerce_dict(self.guidEntityMap, AtlasEntityHeader)
- self.relations = type_coerce_list(self.relations, LineageRelation)
+ self.relations = type_coerce_list(self.relations, LineageRelation)
class LineageRelation(AtlasBase):
def __init__(self, attrs):
AtlasBase.__init__(self, attrs)
- self.fromEntityId = attrs.get('fromEntityId')
- self.toEntityId = attrs.get('toEntityId')
+ self.fromEntityId = attrs.get('fromEntityId')
+ self.toEntityId = attrs.get('toEntityId')
self.relationshipId = attrs.get('relationshipId')
diff --git a/intg/src/main/python/apache_atlas/model/misc.py b/intg/src/main/python/apache_atlas/model/misc.py
index 23d0d2f..f4d9c1c 100644
--- a/intg/src/main/python/apache_atlas/model/misc.py
+++ b/intg/src/main/python/apache_atlas/model/misc.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,11 +15,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
import json
import sys
-from apache_atlas.utils import *
+from apache_atlas.utils import next_id
+from apache_atlas.utils import non_null
class AtlasBase(dict):
@@ -50,6 +49,7 @@ class AtlasBase(dict):
def type_coerce_attrs(self):
pass
+
class AtlasBaseModelObject(AtlasBase):
def __init__(self, members):
AtlasBase.__init__(self, members)
@@ -61,24 +61,24 @@ class AtlasBaseModelObject(AtlasBase):
class TimeBoundary(AtlasBase):
- def __init__(self, attrs={}):
+ def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
self.startTime = attrs.get('startTime')
- self.endTime = attrs.get('endTime')
- self.timeZone = attrs.get('timeZone')
+ self.endTime = attrs.get('endTime')
+ self.timeZone = attrs.get('timeZone')
class Plist(AtlasBase):
- def __init__(self, attrs={}):
+ def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.list = non_null(attrs.get('list'), [])
+ self.list = non_null(attrs.get('list'), [])
self.startIndex = non_null(attrs.get('startIndex'), 0)
- self.pageSize = non_null(attrs.get('pageSize'), 0)
+ self.pageSize = non_null(attrs.get('pageSize'), 0)
self.totalCount = non_null(attrs.get('totalCount'), 0)
- self.sortBy = attrs.get('sortBy')
- self.sortType = attrs.get('sortType')
+ self.sortBy = attrs.get('sortBy')
+ self.sortType = attrs.get('sortType')
class SearchFilter(AtlasBase):
@@ -86,5 +86,5 @@ class SearchFilter(AtlasBase):
AtlasBase.__init__(self, attrs)
self.startIndex = non_null(attrs.get('startIndex'), 0)
- self.maxsize = non_null(attrs.get('maxsize'), sys.maxsize)
- self.getCount = non_null(attrs.get('getCount'), True)
+ self.maxsize = non_null(attrs.get('maxsize'), sys.maxsize)
+ self.getCount = non_null(attrs.get('getCount'), True)
diff --git a/intg/src/main/python/apache_atlas/model/profile.py b/intg/src/main/python/apache_atlas/model/profile.py
index 4c27702..7ef2bf1 100644
--- a/intg/src/main/python/apache_atlas/model/profile.py
+++ b/intg/src/main/python/apache_atlas/model/profile.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,20 +15,20 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.discovery import *
-from apache_atlas.utils import *
+from apache_atlas.model.discovery import SearchParameters
+from apache_atlas.model.misc import AtlasBaseModelObject
+from apache_atlas.utils import type_coerce
class AtlasUserSavedSearch(AtlasBaseModelObject):
def __init__(self, attrs={}):
AtlasBaseModelObject.__init__(self, attrs)
- self.ownerName = attrs.get('ownerName')
- self.name = attrs.get('name')
- self.searchType = attrs.get('searchType')
+ self.ownerName = attrs.get('ownerName')
+ self.name = attrs.get('name')
+ self.searchType = attrs.get('searchType')
self.searchParameters = attrs.get('searchParameters')
- self.uiParameters = attrs.get('uiParameters')
+ self.uiParameters = attrs.get('uiParameters')
def type_coerce_attrs(self):
super(AtlasUserSavedSearch, self).type_coerce_attrs()
diff --git a/intg/src/main/python/apache_atlas/model/relationship.py b/intg/src/main/python/apache_atlas/model/relationship.py
index 58bfd1b..2a32811 100644
--- a/intg/src/main/python/apache_atlas/model/relationship.py
+++ b/intg/src/main/python/apache_atlas/model/relationship.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,49 +15,55 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
-from apache_atlas.model.instance import *
-from apache_atlas.utils import *
+from apache_atlas.model.instance import AtlasClassification
+from apache_atlas.model.instance import AtlasEntityHeader
+from apache_atlas.model.instance import AtlasObjectId
+from apache_atlas.model.instance import AtlasStruct
+from apache_atlas.model.misc import AtlasBase
+from apache_atlas.utils import type_coerce
+from apache_atlas.utils import type_coerce_dict
+from apache_atlas.utils import type_coerce_list
class AtlasRelationship(AtlasStruct):
def __init__(self, attrs={}):
AtlasStruct.__init__(self, attrs)
- self.guid = attrs.get('guid')
- self.homeId = attrs.get('homeId')
- self.provenanceType = attrs.get('provenanceType')
- self.end1 = attrs.get('end1')
- self.end2 = attrs.get('end2')
- self.label = attrs.get('label')
- self.propagateTags = attrs.get('propagateTags')
- self.status = attrs.get('status')
- self.createdBy = attrs.get('createdBy')
- self.updatedBy = attrs.get('updatedBy')
- self.createTime = attrs.get('createTime')
- self.updateTime = attrs.get('updateTime')
- self.version = attrs.get('version')
- self.propagatedClassifications = attrs.get('propagatedClassifications')
+ self.guid = attrs.get('guid')
+ self.homeId = attrs.get('homeId')
+ self.provenanceType = attrs.get('provenanceType')
+ self.end1 = attrs.get('end1')
+ self.end2 = attrs.get('end2')
+ self.label = attrs.get('label')
+ self.propagateTags = attrs.get('propagateTags')
+ self.status = attrs.get('status')
+ self.createdBy = attrs.get('createdBy')
+ self.updatedBy = attrs.get('updatedBy')
+ self.createTime = attrs.get('createTime')
+ self.updateTime = attrs.get('updateTime')
+ self.version = attrs.get('version')
+ self.propagatedClassifications = attrs.get('propagatedClassifications')
self.blockedPropagatedClassifications = attrs.get('blockedPropagatedClassifications')
def type_coerce_attrs(self):
super(AtlasRelationship, self).type_coerce_attrs()
- self.end1 = type_coerce(self.end1, AtlasObjectId)
- self.end2 = type_coerce(self.end2, AtlasObjectId)
- self.propagatedClassifications = type_coerce_list(self.propagatedClassifications, AtlasClassification)
- self.blockedPropagatedClassifications = type_coerce_list(self.blockedPropagatedClassifications, AtlasClassification)
+ self.end1 = type_coerce(self.end1, AtlasObjectId)
+ self.end2 = type_coerce(self.end2, AtlasObjectId)
+ self.propagatedClassifications = type_coerce_list(self.propagatedClassifications, AtlasClassification)
+ self.blockedPropagatedClassifications = type_coerce_list(
+ self.blockedPropagatedClassifications, AtlasClassification)
class AtlasRelationshipWithExtInfo(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.relationship = attrs.get('relationship')
+ self.relationship = attrs.get('relationship')
self.referredEntities = attrs.get('referredEntities')
def type_coerce_attrs(self):
super(AtlasBase, self).type_coerce_attrs()
- self.relationship = type_coerce(self.relationship, AtlasRelationship)
+ self.relationship = type_coerce(self.relationship, AtlasRelationship)
self.referredEntities = type_coerce_dict(self.referredEntities, AtlasEntityHeader)
diff --git a/intg/src/main/python/apache_atlas/model/typedef.py b/intg/src/main/python/apache_atlas/model/typedef.py
index f6fdf1a..079f714 100644
--- a/intg/src/main/python/apache_atlas/model/typedef.py
+++ b/intg/src/main/python/apache_atlas/model/typedef.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,13 +15,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
import logging
-from apache_atlas.model.enums import *
-from apache_atlas.model.misc import *
-from apache_atlas.utils import *
-
+from apache_atlas.model.enums import TypeCategory
+from apache_atlas.model.misc import AtlasBase
+from apache_atlas.utils import non_null
+from apache_atlas.utils import type_coerce
+from apache_atlas.utils import type_coerce_dict_list
+from apache_atlas.utils import type_coerce_list
LOG = logging.getLogger('apache_atlas')
@@ -31,25 +31,25 @@ class AtlasBaseTypeDef(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.category = attrs.get('category')
- self.guid = attrs.get('guid')
- self.createdBy = attrs.get('createdBy')
- self.updatedBy = attrs.get('updatedBy')
- self.createTime = attrs.get('createTime')
- self.updateTime = attrs.get('updateTime')
- self.version = attrs.get('version')
- self.name = attrs.get('name')
+ self.category = attrs.get('category')
+ self.guid = attrs.get('guid')
+ self.createdBy = attrs.get('createdBy')
+ self.updatedBy = attrs.get('updatedBy')
+ self.createTime = attrs.get('createTime')
+ self.updateTime = attrs.get('updateTime')
+ self.version = attrs.get('version')
+ self.name = attrs.get('name')
self.description = attrs.get('description')
self.typeVersion = attrs.get('typeVersion')
self.serviceType = attrs.get('serviceType')
- self.options = attrs.get('options')
+ self.options = attrs.get('options')
class AtlasEnumDef(AtlasBaseTypeDef):
def __init__(self, attrs={}):
AtlasBaseTypeDef.__init__(self, attrs)
- self.elementDefs = attrs.get('elementDefs')
+ self.elementDefs = attrs.get('elementDefs')
self.defaultValue = attrs.get('defaultValue')
def type_coerce_attrs(self):
@@ -62,7 +62,7 @@ class AtlasStructDef(AtlasBaseTypeDef):
def __init__(self, attrs={}):
AtlasBaseTypeDef.__init__(self, attrs)
- self.category = non_null(attrs.get('category'), TypeCategory.STRUCT.name)
+ self.category = non_null(attrs.get('category'), TypeCategory.STRUCT.name)
self.attributeDefs = attrs.get('attributeDefs')
def type_coerce_attrs(self):
@@ -75,39 +75,39 @@ class AtlasClassificationDef(AtlasStructDef):
def __init__(self, attrs={}):
AtlasStructDef.__init__(self, attrs)
- self.category = TypeCategory.CLASSIFICATION.name
- self.superTypes = attrs.get('superTypes')
+ self.category = TypeCategory.CLASSIFICATION.name
+ self.superTypes = attrs.get('superTypes')
self.entityTypes = attrs.get('entityTypes')
- self.subTypes = attrs.get('subTypes')
+ self.subTypes = attrs.get('subTypes')
class AtlasEntityDef(AtlasStructDef):
def __init__(self, attrs={}):
AtlasStructDef.__init__(self, attrs)
- self.category = TypeCategory.ENTITY.name
- self.superTypes = attrs.get('superTypes')
- self.subTypes = attrs.get('subTypes')
+ self.category = TypeCategory.ENTITY.name
+ self.superTypes = attrs.get('superTypes')
+ self.subTypes = attrs.get('subTypes')
self.relationshipAttributeDefs = attrs.get('relationshipAttributeDefs')
- self.businessAttributeDefs = attrs.get('businessAttributeDefs')
+ self.businessAttributeDefs = attrs.get('businessAttributeDefs')
def type_coerce_attrs(self):
super(AtlasEntityDef, self).type_coerce_attrs()
self.relationshipAttributeDefs = type_coerce_list(self.relationshipAttributeDefs, AtlasRelationshipAttributeDef)
- self.businessAttributeDefs = type_coerce_dict_list(self.businessAttributeDefs, AtlasAttributeDef)
+ self.businessAttributeDefs = type_coerce_dict_list(self.businessAttributeDefs, AtlasAttributeDef)
class AtlasRelationshipDef(AtlasStructDef):
def __init__(self, attrs={}):
AtlasStructDef.__init__(self, attrs)
- self.category = TypeCategory.RELATIONSHIP.name
- self.relationshipCategory = attrs.get('relationshipCategory');
- self.relationshipLabel = attrs.get('relationshipLabel');
- self.propagateTags = attrs.get('propagateTags');
- self.endDef1 = attrs.get('endDef1');
- self.endDef2 = attrs.get('endDef2');
+ self.category = TypeCategory.RELATIONSHIP.name
+ self.relationshipCategory = attrs.get('relationshipCategory')
+ self.relationshipLabel = attrs.get('relationshipLabel')
+ self.propagateTags = attrs.get('propagateTags')
+ self.endDef1 = attrs.get('endDef1')
+ self.endDef2 = attrs.get('endDef2')
def type_coerce_attrs(self):
super(AtlasRelationshipDef, self).type_coerce_attrs()
@@ -127,22 +127,22 @@ class AtlasAttributeDef(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.name = attrs.get('name')
- self.typeName = attrs.get('typeName')
- self.isOptional = attrs.get('isOptional')
- self.cardinality = attrs.get('cardinality')
- self.valuesMinCount = attrs.get('valuesMinCount')
- self.valuesMaxCount = attrs.get('valuesMaxCount')
- self.isUnique = attrs.get('isUnique')
- self.isIndexable = attrs.get('isIndexable')
+ self.name = attrs.get('name')
+ self.typeName = attrs.get('typeName')
+ self.isOptional = attrs.get('isOptional')
+ self.cardinality = attrs.get('cardinality')
+ self.valuesMinCount = attrs.get('valuesMinCount')
+ self.valuesMaxCount = attrs.get('valuesMaxCount')
+ self.isUnique = attrs.get('isUnique')
+ self.isIndexable = attrs.get('isIndexable')
self.includeInNotification = attrs.get('includeInNotification')
- self.defaultValue = attrs.get('defaultValue')
- self.description = attrs.get('description')
- self.searchWeight = non_null(attrs.get('searchWeight'), -1)
- self.indexType = attrs.get('indexType')
- self.constraints = attrs.get('constraints')
- self.options = attrs.get('options')
- self.displayName = attrs.get('displayName')
+ self.defaultValue = attrs.get('defaultValue')
+ self.description = attrs.get('description')
+ self.searchWeight = non_null(attrs.get('searchWeight'), -1)
+ self.indexType = attrs.get('indexType')
+ self.constraints = attrs.get('constraints')
+ self.options = attrs.get('options')
+ self.displayName = attrs.get('displayName')
def type_coerce_attrs(self):
super(AtlasAttributeDef, self).type_coerce_attrs()
@@ -154,7 +154,7 @@ class AtlasConstraintDef(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.type = attrs.get('type')
+ self.type = attrs.get('type')
self.params = attrs.get('params')
@@ -162,9 +162,9 @@ class AtlasEnumElementDef(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.value = attrs.get('value')
+ self.value = attrs.get('value')
self.description = attrs.get('description')
- self.ordinal = attrs.get('ordinal')
+ self.ordinal = attrs.get('ordinal')
class AtlasRelationshipAttributeDef(AtlasAttributeDef):
@@ -172,40 +172,38 @@ class AtlasRelationshipAttributeDef(AtlasAttributeDef):
AtlasAttributeDef.__init__(self, attrs)
self.relationshipTypeName = attrs.get('relationshipTypeName')
- self.isLegacyAttribute = attrs.get('isLegacyAttribute')
+ self.isLegacyAttribute = attrs.get('isLegacyAttribute')
class AtlasRelationshipEndDef(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.type = attrs.get('type')
- self.name = attrs.get('name')
- self.isContainer = attrs.get('isContainer')
- self.cardinality = attrs.get('cardinality')
+ self.type = attrs.get('type')
+ self.name = attrs.get('name')
+ self.isContainer = attrs.get('isContainer')
+ self.cardinality = attrs.get('cardinality')
self.isLegacyAttribute = attrs.get('isLegacyAttribute')
- self.description = attrs.get('description')
+ self.description = attrs.get('description')
class AtlasTypesDef(AtlasBase):
def __init__(self, attrs={}):
AtlasBase.__init__(self, attrs)
- self.enumDefs = attrs.get('enumDefs')
- self.structDefs = attrs.get('structDefs')
- self.classificationDefs = attrs.get('classificationDefs')
- self.entityDefs = attrs.get('entityDefs')
- self.relationshipDefs = attrs.get('relationshipDefs')
+ self.enumDefs = attrs.get('enumDefs')
+ self.structDefs = attrs.get('structDefs')
+ self.classificationDefs = attrs.get('classificationDefs')
+ self.entityDefs = attrs.get('entityDefs')
+ self.relationshipDefs = attrs.get('relationshipDefs')
self.businessMetadataDefs = attrs.get('businessMetadataDefs')
def type_coerce_attrs(self):
super(AtlasTypesDef, self).type_coerce_attrs()
- self.enumDefs = type_coerce_list(self.enumDefs, AtlasEnumDef)
- self.structDefs = type_coerce_list(self.structDefs, AtlasStructDef)
- self.classificationDefs = type_coerce_list(self.classificationDefs, AtlasClassificationDef)
- self.entityDefs = type_coerce_list(self.entityDefs, AtlasEntityDef)
- self.relationshipDefs = type_coerce_list(self.relationshipDefs, AtlasRelationshipDef)
+ self.enumDefs = type_coerce_list(self.enumDefs, AtlasEnumDef)
+ self.structDefs = type_coerce_list(self.structDefs, AtlasStructDef)
+ self.classificationDefs = type_coerce_list(self.classificationDefs, AtlasClassificationDef)
+ self.entityDefs = type_coerce_list(self.entityDefs, AtlasEntityDef)
+ self.relationshipDefs = type_coerce_list(self.relationshipDefs, AtlasRelationshipDef)
self.businessMetadataDefs = type_coerce_list(self.businessMetadataDefs, AtlasBusinessMetadataDef)
-
-
diff --git a/intg/src/main/python/apache_atlas/utils.py b/intg/src/main/python/apache_atlas/utils.py
index 8384dc5..8500293 100644
--- a/intg/src/main/python/apache_atlas/utils.py
+++ b/intg/src/main/python/apache_atlas/utils.py
@@ -1,5 +1,4 @@
#!/usr/bin/env/python
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -16,19 +15,19 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
import enum
import time
-BASE_URI = "api/atlas/"
-APPLICATION_JSON = 'application/json'
+BASE_URI = "api/atlas/"
+APPLICATION_JSON = 'application/json'
APPLICATION_OCTET_STREAM = 'application/octet-stream'
-MULTIPART_FORM_DATA = 'multipart/form-data'
-PREFIX_ATTR = "attr:"
-PREFIX_ATTR_ = "attr_"
+MULTIPART_FORM_DATA = 'multipart/form-data'
+PREFIX_ATTR = "attr:"
+PREFIX_ATTR_ = "attr_"
s_nextId = milliseconds = int(round(time.time() * 1000)) + 1
+
def next_id():
global s_nextId
@@ -36,31 +35,35 @@ def next_id():
return "-" + str(s_nextId)
+
def list_attributes_to_params(attributes_list, query_params=None):
- if not query_params:
+ if query_params is None:
query_params = {}
for i, attr in enumerate(attributes_list):
for key, value in attr.items():
- new_key = PREFIX_ATTR_ + i + ":" + key
+ new_key = PREFIX_ATTR_ + i + ":" + key
query_params[new_key] = value
return query_params
+
def attributes_to_params(attributes, query_params=None):
- if not query_params:
+ if query_params is None:
query_params = {}
if attributes:
for key, value in attributes:
- new_key = PREFIX_ATTR + key
+ new_key = PREFIX_ATTR + key
query_params[new_key] = value
return query_params
+
def non_null(obj, defValue):
return obj if obj is not None else defValue
+
def type_coerce(obj, objType):
if isinstance(obj, objType):
ret = obj
@@ -73,6 +76,7 @@ def type_coerce(obj, objType):
return ret
+
def type_coerce_list(obj, objType):
if isinstance(obj, list):
ret = []
@@ -83,6 +87,7 @@ def type_coerce_list(obj, objType):
return ret
+
def type_coerce_dict(obj, objType):
if isinstance(obj, dict):
ret = {}
@@ -93,6 +98,7 @@ def type_coerce_dict(obj, objType):
return ret
+
def type_coerce_dict_list(obj, objType):
if isinstance(obj, dict):
ret = {}
@@ -106,11 +112,11 @@ def type_coerce_dict_list(obj, objType):
class API:
def __init__(self, path, method, expected_status, consumes=APPLICATION_JSON, produces=APPLICATION_JSON):
- self.path = path
- self.method = method
+ self.path = path
+ self.method = method
self.expected_status = expected_status
- self.consumes = consumes
- self.produces = produces
+ self.consumes = consumes
+ self.produces = produces
def format_path(self, params):
return API(self.path.format(**params), self.method, self.expected_status, self.consumes, self.produces)
@@ -124,14 +130,14 @@ class API:
return API(path, self.method, self.expected_status, self.consumes, self.produces)
-class HttpMethod(enum.Enum):
- GET = "GET"
- PUT = "PUT"
- POST = "POST"
+class HTTPMethod(enum.Enum):
+ GET = "GET"
+ PUT = "PUT"
+ POST = "POST"
DELETE = "DELETE"
class HTTPStatus:
- OK = 200
- NO_CONTENT = 204
+ OK = 200
+ NO_CONTENT = 204
SERVICE_UNAVAILABLE = 503
diff --git a/intg/src/main/python/requirements-dev.txt b/intg/src/main/python/requirements-dev.txt
new file mode 100644
index 0000000..26c4295
--- /dev/null
+++ b/intg/src/main/python/requirements-dev.txt
@@ -0,0 +1,2 @@
+flake8
+mypy
diff --git a/intg/src/main/python/setup.py b/intg/src/main/python/setup.py
index f11fa55..7c563c9 100644
--- a/intg/src/main/python/setup.py
+++ b/intg/src/main/python/setup.py
@@ -46,5 +46,5 @@ setup(
include_package_data=True,
zip_safe=False,
keywords='atlas client, apache atlas',
- python_requires='>=2.7',
+ python_requires='>=2.7',
)
diff --git a/intg/src/main/python/tox.ini b/intg/src/main/python/tox.ini
new file mode 100644
index 0000000..6deafc2
--- /dev/null
+++ b/intg/src/main/python/tox.ini
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 120