Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column Level Badging Through API #944

Closed
alldoami opened this issue Mar 5, 2021 · 1 comment
Closed

Column Level Badging Through API #944

alldoami opened this issue Mar 5, 2021 · 1 comment

Comments

@alldoami
Copy link
Contributor

alldoami commented Mar 5, 2021

The only way to add badges to columns currently is through the databuilder and there is only API support for tables. It would be great to provide API support for column level badging.

Expected Behavior or Use Case

Defining badges to the metadata config and config-custom.ts in the amundsenfrontendlibrary should stay the same. Ability to badge columns with a similar curl command like: curl -X PUT https://{your metadata url}/column/{column key}/badge/{badge name}?category={badge category}.

Where the column key would be in the format: datasource://database.schema/table/column (e.g. hive://gold.testschema/testtable)

Service or Ingestion ETL

This is within the amundsenmetadatalibrary.

Possible Implementation

I believe adding this to metadata_servie/api/column.py would be most of the code:

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/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.Column,
                                      badge_name=badge,
                                      category=category,
                                      column_name=column_name)

    @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.Column,
                                         badge_name=badge,
                                         category=category,
                                         column_name=column_name)

And adding this resource to the metadata_service/__init__.py:

    api.add_resource(ColumnBadgeAPI,
                     '/table/<path:id>/column/<column_name>/badge/<badge>')

I also see this TODO in the badge.py file: https://github.com/amundsen-io/amundsenmetadatalibrary/blob/master/metadata_service/api/badge.py#L56

Context

Being able to hit the API for low-effort badge assignment would be helpful when there are minimum amount of badges to assign.

@feng-tao
Copy link
Member

both prs are merged now. thanks @alldoami for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants