-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
List Dashboards using Table API (#137)
* List Dashboards using Table API * Update * Update * Update
- Loading branch information
1 parent
27147b2
commit a2272af
Showing
11 changed files
with
207 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
metadata_service/api/swagger_doc/table/dashboards_using_table_get.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Gets Dashboards that is using this table | ||
--- | ||
tags: | ||
- 'table' | ||
parameters: | ||
- name: id | ||
in: path | ||
type: string | ||
schema: | ||
type: string | ||
required: true | ||
example: 'hive://gold.test_schema/test_table2' | ||
responses: | ||
200: | ||
description: 'List of dashboards that table is used' | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
dashboards: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/DashboardSummary' | ||
404: | ||
description: 'Table not found' | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ErrorResponse' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import List | ||
|
||
import attr | ||
from amundsen_common.models.dashboard import DashboardSummary as Summary | ||
from marshmallow_annotations.ext.attrs import AttrsSchema | ||
|
||
|
||
@attr.s(auto_attribs=True, kw_only=True) | ||
class DashboardSummary: | ||
dashboards: List[Summary] = attr.ib(factory=list) | ||
|
||
|
||
class DashboardSummarySchema(AttrsSchema): | ||
class Meta: | ||
target = DashboardSummary | ||
register_as_scheme = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import unittest | ||
from http import HTTPStatus | ||
|
||
from metadata_service.entity.resource_type import ResourceType | ||
from tests.unit.api.table.table_test_case import TableTestCase | ||
|
||
TABLE_URI = 'wizards' | ||
|
||
QUERY_RESPONSE = { | ||
'dashboards': [ | ||
{ | ||
'uri': 'foo_dashboard://gold.foo/bar1', | ||
'cluster': 'gold', | ||
'group_name': 'foo', | ||
'group_url': 'https://foo', | ||
'product': 'foo', | ||
'name': 'test dashboard 1', | ||
'url': 'https://foo.bar', | ||
'description': 'test dashboard description 1', | ||
'last_successful_run_timestamp': 1234567890 | ||
}, | ||
{ | ||
'uri': 'foo_dashboard://gold.foo/bar1', | ||
'cluster': 'gold', | ||
'group_name': 'foo', | ||
'group_url': 'https://foo', | ||
'product': 'foo', | ||
'name': 'test dashboard 1', | ||
'url': 'https://foo.bar', | ||
'description': None, | ||
'last_successful_run_timestamp': None | ||
} | ||
] | ||
} | ||
|
||
API_RESPONSE = { | ||
'dashboards': | ||
[ | ||
{ | ||
'group_url': 'https://foo', 'uri': 'foo_dashboard://gold.foo/bar1', | ||
'last_successful_run_timestamp': 1234567890, 'group_name': 'foo', 'name': 'test dashboard 1', | ||
'url': 'https://foo.bar', 'description': 'test dashboard description 1', 'cluster': 'gold', | ||
'product': 'foo' | ||
}, | ||
{ | ||
'group_url': 'https://foo', 'uri': 'foo_dashboard://gold.foo/bar1', | ||
'last_successful_run_timestamp': None, | ||
'group_name': 'foo', 'name': 'test dashboard 1', 'url': 'https://foo.bar', 'description': None, | ||
'cluster': 'gold', 'product': 'foo' | ||
} | ||
] | ||
} | ||
|
||
|
||
class TestTableDashboardAPI(TableTestCase): | ||
|
||
def test_get_dashboards_using_table(self) -> None: | ||
self.mock_proxy.get_resources_using_table.return_value = QUERY_RESPONSE | ||
|
||
response = self.app.test_client().get(f'/table/{TABLE_URI}/dashboard/') | ||
self.assertEqual(response.json, API_RESPONSE) | ||
self.assertEqual(response.status_code, HTTPStatus.OK) | ||
self.mock_proxy.get_resources_using_table.assert_called_with(id=TABLE_URI, | ||
resource_type=ResourceType.Dashboard) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |