From 26815d9410a869342ed19f6671252cd8b4e79b17 Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Tue, 18 Oct 2022 18:17:45 +0530 Subject: [PATCH] Doc : Add How to guide for Custom Property (#8209) * Doc : Add How to guide for Custom Property * Update the hostname --- .../how-to-guides/custom-properties.md | 145 ++++++++++++++++++ openmetadata-docs/content/menu.md | 13 +- 2 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 openmetadata-docs/content/how-to-guides/custom-properties.md diff --git a/openmetadata-docs/content/how-to-guides/custom-properties.md b/openmetadata-docs/content/how-to-guides/custom-properties.md new file mode 100644 index 00000000000..8919df1e90f --- /dev/null +++ b/openmetadata-docs/content/how-to-guides/custom-properties.md @@ -0,0 +1,145 @@ +--- +title: How to add a custom property to an entity +slug: /how-to-guides/how-to-add-custom-property-to-an-entity +--- + +# How to add a custom property to an entity with API + +This tutorial will create a custom property for a `table` entity. + +Let's assume in your organization you want to keep track of table size, so to achieve that you will be creating a custom property for table entities and then providing a value to that property for each table. + +### Step 1: Get the table entity type. + +All OpenMetadata APIs are secured so make sure to add the proper headers. + +```commandline +curl -X GET http://localhost:8585/api/v1/metadata/types/name/table +``` + +After the API call, you will get a response like this. + +```json +{ + "id": "7f0b032f-cdc8-4573-abb0-22165dcd8e07", + "name": "table", + "customProperties": [ + { + "name": "tableSize", + "description": "Property for tracking the tableSize.", + "propertyType": { + "id": "7531f881-c37c-4e39-9154-4bdf0802e05e", + "type": "type", + "name": "string", + "fullyQualifiedName": "string", + "description": "\"A String type.\"", + "displayName": "string", + "href": "http://localhost:8585/api/v1/metadata/types/7531f881-c37c-4e39-9154-4bdf0802e05e" + } + } + ] +} +``` + +Now take the `id` from above response `7f0b032f-cdc8-4573-abb0-22165dcd8e07`. + +### Step 2: Get the field types with `category=field` + +> From UI OpenMetadata only supports three field types +> +> - String +> - Markdown +> - Integer + +```commandline + curl -X GET http://localhost:8585/api/v1/metadata/types?category=field +``` + +This API will return all the available field types, for this tutorial grab the id of the `string` field type. i.e `7531f881-c37c-4e39-9154-4bdf0802e05e` + +### Step 3: Make a PUT call to create the custom property for the table entity + +```commandline +curl -X PUT http://localhost:8585/api/v1/metadata/types/7f0b032f-cdc8-4573-abb0-22165dcd8e07 +``` + +**Payload** + +```json +{ + "description": "Property for tracking the tableSize.", + "name": "tableSize", + "propertyType": { + "id": "7531f881-c37c-4e39-9154-4bdf0802e05e", + "type": "type" + } +} +``` + +### Step 4: Get the custom properties for the table entity + +```commandline +curl -X GET http://localhost:8585/api/v1/metadata/types/name/table?fields=customProperties +``` + +**Response** + +```json +{ + "id": "7f0b032f-cdc8-4573-abb0-22165dcd8e07", + "name": "table", + "customProperties": [ + { + "name": "tableSize", + "description": "Property for tracking the tableSize.", + "propertyType": { + "id": "7531f881-c37c-4e39-9154-4bdf0802e05e", + "type": "type", + "name": "string", + "fullyQualifiedName": "string", + "description": "\"A String type.\"", + "displayName": "string", + "href": "http://localhost:8585/api/v1/metadata/types/7531f881-c37c-4e39-9154-4bdf0802e05e" + } + } + ] +} +``` + +So for all table entities, we have `tableSize` custom property available now, let’s add the value for it for the `raw_product_catalog` table. + +### Step 5: Add/Edit the value of the custom property for the entity. + +All the custom properties value for the entity will be stored in the `extension` attribute. + +Let’s assume you have `raw_product_catalog` table and its id is `208598fc-bd5f-458c-bf98-59224e1620c7` so our PATCH API request will be like this. + +```commandline +curl -X PATCH http://localhost:8585/api/v1/tables/208598fc-bd5f-458c-bf98-59224e1620c7 +``` + +For the first time if we want to add the value to the custom property then the payload should be like this. + +```json +[ + { + "op": "add", + "path": "/extension", + "value": { + "tableSize": "50GB" + } + } +] +``` + +When Changing the value of the custom property payload should be like this, + +```json +[ + { + "op": "replace", + "path": "/extension/tableSize", + "value": "60GB" + } +] +``` diff --git a/openmetadata-docs/content/menu.md b/openmetadata-docs/content/menu.md index 20147c323b5..6eeee64785b 100644 --- a/openmetadata-docs/content/menu.md +++ b/openmetadata-docs/content/menu.md @@ -156,15 +156,15 @@ site_menu: - category: Deployment / Airflow url: /deployment/airflow - + - category: Connectors url: /connectors color: violet-70 icon: openmetadata - - category: Connectors / Database + - category: Connectors / Database url: /connectors/database - - category: Connectors / Database / Athena + - category: Connectors / Database / Athena url: /connectors/database/athena - category: Connectors / Database / Athena / Airflow url: /connectors/database/athena/airflow @@ -483,7 +483,6 @@ site_menu: - category: Connectors / Ingestion / Run Connectors in your Airflow url: /connectors/ingestion/run-connectors-in-airflow - - category: How to guides url: /how-to-guides color: violet-70 @@ -499,14 +498,14 @@ site_menu: url: /how-to-guides/teams-and-users - category: How to guides / Teams and Users / How to Organise Teams and Users url: /how-to-guides/teams-and-users/how-to-organise-teams-and-users - - + - category: How to guides / How to add a custom property to an entity + url: /how-to-guides/how-to-add-custom-property-to-an-entity - category: Features url: /openmetadata color: violet-70 icon: openmetadata - + - category: Features / Discovery & Collaboration url: /openmetadata/discovery-collaboration