class DashboardBadgeAPI(Resource): """ DashboardBadgeAPI that supports PUT and DELETE operation to add or delete badges on Dashboard """ def __init__(self) -> None: self.client = get_proxy_client() self.parser = reqparse.RequestParser() self.parser.add_argument('category', type=str, required=True) super(DashboardBadgeAPI, self).__init__() self._badge_common = BadgeCommon(client=self.client) @swag_from('swagger_doc/badge/badge_put.yml') def put(self, id: str, badge: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() category = args.get('category', '') return self._badge_common.put(id=id, resource_type=ResourceType.Dashboard, badge_name=badge, category=category) @swag_from('swagger_doc/badge/badge_delete.yml') def delete(self, id: str, badge: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() category = args.get('category', '') return self._badge_common.delete(id=id, resource_type=ResourceType.Dashboard, badge_name=badge, category=category)
class TypeMetadataBadgeAPI(Resource): def __init__(self) -> None: self.client = get_proxy_client() self.parser = reqparse.RequestParser() self.parser.add_argument('category', type=str, required=True) super(TypeMetadataBadgeAPI, self).__init__() self._badge_common = BadgeCommon(client=self.client) @swag_from('swagger_doc/type_metadata/badge_put.yml') def put(self, type_metadata_key: str, badge: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() category = args.get('category', '') return self._badge_common.put(id=type_metadata_key, resource_type=ResourceType.Type_Metadata, badge_name=badge, category=category) @swag_from('swagger_doc/type_metadata/badge_delete.yml') def delete(self, type_metadata_key: str, badge: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() category = args.get('category', '') return self._badge_common.delete(id=type_metadata_key, resource_type=ResourceType.Type_Metadata, badge_name=badge, category=category)
class ColumnBadgeAPI(Resource): def __init__(self) -> None: self.client = get_proxy_client() self.parser = reqparse.RequestParser() self.parser.add_argument('category', type=str, required=True) super(ColumnBadgeAPI, self).__init__() self._badge_common = BadgeCommon(client=self.client) @swag_from('swagger_doc/column/badge_put.yml') def put(self, table_uri: str, badge: str, column_name: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() category = args.get('category', '') return self._badge_common.put(id=f"{table_uri}/{column_name}", resource_type=ResourceType.Column, badge_name=badge, category=category) @swag_from('swagger_doc/column/badge_delete.yml') def delete(self, table_uri: str, badge: str, column_name: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() category = args.get('category', '') return self._badge_common.delete(id=f"{table_uri}/{column_name}", resource_type=ResourceType.Column, badge_name=badge, category=category)
class TableBadgeAPI(Resource): def __init__(self) -> None: self.client = get_proxy_client() self.parser = reqparse.RequestParser() self.parser.add_argument('category', type=str, required=True) self.parser.add_argument('badge_type', type=str, required=True) super(TableBadgeAPI, self).__init__() self._badge_common = BadgeCommon(client=self.client) @swag_from('swagger_doc/badge/badge_put.yml') def put(self, id: str, badge: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() # TODO should I have default here? category = args.get('category', '') badge_type = args.get('badge_type', '') return self._badge_common.put(id=id, resource_type=ResourceType.Table, badge_name=badge, category=category, badge_type=badge_type) @swag_from('swagger_doc/badge/badge_delete.yml') def delete(self, id: str, badge: str) -> Iterable[Union[Mapping, int, None]]: args = self.parser.parse_args() category = args.get('category', '') badge_type = args.get('badge_type', '') return self._badge_common.delete(id=id, resource_type=ResourceType.Table, badge_name=badge, category=category, badge_type=badge_type)