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/15 17:50:34 UTC
[atlas] 02/02: ATLAS-4080: updated Python client with addition of
API to retrieve metrics
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
commit af55c7f8799a95a1f26a38d51309bd9c5246bc77
Author: Verdan Mahmood <ve...@gmail.com>
AuthorDate: Tue Dec 15 09:35:38 2020 -0800
ATLAS-4080: updated Python client with addition of API to retrieve metrics
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
---
intg/src/main/python/README.md | 2 +-
.../apache_atlas/{model/metrics.py => client/admin.py} | 14 ++++++++++----
intg/src/main/python/apache_atlas/client/base_client.py | 4 ++--
.../python/apache_atlas/model/{metrics.py => admin.py} | 14 ++++++++++----
intg/src/main/python/setup.py | 2 +-
5 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/intg/src/main/python/README.md b/intg/src/main/python/README.md
index 9d80a68..a973717 100644
--- a/intg/src/main/python/README.md
+++ b/intg/src/main/python/README.md
@@ -16,7 +16,7 @@ Verify if apache-atlas client is installed:
Package Version
------------ ---------
-apache-atlas 0.0.2
+apache-atlas 0.0.3
```
## Usage
diff --git a/intg/src/main/python/apache_atlas/model/metrics.py b/intg/src/main/python/apache_atlas/client/admin.py
similarity index 70%
copy from intg/src/main/python/apache_atlas/model/metrics.py
copy to intg/src/main/python/apache_atlas/client/admin.py
index 636a3ea..171bcf8 100644
--- a/intg/src/main/python/apache_atlas/model/metrics.py
+++ b/intg/src/main/python/apache_atlas/client/admin.py
@@ -17,11 +17,17 @@
# 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 *
-class AtlasMetrics(AtlasBase):
- def __init__(self, attrs={}):
- AtlasBase.__init__(self, attrs)
+class AdminClient:
+ BASE_ADMIN_URL = BASE_URI + "admin/"
- self.data = attrs.get('data')
+ GET_METRICS_API = API(BASE_ADMIN_URL + "metrics", HttpMethod.GET, HTTPStatus.OK)
+
+ def __init__(self, client):
+ self.client = client
+
+ def get_metrics(self):
+ return self.client.call_api(AdminClient.GET_METRICS_API, AtlasAdminMetrics)
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 3e6002d..fe0ddf4 100644
--- a/intg/src/main/python/apache_atlas/client/base_client.py
+++ b/intg/src/main/python/apache_atlas/client/base_client.py
@@ -28,11 +28,11 @@ 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
-
LOG = logging.getLogger('apache_atlas')
@@ -50,10 +50,10 @@ class AtlasClient:
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)
diff --git a/intg/src/main/python/apache_atlas/model/metrics.py b/intg/src/main/python/apache_atlas/model/admin.py
similarity index 69%
rename from intg/src/main/python/apache_atlas/model/metrics.py
rename to intg/src/main/python/apache_atlas/model/admin.py
index 636a3ea..3be8a94 100644
--- a/intg/src/main/python/apache_atlas/model/metrics.py
+++ b/intg/src/main/python/apache_atlas/model/admin.py
@@ -17,11 +17,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from apache_atlas.utils import *
+from apache_atlas.model.instance import AtlasBase
-class AtlasMetrics(AtlasBase):
- def __init__(self, attrs={}):
+class AtlasAdminMetrics(AtlasBase):
+ def __init__(self, attrs=None):
AtlasBase.__init__(self, attrs)
- self.data = attrs.get('data')
+ attrs = attrs or {}
+ _data = attrs.get('data', {})
+
+ self.general = _data.get('general', {})
+ self.tag = _data.get('tag', {})
+ self.entity = _data.get('entity', {})
+ self.system = _data.get('system', {})
diff --git a/intg/src/main/python/setup.py b/intg/src/main/python/setup.py
index ed33ebe..f11fa55 100644
--- a/intg/src/main/python/setup.py
+++ b/intg/src/main/python/setup.py
@@ -28,7 +28,7 @@ with open("README.md", "r") as fh:
setup(
name='apache-atlas',
- version='0.0.2',
+ version='0.0.3',
author="Apache Atlas",
author_email='dev@atlas.apache.org',
description="Apache Atlas Python Client",